OTB  9.0.0
Orfeo Toolbox
otbJoinContainer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbJoinContainer_h
22 #define otbJoinContainer_h
23 
24 // #include <iosfwd>
25 #include <string>
26 
27 #include <ostream>
28 // #include <boost/range/iterator.hpp>
29 #include <boost/range/begin.hpp>
30 #include <boost/range/end.hpp>
31 #include <boost/range/empty.hpp>
32 namespace otb
33 {
46 template <typename TRange>
47 inline std::ostream& Join(std::ostream& os, TRange const& range, std::string const& separator)
48 {
49  if (!boost::empty(range))
50  {
51  typename boost::range_iterator<TRange const>::type first = boost::begin(range);
52  typename boost::range_iterator<TRange const>::type const last = boost::end(range);
53  os << *first;
54  for (++first; first != last; ++first)
55  {
56  os << separator << *first;
57  }
58  }
59  return os;
60 }
62 
73 template <typename Tmap>
74 inline std::ostream& JoinMap(std::ostream& os, Tmap const& range, std::string const& separator)
75 {
76  if (!boost::empty(range))
77  {
78  typename boost::range_iterator<Tmap const>::type first = boost::begin(range);
79  typename boost::range_iterator<Tmap const>::type const last = boost::end(range);
80  os << first->second;
81  for (++first; first != last; ++first)
82  {
83  os << separator << first->second;
84  }
85  }
86  return os;
87 }
88 } // end namespace otb
90 
91 #ifndef OTB_MANUAL_INSTANTIATION
92 // #include "otbJoinContainer.hxx"
93 #endif
94 
95 #endif // otbJoinContainer_h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::JoinMap
std::ostream & JoinMap(std::ostream &os, Tmap const &range, std::string const &separator)
Definition: otbJoinContainer.h:74
otb::Join
std::ostream & Join(std::ostream &os, TRange const &range, std::string const &separator)
Definition: otbJoinContainer.h:47