format_range.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2022 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef PSEN_SCAN_V2_STANDALONE_FORMAT_RANGE_H
17 #define PSEN_SCAN_V2_STANDALONE_FORMAT_RANGE_H
18 
19 #include <algorithm>
20 #include <iterator>
21 #include <sstream>
22 #include <string>
23 
24 #include <fmt/format.h>
25 
27 {
28 namespace util
29 {
37 template <typename T>
38 std::string formatRange(const T& range)
39 {
40  std::stringstream strstr;
41  strstr << "{";
42  for (auto it = range.begin(); std::next(it) < range.end(); ++it)
43  {
44  strstr << fmt::format("{}, ", *it);
45  }
46  if (range.begin() < range.end())
47  {
48  strstr << fmt::format("{}", *std::prev(range.end()));
49  }
50  strstr << "}";
51  return strstr.str();
52 }
53 
54 } // namespace util
55 } // namespace psen_scan_v2_standalone
56 
57 #endif // PSEN_SCAN_V2_STANDALONE_FORMAT_RANGE_H
psen_scan_v2_standalone::util::formatRange
std::string formatRange(const T &range)
Definition: format_range.h:38
psen_scan_v2_standalone
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:11