ptree_utils.hpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2002-2006 Marcin Kalicinski
3 //
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // For more information, see www.boost.org
9 // ----------------------------------------------------------------------------
10 #ifndef BOOST_PROPERTY_TREE_DETAIL_PTREE_UTILS_HPP_INCLUDED
11 #define BOOST_PROPERTY_TREE_DETAIL_PTREE_UTILS_HPP_INCLUDED
12 
13 #include <boost/limits.hpp>
15 #include <boost/mpl/has_xxx.hpp>
16 #include <boost/mpl/and.hpp>
17 #include <string>
18 #include <algorithm>
19 #include <locale>
20 
21 namespace boost { namespace property_tree { namespace detail
22 {
23 
24  template<class T>
25  struct less_nocase
26  {
27  typedef typename T::value_type Ch;
28  std::locale m_locale;
29  inline bool operator()(Ch c1, Ch c2) const
30  {
31  return std::toupper(c1, m_locale) < std::toupper(c2, m_locale);
32  }
33  inline bool operator()(const T &t1, const T &t2) const
34  {
35  return std::lexicographical_compare(t1.begin(), t1.end(),
36  t2.begin(), t2.end(), *this);
37  }
38  };
39 
40  template <typename Ch>
41  struct is_character : public boost::false_type {};
42  template <>
43  struct is_character<char> : public boost::true_type {};
44  template <>
45  struct is_character<wchar_t> : public boost::true_type {};
46 
47 
48  BOOST_MPL_HAS_XXX_TRAIT_DEF(internal_type)
49  BOOST_MPL_HAS_XXX_TRAIT_DEF(external_type)
50  template <typename T>
52  has_internal_type<T>, has_external_type<T> > {};
53 
54 
55 
56  // Naively convert narrow string to another character type
57  template<typename Str>
58  Str widen(const char *text)
59  {
60  Str result;
61  while (*text)
62  {
63  result += typename Str::value_type(*text);
64  ++text;
65  }
66  return result;
67  }
68 
69  // Naively convert string to narrow character type
70  template<typename Str, typename char_type>
71  Str narrow(const char_type *text)
72  {
73  Str result;
74  while (*text)
75  {
76  if (*text < 0 || *text > (std::numeric_limits<char>::max)())
77  result += '*';
78  else
79  result += typename Str::value_type(*text);
80  ++text;
81  }
82  return result;
83  }
84 
85  // Remove trailing and leading spaces
86  template<class Str>
87  Str trim(const Str &s, const std::locale &loc = std::locale())
88  {
89  typename Str::const_iterator first = s.begin();
90  typename Str::const_iterator end = s.end();
91  while (first != end && std::isspace(*first, loc))
92  ++first;
93  if (first == end)
94  return Str();
95  typename Str::const_iterator last = end;
96  do --last; while (std::isspace(*last, loc));
97  if (first != s.begin() || last + 1 != end)
98  return Str(first, last + 1);
99  else
100  return s;
101  }
102 
103 } } }
104 
105 #endif
boost::property_tree::detail::less_nocase::Ch
T::value_type Ch
Definition: ptree_utils.hpp:27
boost::property_tree::detail::less_nocase::m_locale
std::locale m_locale
Definition: ptree_utils.hpp:28
T
T
Definition: mem_fn_cc.hpp:25
s
XmlRpcServer s
integral_constant.hpp
boost::property_tree::detail::narrow
Str narrow(const char_type *text)
Definition: ptree_utils.hpp:71
boost
BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE.
and.hpp
boost::property_tree::detail::widen
Str widen(const char *text)
Definition: ptree_utils.hpp:58
boost::property_tree::detail::is_character
Definition: ptree_utils.hpp:41
boost::foreach_detail_::end
auto_any< BOOST_DEDUCED_TYPENAME foreach_iterator< T, C >::type > end(auto_any_t col, type2type< T, C > *, boost::mpl::true_ *)
Definition: foreach.hpp:700
has_xxx.hpp
boost::property_tree::detail::trim
Str trim(const Str &s, const std::locale &loc=std::locale())
Definition: ptree_utils.hpp:87
boost::property_tree::detail::less_nocase::operator()
bool operator()(const T &t1, const T &t2) const
Definition: ptree_utils.hpp:33
boost::property_tree::detail::less_nocase::operator()
bool operator()(Ch c1, Ch c2) const
Definition: ptree_utils.hpp:29
boost::property_tree::detail::less_nocase
Definition: ptree_utils.hpp:25
boost::property_tree::detail::is_translator
Definition: ptree_utils.hpp:51
BOOST_MPL_HAS_XXX_TRAIT_DEF
#define BOOST_MPL_HAS_XXX_TRAIT_DEF(name)
Definition: has_xxx.hpp:278
boost::mpl::and_
Definition: mpl/aux_/preprocessed/bcc/and.hpp:48
boost::integral_constant< bool, false >
limits.hpp


sick_visionary_ros
Author(s): SICK AG TechSupport 3D Snapshot
autogenerated on Thu Feb 8 2024 03:45:47