scenario_simulator_v2 C++ API
print.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef OPENSCENARIO_INTERPRETER__UTILITY__PRINT_HPP_
16 #define OPENSCENARIO_INTERPRETER__UTILITY__PRINT_HPP_
17 
18 #include <iomanip>
19 #include <iostream>
20 
22 {
23 inline namespace utility
24 {
25 template <typename SequenceContainer>
26 auto & print_to(std::ostream & os, const SequenceContainer & sequence_container)
27 {
28  const auto * separator = "[";
29 
30  for (const auto & each : sequence_container) {
31  os << separator << each;
32  separator = ", ";
33  }
34 
35  return os << "]";
36 }
37 
38 inline auto print_keys_to = [](auto & os, const auto & xs) -> decltype(auto) {
39  if (not xs.empty()) {
40  for (auto iter = std::begin(xs); iter != std::end(xs); ++iter) {
41  os << std::get<0>(*iter);
42  switch (std::distance(iter, std::end(xs))) {
43  case 1:
44  return os;
45  case 2:
46  os << " and ";
47  break;
48  default:
49  os << ", ";
50  break;
51  }
52  }
53  }
54  return os;
55 };
56 } // namespace utility
57 } // namespace openscenario_interpreter
58 
59 #endif // OPENSCENARIO_INTERPRETER__UTILITY__PRINT_HPP_
auto & print_to(std::ostream &os, const SequenceContainer &sequence_container)
Definition: print.hpp:26
auto print_keys_to
Definition: print.hpp:38
Definition: escape_sequence.hpp:22
auto distance(const geometry_msgs::Pose &pose1, const geometry_msgs::Pose &pose2)
Definition: detection_sensor.cpp:34
Definition: junit5.hpp:25