diff options
author | Peter Powell <petpow@saberuk.com> | 2013-04-01 05:25:03 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-04-01 05:57:33 +0100 |
commit | fd655fa93a00a5f2993adb7ef562b6dbab8aa87c (patch) | |
tree | 31157094a88c713ffa3bdf549b936e13ae22712c /include | |
parent | 1cb05553e286227e6bbd463d0b4b8cae40ff3940 (diff) |
Purge the deprecated hash_map from existance.
Diffstat (limited to 'include')
-rw-r--r-- | include/bancache.h | 2 | ||||
-rw-r--r-- | include/dns.h | 2 | ||||
-rw-r--r-- | include/hash_map.h | 59 | ||||
-rw-r--r-- | include/hashcomp.h | 81 | ||||
-rw-r--r-- | include/inspircd.h | 6 | ||||
-rw-r--r-- | include/typedefs.h | 11 |
6 files changed, 27 insertions, 134 deletions
diff --git a/include/bancache.h b/include/bancache.h index a7aac7f17..a99e97856 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -65,7 +65,7 @@ class CoreExport BanCacheHit /* A container of ban cache items. * must be defined after class BanCacheHit. */ -typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash<std::string> > BanCacheHash; +typedef std::tr1::unordered_map<std::string, BanCacheHit*, std::tr1::hash<std::string> > BanCacheHash; /** A manager for ban cache, which allocates and deallocates and checks cached bans. */ diff --git a/include/dns.h b/include/dns.h index 27c3c8848..3c8e55d08 100644 --- a/include/dns.h +++ b/include/dns.h @@ -102,7 +102,7 @@ class CoreExport CachedQuery /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. */ -typedef nspace::hash_map<irc::string, CachedQuery, irc::hash> dnscache; +typedef std::tr1::unordered_map<irc::string, CachedQuery, irc::hash> dnscache; /** * Error types that class Resolver can emit to its error method. diff --git a/include/hash_map.h b/include/hash_map.h deleted file mode 100644 index 1b43f0118..000000000 --- a/include/hash_map.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * Copyright (C) 2009 Robin Burchell <robin+git@viroteck.net> - * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc> - * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org> - * Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com> - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#ifndef INSPIRCD_HASHMAP_H -#define INSPIRCD_HASHMAP_H - - /** Where hash_map is varies from compiler to compiler - * as it is not standard unless we have tr1. - * - * TODO: in 2.2 if we drop support for libstdc++ older than 3.4.7 and GCC older - * than 4.1 this can be cleaned up massively. - */ - #ifndef _WIN32 - #if __GLIBCXX__ > 20060309 - // GCC4+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. FOR FUCKS SAKE. - #include <tr1/unordered_map> - #define HAS_TR1_UNORDERED - #define HASHMAP_DEPRECATED - #else - #include <ext/hash_map> - /** Oddball linux namespace for hash_map */ - #define nspace __gnu_cxx - #define BEGIN_HASHMAP_NAMESPACE namespace nspace { - #define END_HASHMAP_NAMESPACE } - #endif - #else - #include <unordered_map> - #define HAS_TR1_UNORDERED - #define HASHMAP_DEPRECATED - #endif - - // tr1: restoring sanity to our headers. now if only compiler vendors could agree on a FUCKING INCLUDE FILE. - #ifdef HAS_TR1_UNORDERED - #define hash_map unordered_map - #define nspace std::tr1 - #define BEGIN_HASHMAP_NAMESPACE namespace std { namespace tr1 { - #define END_HASHMAP_NAMESPACE } } - #endif - -#endif diff --git a/include/hashcomp.h b/include/hashcomp.h index 78d7ee878..449b367b9 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -31,7 +31,7 @@ #include <deque> #include <map> #include <set> -#include "hash_map.h" +#include "inspircd.h" /******************************************************* * This file contains classes and templates that deal @@ -591,71 +591,22 @@ inline std::string& trim(std::string &str) return str; } -/** Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of - * \#ifdefs we'll just do it all at once. Except, of course, with TR1, when it's the same as GCC. - */ -BEGIN_HASHMAP_NAMESPACE - - /** Hashing function to hash irc::string - */ -#if defined(_WIN32) && !defined(HAS_TR1_UNORDERED) - template<> class CoreExport hash_compare<irc::string, std::less<irc::string> > - { - public: - enum { bucket_size = 4, min_buckets = 8 }; /* Got these numbers from the CRT source, if anyone wants to change them feel free. */ - - /** Compare two irc::string values for hashing in hash_map - */ - bool operator()(const irc::string & s1, const irc::string & s2) const - { - if(s1.length() != s2.length()) return true; - return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), (size_t)s1.length()) < 0); - } - - /** Hash an irc::string value for hash_map - */ - size_t operator()(const irc::string & s) const; - }; - - template<> class CoreExport hash_compare<std::string, std::less<std::string> > +namespace std +{ + namespace tr1 { - public: - enum { bucket_size = 4, min_buckets = 8 }; /* Again, from the CRT source */ - - /** Compare two std::string values for hashing in hash_map - */ - bool operator()(const std::string & s1, const std::string & s2) const + + struct insensitive { - if(s1.length() != s2.length()) return true; - return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), (size_t)s1.length()) < 0); - } - - /** Hash a std::string using RFC1459 case sensitivity rules - * @param s A string to hash - * @return The hash value - */ - size_t operator()(const std::string & s) const; - }; -#else - - /* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */ - -#ifdef HASHMAP_DEPRECATED - struct insensitive -#else - CoreExport template<> struct hash<std::string> -#endif - { - size_t CoreExport operator()(const std::string &s) const; - }; - -#endif - - /** Convert a string to lower case respecting RFC1459 - * @param n A string to lowercase - */ - void strlower(char *n); - -END_HASHMAP_NAMESPACE + size_t CoreExport operator()(const std::string &s) const; + }; + + /** Convert a string to lower case respecting RFC1459 + * @param n A string to lowercase + */ + void strlower(char *n); + + } +} #endif diff --git a/include/inspircd.h b/include/inspircd.h index 86853a94f..9456ce329 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -58,6 +58,11 @@ #include <unistd.h> #endif +#ifdef _WIN32 +# include <unordered_map> +#else +# include <tr1/unordered_map> +#endif #include <sstream> #include <string> #include <vector> @@ -896,3 +901,4 @@ class CommandModule : public Module }; #endif + diff --git a/include/typedefs.h b/include/typedefs.h index 06f704120..e73790667 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -56,13 +56,8 @@ struct ResourceRecord; #include "hashcomp.h" #include "base.h" -#ifdef HASHMAP_DEPRECATED - typedef nspace::hash_map<std::string, User*, nspace::insensitive, irc::StrHashComp> user_hash; - typedef nspace::hash_map<std::string, Channel*, nspace::insensitive, irc::StrHashComp> chan_hash; -#else - typedef nspace::hash_map<std::string, User*, nspace::hash<std::string>, irc::StrHashComp> user_hash; - typedef nspace::hash_map<std::string, Channel*, nspace::hash<std::string>, irc::StrHashComp> chan_hash; -#endif +typedef std::tr1::unordered_map<std::string, User*, std::tr1::insensitive, irc::StrHashComp> user_hash; +typedef std::tr1::unordered_map<std::string, Channel*, std::tr1::insensitive, irc::StrHashComp> chan_hash; /** A list holding local users, this is the type of UserManager::local_users */ @@ -120,7 +115,7 @@ typedef std::map<std::string, file_cache> ConfigFileCache; /** A hash of commands used by the core */ -typedef nspace::hash_map<std::string,Command*> Commandtable; +typedef std::tr1::unordered_map<std::string,Command*> Commandtable; /** Membership list of a channel */ typedef std::map<User*, Membership*> UserMembList; |