10 #ifndef __PION_HASH_MAP_HEADER__
11 #define __PION_HASH_MAP_HEADER__
15 #include <boost/algorithm/string.hpp>
16 #include <boost/functional/hash.hpp>
17 #include <pion/config.hpp>
19 #if defined(PION_HAVE_UNORDERED_MAP) && defined(PION_CMAKE_BUILD)
21 #include <unordered_map>
22 #elif defined(PION_HAVE_UNORDERED_MAP)
23 #include <tr1/unordered_map>
24 #elif defined(PION_HAVE_EXT_HASH_MAP)
25 #include <ext/hash_map>
26 #elif defined(PION_HAVE_HASH_MAP)
33 #if defined(PION_HAVE_UNORDERED_MAP) && defined(PION_CMAKE_BUILD)
34 #define PION_HASH_MAP std::unordered_map
35 #define PION_HASH_MULTIMAP std::unordered_multimap
36 #define PION_HASH_STRING boost::hash<std::string>
37 #define PION_HASH(TYPE) boost::hash<TYPE>
38 #elif defined(PION_HAVE_UNORDERED_MAP)
39 #define PION_HASH_MAP std::tr1::unordered_map
40 #define PION_HASH_MULTIMAP std::tr1::unordered_multimap
41 #define PION_HASH_STRING boost::hash<std::string>
42 #define PION_HASH(TYPE) boost::hash<TYPE>
43 #elif defined(PION_HAVE_EXT_HASH_MAP)
45 #define PION_HASH_MAP __gnu_cxx::hash_map
46 #define PION_HASH_MULTIMAP __gnu_cxx::hash_multimap
48 #define PION_HASH_MAP hash_map
49 #define PION_HASH_MULTIMAP hash_multimap
51 #define PION_HASH_STRING boost::hash<std::string>
52 #define PION_HASH(TYPE) boost::hash<TYPE>
53 #elif defined(PION_HAVE_HASH_MAP)
55 #define PION_HASH_MAP stdext::hash_map
56 #define PION_HASH_MULTIMAP stdext::hash_multimap
57 #define PION_HASH_STRING stdext::hash_compare<std::string, std::less<std::string> >
58 #define PION_HASH(TYPE) stdext::hash_compare<TYPE, std::less<TYPE> >
60 #define PION_HASH_MAP hash_map
61 #define PION_HASH_MULTIMAP hash_multimap
62 #define PION_HASH_STRING boost::hash<std::string>
63 #define PION_HASH(TYPE) boost::hash<TYPE>
71 : std::binary_function<std::string, std::string, bool>
73 bool operator()(std::string
const& x,
74 std::string
const& y)
const
76 return boost::algorithm::iequals(x, y, std::locale());
84 : std::unary_function<std::string, std::size_t>
86 std::size_t operator()(std::string
const& x)
const
91 for(std::string::const_iterator it = x.begin();
94 boost::hash_combine(seed, std::toupper(*it, locale));
102 template<
class _Ty>
struct is_iless :
public std::binary_function<_Ty, _Ty, bool>
106 is_iless(
const std::locale& Loc=std::locale() ) : m_Loc( Loc ) {}
109 bool operator()(
const _Ty& Arg1,
const _Ty& Arg2 )
const
111 return _Ty(boost::algorithm::to_upper_copy(Arg1, m_Loc)) < _Ty(boost::algorithm::to_upper_copy(Arg2, m_Loc));
119 struct ihash_windows :
public stdext::hash_compare<std::string, is_iless<std::string> > {
121 using stdext::hash_compare<std::string, is_iless<std::string> >::operator();
123 inline size_t operator()(
const std::string& str)
const {
129 typedef PION_HASH_MULTIMAP<std::string, std::string, ihash_windows > ihash_multimap;
131 typedef PION_HASH_MULTIMAP<std::string, std::string, ihash, iequal_to > ihash_multimap;