32 #ifndef _HUGIN_UTILS_STL_UTILS_H
33 #define _HUGIN_UTILS_STL_UTILS_H
46 namespace hugin_utils {
49 inline std::string
tolower(
const std::string& s)
51 std::string result = s;
52 std::transform<std::string::iterator,
53 std::string::iterator,
54 int (*)(int)>(result.begin(), result.end(),
59 inline std::string
toupper(
const std::string& s)
61 std::string result = s;
62 std::transform<std::string::iterator,
63 std::string::iterator,
64 int (*)(int)>(result.begin(), result.end(),
72 template<
typename _Container>
74 inline bool set_contains(
const _Container & c,
const typename _Container::key_type & key)
76 return c.find(key) != c.end();
80 template<
typename _Container>
81 inline void fill_set(_Container & c,
typename _Container::key_type begin,
82 typename _Container::key_type end)
84 for (
typename _Container::key_type i=begin; i <= end; i++) {
97 template<
typename Map>
98 typename Map::mapped_type &
map_get(Map &m,
const typename Map::key_type & key)
100 typename Map::iterator it = m.find(key);
105 throw std::out_of_range(
"No such element in vector");
109 template<
typename Map>
110 const typename Map::mapped_type &
const_map_get(
const Map &m,
const typename Map::key_type & key)
112 typename Map::const_iterator it = m.find(key);
117 throw std::out_of_range(
"No such element in vector");
122 template<
typename Map>
123 typename Map::mapped_type &
map_get(Map &m,
const char * key)
125 typename Map::iterator it = m.find(key);
130 throw std::out_of_range(
"No such element in vector");
134 template<
typename Map>
135 const typename Map::mapped_type &
const_map_get(
const Map &m,
const char * key)
137 typename Map::const_iterator it = m.find(key);
142 throw std::out_of_range(
"No such element in vector");
146 #endif // _HUGIN_UTILS_STL_UTILS_H
bool set_contains(const _Container &c, const typename _Container::key_type &key)
std::string toupper(const std::string &s)
const Map::mapped_type & const_map_get(const Map &m, const typename Map::key_type &key)
Map::mapped_type & map_get(Map &m, const typename Map::key_type &key)
get a map element.
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
std::string tolower(const std::string &s)
convert a string to lowercase