OTB  7.2.0
Orfeo Toolbox
otbJoinContainer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2020 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 }
61 } // end namespace otb
63 
64 #ifndef OTB_MANUAL_INSTANTIATION
65 // #include "otbJoinContainer.hxx"
66 #endif
67 
68 #endif // otbJoinContainer_h
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
std::ostream & Join(std::ostream &os, TRange const &range, std::string const &separator)