00001 #ifndef _stringhash_hh_ 00002 #define _stringhash_hh_ 00003 00004 #include <string.h> 00005 00006 #if __GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ >= 1)) 00007 #include <ext/hash_map> 00008 using namespace __gnu_cxx; 00009 #else 00010 #include <hash_map> 00011 #endif 00012 #include <string> 00013 00014 struct eqstr { 00015 bool operator()(const char *s1, const char *s2) { 00016 return strcmp(s1, s2) == 0; 00017 } 00018 }; 00019 00020 template<class storageT> 00021 class string_map: public hash_map<const char *, storageT, hash<const char*>, eqstr> {}; 00022 00023 #if __GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ >= 1)) 00024 namespace __gnu_cxx { 00025 00026 struct hash<std::string> { 00027 size_t operator()(std::string &__s) const { return __stl_hash_string(__s.c_str()); } 00028 }; 00029 00030 struct hash<const std::string> { 00031 size_t operator()(const std::string &__s) const { return __stl_hash_string(__s.c_str()); } 00032 }; 00033 00034 }; 00035 #else 00036 struct hash<std::string> { 00037 size_t operator()(std::string &__s) const { return __stl_hash_string(__s.c_str()); } 00038 }; 00039 00040 struct hash<const std::string> { 00041 size_t operator()(const std::string &__s) const { return __stl_hash_string(__s.c_str()); } 00042 }; 00043 #endif 00044 00045 #endif