From f049124905bd9f53439293e873003cb027a17b91 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 14 May 2010 20:35:38 -0400 Subject: Rewrote the hashing system to use std::tr1::unordered_map --- include/hashcomp.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) (limited to 'include/hashcomp.h') 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 +#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 + #define unordered_map_namespace std::tr1 + #else + #include + /* 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 + #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 -- cgit From e6447fa2c40270d2e2435229127dd970194b47d9 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 3 Jun 2010 23:09:22 -0400 Subject: Added in a subcommand system and switched ns_set and ns_saset to use it --- include/hashcomp.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/hashcomp.h') diff --git a/include/hashcomp.h b/include/hashcomp.h index a0d456b40..6d4530dc6 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -16,7 +16,8 @@ #include #ifndef _WIN32 - #ifdef HASHMAP_DEPRECATED /* If gcc ver > 4.3 */ +// #ifdef HASHMAP_DEPRECATED /* If gcc ver > 4.3 */ + #if 1 /* GCC4.3+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. */ #include #define unordered_map_namespace std::tr1 -- cgit