35 #ifndef _Wolframe_TYPES_KEYMAP_HPP_INCLUDED
36 #define _Wolframe_TYPES_KEYMAP_HPP_INCLUDED
41 #include <boost/algorithm/string.hpp>
42 #include <boost/utility/enable_if.hpp>
43 #include <boost/type_traits.hpp>
44 #include <boost/detail/select_type.hpp>
55 :std::string( boost::to_upper_copy( std::string(o))){}
57 :std::string( boost::to_upper_copy( o)){}
65 template <
typename ValueType>
67 :
public std::map<keystring,ValueType>
69 typedef std::map<keystring,ValueType>
Parent;
74 keymap(
const std::map<std::string,ValueType>& o)
76 std::copy( o.begin(), o.end(), std::inserter( *
this, this->end()));
81 if (Parent::find( key) != this->end())
83 throw std::runtime_error( std::string(
"duplicate definition of '") + key +
"'");
85 Parent::operator[](key) = value;
90 typename Parent::const_iterator ki = m.begin(), ke = m.end();
91 for (; ki != ke; ++ki)
insert( ki->first, ki->second);
96 typename Parent::const_iterator ki = m.begin(), ke = m.end();
97 for (; ki != ke; ++ki)
99 typename Parent::const_iterator fi = Parent::find( ki->first);
100 if (fi != this->end())
102 if (ki->second != fi->second)
104 throw std::runtime_error( std::string(
"duplicate definition of '") + ki->first +
"'");
109 Parent::operator[](ki->first) = ki->second;
114 template <
class KeyList>
115 typename boost::enable_if_c<
121 typename Parent::const_iterator ki = Parent::begin(), ke = Parent::end();
122 for (; ki != ke; ++ki) rt.push_back( ki->first);
Constructor for implementing implicit type reductions in key maps that store the key as upper case st...
Definition: keymap.hpp:51
Map with case insensitive strings as keys.
Definition: keymap.hpp:66
void join(const keymap &m)
Definition: keymap.hpp:94
keymap(const std::map< std::string, ValueType > &o)
Definition: keymap.hpp:74
void insert(const keymap &m)
Definition: keymap.hpp:88
keymap(const keymap &o)
Definition: keymap.hpp:72
std::map< keystring, ValueType > Parent
Definition: keymap.hpp:69
void insert(const keystring &key, const ValueType &value)
Definition: keymap.hpp:79
keystring(const std::string &o)
Definition: keymap.hpp:56
keymap()
Definition: keymap.hpp:71
keystring(const keystring &o)
Definition: keymap.hpp:58
boost::enable_if_c< types::traits::is_back_insertion_sequence< KeyList >::value,KeyList >::type getkeys() const
Definition: keymap.hpp:118
keystring()
Definition: keymap.hpp:60
Enable-if template for deciding wheter elements can be added to the class T with 'push_back' as for e...
Definition: traits.hpp:45
keystring(const char *o)
Definition: keymap.hpp:54