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) 20 #include <unordered_map> 21 #elif defined(PION_HAVE_TR1_UNORDERED_MAP) 22 #include <tr1/unordered_map> 23 #elif defined(PION_HAVE_EXT_HASH_MAP) 24 #include <ext/hash_map> 25 #elif defined(PION_HAVE_HASH_MAP) 32 #if defined(PION_HAVE_UNORDERED_MAP) 33 #define PION_HASH_MAP std::unordered_map 34 #define PION_HASH_MULTIMAP std::unordered_multimap 35 #define PION_HASH_STRING boost::hash<std::string> 36 #define PION_HASH(TYPE) boost::hash<TYPE> 37 #elif defined(PION_HAVE_TR1_UNORDERED_MAP) 38 #define PION_HASH_MAP std::tr1::unordered_map 39 #define PION_HASH_MULTIMAP std::tr1::unordered_multimap 40 #define PION_HASH_STRING boost::hash<std::string> 41 #define PION_HASH(TYPE) boost::hash<TYPE> 42 #elif defined(PION_HAVE_EXT_HASH_MAP) 44 #define PION_HASH_MAP __gnu_cxx::hash_map 45 #define PION_HASH_MULTIMAP __gnu_cxx::hash_multimap 47 #define PION_HASH_MAP hash_map 48 #define PION_HASH_MULTIMAP hash_multimap 50 #define PION_HASH_STRING boost::hash<std::string> 51 #define PION_HASH(TYPE) boost::hash<TYPE> 52 #elif defined(PION_HAVE_HASH_MAP) 54 #define PION_HASH_MAP stdext::hash_map 55 #define PION_HASH_MULTIMAP stdext::hash_multimap 56 #define PION_HASH_STRING stdext::hash_compare<std::string, std::less<std::string> > 57 #define PION_HASH(TYPE) stdext::hash_compare<TYPE, std::less<TYPE> > 59 #define PION_HASH_MAP hash_map 60 #define PION_HASH_MULTIMAP hash_multimap 61 #define PION_HASH_STRING boost::hash<std::string> 62 #define PION_HASH(TYPE) boost::hash<TYPE> 70 : std::binary_function<std::string, std::string, bool>
72 bool operator()(std::string
const& x,
73 std::string
const& y)
const 75 return boost::algorithm::iequals(x, y, std::locale());
83 : std::unary_function<std::string, std::size_t>
85 std::size_t operator()(std::string
const& x)
const 90 for(std::string::const_iterator it = x.begin();
93 boost::hash_combine(seed, std::toupper(*it, locale));
100 #if defined(_MSC_VER) && !defined(PION_HAVE_UNORDERED_MAP) 101 template<
class _Ty>
struct is_iless :
public std::binary_function<_Ty, _Ty, bool>
105 is_iless(
const std::locale& Loc=std::locale() ) : m_Loc( Loc ) {}
108 bool operator()(
const _Ty& Arg1,
const _Ty& Arg2 )
const 110 return _Ty(boost::algorithm::to_upper_copy(Arg1, m_Loc)) < _Ty(boost::algorithm::to_upper_copy(Arg2, m_Loc));
118 struct ihash_windows :
public stdext::hash_compare<std::string, is_iless<std::string> > {
120 using stdext::hash_compare<std::string, is_iless<std::string> >::operator();
122 inline size_t operator()(
const std::string& str)
const {
128 typedef PION_HASH_MULTIMAP<std::string, std::string, ihash_windows > ihash_multimap;
130 typedef PION_HASH_MULTIMAP<std::string, std::string, ihash, iequal_to > ihash_multimap;