Orfeo Toolbox  3.16
otbOGRHelpers.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbOGRHelpers_h
19 #define __otbOGRHelpers_h
20 
21 #include <string>
22 #include <vector>
23 #include <cassert>
24 #include <boost/range/begin.hpp>
25 #include <boost/range/end.hpp>
26 #include <boost/range/size.hpp>
27 #include <boost/mpl/assert.hpp>
28 #include <boost/type_traits/is_same.hpp>
29 #if ! defined(NDEBUG)
30 #include "cpl_string.h" // CSLCount
31 #endif
32 
33 namespace otb
34 {
35 namespace ogr
36 {
56 {
57 
58  template <class ContainerType>
69  explicit StringListConverter(ContainerType const& strings)
70  {
71  BOOST_MPL_ASSERT((boost::is_same<typename ContainerType::value_type, std::string>));
72  m_raw.reserve(boost::size(strings)+1);
73  for (typename ContainerType::const_iterator b = boost::begin(strings), e = boost::end(strings); b != e; ++b)
74  {
75  m_raw.push_back(b->c_str());
76  }
77  m_raw.push_back(0);
78  assert(CSLCount(const_cast <char**>(&m_raw[0])) == boost::size(strings));
79  }
83  char ** to_ogr() const
84  {
85  return m_raw.size() == 1
86  ? NULL
87  : const_cast <char**>(&m_raw[0]);
88  }
89 private:
90  std::vector<char const*> m_raw;
91 };
92 
93 } // ogr namespace
94 } // end namespace otb
95 
96 #endif // __otbOGRHelpers_h

Generated at Sun May 19 2013 00:42:31 for Orfeo Toolbox with doxygen 1.8.3.1