diff options
author | Adam <Adam@drink-coca-cola.info> | 2010-05-14 20:35:38 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-06-18 21:01:53 -0400 |
commit | f049124905bd9f53439293e873003cb027a17b91 (patch) | |
tree | 352ed9251fd47055dd770aa2d5eabb20247e4b43 /include/hashcomp.h | |
parent | 81a45520a773732c9f46785f27aa1956150775d7 (diff) |
Rewrote the hashing system to use std::tr1::unordered_map
Diffstat (limited to 'include/hashcomp.h')
-rw-r--r-- | include/hashcomp.h | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index becebb48e..a0d456b40 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -15,6 +15,23 @@ #include <string> +#ifndef _WIN32 + #ifdef HASHMAP_DEPRECATED /* If gcc ver > 4.3 */ + /* GCC4.3+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. */ + #include <tr1/unordered_map> + #define unordered_map_namespace std::tr1 + #else + #include <ext/hash_map> + /* Oddball linux namespace for hash_map */ + #define unordered_map_namespace __gnu_cxx + #define unordered_map hash_map + #endif +#else + /* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */ + #include <unordered_map> + #define unordered_map_namespace std::tr1 +#endif + /******************************************************* * This file contains classes and templates that deal * with the comparison and hashing of 'irc strings'. @@ -30,9 +47,6 @@ * aware of irc::string. *******************************************************/ -#ifndef LOWERMAP -#define LOWERMAP - /** A mapping of uppercase to lowercase, including scandinavian * 'oddities' as specified by RFC1459, e.g. { -> [, and | -> \ */ @@ -72,8 +86,6 @@ unsigned const char ascii_case_insensitive_map[256] = { 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 /* 240-255 */ }; -#endif - /** The irc namespace contains a number of helper classes. */ namespace irc @@ -470,4 +482,40 @@ class spacesepstream : public sepstream spacesepstream(const char *source) : sepstream(source, ' ') { } }; +/** Class used to hash a std::string, given as the third argument to the unordered_map template + */ +class CoreExport hash_compare_std_string +{ + public: + /** Return a hash value for a string + * @param s The string + * @return The hash value + */ + size_t operator()(const std::string &s) const; +}; + +/** Class used to hash a ci::string, given as the third argument to the unordered_map template + */ +class CoreExport hash_compare_ci_string +{ + public: + /** Return a hash value for a string using case insensitivity + * @param s The string + * @return The hash value + */ + size_t operator()(const ci::string &s) const; +}; + +/** Class used to hash a irc::string, given as the third argument to the unordered_map template + */ +class CoreExport hash_compare_irc_string +{ + public: + /** Return a hash value for a string using RFC1459 case sensitivity rules + * @param s The stirng + * @return The hash value + */ + size_t operator()(const irc::string &s) const; +}; + #endif |