10 #ifndef __PION_PIONHASHMAP_HEADER__
11 #define __PION_PIONHASHMAP_HEADER__
15 #include <boost/functional/hash.hpp>
16 #include <pion/PionConfig.hpp>
18 #if defined(PION_HAVE_UNORDERED_MAP)
19 #include <tr1/unordered_map>
20 #elif defined(PION_HAVE_EXT_HASH_MAP)
21 #include <ext/hash_map>
22 #elif defined(PION_HAVE_HASH_MAP)
30 #if defined(PION_HAVE_UNORDERED_MAP)
31 #define PION_HASH_MAP std::tr1::unordered_map
32 #define PION_HASH_MULTIMAP std::tr1::unordered_multimap
33 #define PION_HASH_STRING boost::hash<std::string>
34 #define PION_HASH(TYPE) boost::hash<TYPE>
35 #elif defined(PION_HAVE_EXT_HASH_MAP)
37 #define PION_HASH_MAP __gnu_cxx::hash_map
38 #define PION_HASH_MULTIMAP __gnu_cxx::hash_multimap
40 #define PION_HASH_MAP hash_map
41 #define PION_HASH_MULTIMAP hash_multimap
43 #define PION_HASH_STRING boost::hash<std::string>
44 #define PION_HASH(TYPE) boost::hash<TYPE>
45 #elif defined(PION_HAVE_HASH_MAP)
47 #define PION_HASH_MAP stdext::hash_map
48 #define PION_HASH_MULTIMAP stdext::hash_multimap
49 #define PION_HASH_STRING stdext::hash_compare<std::string, std::less<std::string> >
50 #define PION_HASH(TYPE) stdext::hash_compare<TYPE, std::less<TYPE> >
52 #define PION_HASH_MAP hash_map
53 #define PION_HASH_MULTIMAP hash_multimap
54 #define PION_HASH_STRING boost::hash<std::string>
55 #define PION_HASH(TYPE) boost::hash<TYPE>
62 inline bool operator()(
const std::string& str1,
const std::string& str2)
const {
63 if (str1.size() != str2.size())
65 std::string::const_iterator it1 = str1.begin();
66 std::string::const_iterator it2 = str2.begin();
67 while ( (it1!=str1.end()) && (it2!=str2.end()) ) {
68 if (tolower(*it1) != tolower(*it2))
80 inline unsigned long operator()(
const std::string& str)
const {
81 unsigned long value = 0;
82 for (std::string::const_iterator i = str.begin(); i!= str.end(); ++i)
83 value = static_cast<unsigned char>(tolower(*i)) + (value << 6) + (value << 16) - value;
91 inline bool operator()(
const std::string& str1,
const std::string& str2)
const {
92 std::string::const_iterator it1 = str1.begin();
93 std::string::const_iterator it2 = str2.begin();
94 while ( (it1 != str1.end()) && (it2 != str2.end()) ) {
95 if (tolower(*it1) != tolower(*it2))
96 return (tolower(*it1) < tolower(*it2));
100 return (str1.size() < str2.size());
107 struct CaseInsensitiveHashCompare :
public stdext::hash_compare<std::string, CaseInsensitiveLess> {
109 using stdext::hash_compare<std::string, CaseInsensitiveLess>::operator();
111 inline size_t operator()(
const std::string& str)
const {
120 typedef PION_HASH_MULTIMAP<std::string, std::string, CaseInsensitiveHashCompare>
StringDictionary;
122 typedef PION_HASH_MULTIMAP<std::string, std::string, CaseInsensitiveHash, CaseInsensitiveEqual >
StringDictionary;