diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bancache.h | 6 | ||||
-rw-r--r-- | include/dns.h | 6 | ||||
-rw-r--r-- | include/hash_map.h | 56 | ||||
-rw-r--r-- | include/hashcomp.h | 10 | ||||
-rw-r--r-- | include/typedefs.h | 10 |
5 files changed, 48 insertions, 40 deletions
diff --git a/include/bancache.h b/include/bancache.h index 9266149fc..5bfa2fa3f 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -62,10 +62,10 @@ class CoreExport BanCacheHit : public classbase /* A container of ban cache items. * must be defined after class BanCacheHit. */ -#ifndef WIN32 -typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash<std::string> > BanCacheHash; -#else +#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash_compare<std::string, std::less<std::string> > > BanCacheHash; +#else +typedef nspace::hash_map<std::string, BanCacheHit*, nspace::hash<std::string> > BanCacheHash; #endif /** A manager for ban cache, which allocates and deallocates and checks cached bans. diff --git a/include/dns.h b/include/dns.h index 4f577366b..fa4295296 100644 --- a/include/dns.h +++ b/include/dns.h @@ -103,10 +103,10 @@ class CoreExport CachedQuery : public classbase /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. */ -#ifndef WIN32 -typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache; -#else +#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash_compare<irc::string> > dnscache; +#else +typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache; #endif /** diff --git a/include/hash_map.h b/include/hash_map.h index dad08aa93..6e47d292b 100644 --- a/include/hash_map.h +++ b/include/hash_map.h @@ -11,35 +11,45 @@ * --------------------------------------------------- */ -#ifndef INSPIRCD_HASHMAP_H -#define INSPIRCD_HASHMAP_H + #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. - */ -#ifndef WIN32 - #ifndef HASHMAP_DEPRECATED - #include <ext/hash_map> - /** Oddball linux namespace for hash_map */ - #define nspace __gnu_cxx - #define BEGIN_HASHMAP_NAMESPACE namespace nspace { - #define END_HASHMAP_NAMESPACE } + /** Where hash_map is varies from compiler to compiler + * as it is not standard unless we have tr1. + */ + #ifndef WIN32 + #ifdef HASHMAP_DEPRECATED + // 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 + #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 - /** Yay, we have tr1! */ - #include <tr1/unordered_map> - /** Not so oddball linux namespace for hash_map with gcc 4.0 and above */ + #if _MSC_VER >= 1600 + // New MSVC has tr1. Just to make things fucked up, though, MSVC and GCC use different includes! FFS. + #include <unordered_map> + #define HAS_TR1_UNORDERED + #define HASHMAP_DEPRECATED + #else + #define nspace stdext + /** Oddball windows namespace for hash_map */ + using stdext::hash_map; + #define BEGIN_HASHMAP_NAMESPACE namespace nspace { + #define END_HASHMAP_NAMESPACE } + #endif + #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 -#else - #include <hash_map> - #define nspace stdext - /** Oddball windows namespace for hash_map */ - using stdext::hash_map; - #define BEGIN_HASHMAP_NAMESPACE namespace nspace { - #define END_HASHMAP_NAMESPACE } -#endif #endif diff --git a/include/hashcomp.h b/include/hashcomp.h index 94c836c6f..536c42937 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -627,13 +627,13 @@ inline std::string& trim(std::string &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 + * #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 */ -#ifdef WINDOWS +#if defined(WINDOWS) && !defined(HAS_TR1_UNORDERED) template<> class CoreExport hash_compare<irc::string, std::less<irc::string> > { public: @@ -679,7 +679,7 @@ BEGIN_HASHMAP_NAMESPACE * @param s A string to hash * @return The hash value */ - size_t operator()(const irc::string &s) const; + size_t CoreExport operator()(const irc::string &s) const; }; /* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */ @@ -687,10 +687,10 @@ BEGIN_HASHMAP_NAMESPACE #ifdef HASHMAP_DEPRECATED struct insensitive #else - template<> struct hash<std::string> + CoreExport template<> struct hash<std::string> #endif { - size_t operator()(const std::string &s) const; + size_t CoreExport operator()(const std::string &s) const; }; #endif diff --git a/include/typedefs.h b/include/typedefs.h index ca3efcc70..a40e6cfc2 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -14,8 +14,10 @@ #ifndef __TYPEDEF_H__ #define __TYPEDEF_H__ -#ifndef WIN32 - +#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) + typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash; + typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash; +#else #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; @@ -23,10 +25,6 @@ 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 -#else - - typedef nspace::hash_map<std::string, User*, nspace::hash_compare<std::string, std::less<std::string> > > user_hash; - typedef nspace::hash_map<std::string, Channel*, nspace::hash_compare<std::string, std::less<std::string> > > chan_hash; #endif /** Server name cache |