]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/hashcomp.h
Added irc::string
[user/henk/code/inspircd.git] / include / hashcomp.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #ifndef _HASHCOMP_H_
18 #define _HASHCOMP_H_
19
20 #include "inspircd_config.h"
21
22 #ifdef GCC3
23 #include <ext/hash_map>
24 #else
25 #include <hash_map>
26 #endif
27
28 #ifdef GCC3
29 #define nspace __gnu_cxx
30 #else
31 #define nspace std
32 #endif
33
34 using namespace std;
35
36 namespace nspace
37 {
38 #ifdef GCC34
39         template<> struct hash<in_addr>
40 #else
41         template<> struct nspace::hash<in_addr>
42 #endif
43         {
44                 size_t operator()(const struct in_addr &a) const;
45         };
46 #ifdef GCC34
47         template<> struct hash<string>
48 #else
49         template<> struct nspace::hash<string>
50 #endif
51         {
52                 size_t operator()(const string &s) const;
53         };
54 }
55
56 struct StrHashComp
57 {
58
59         bool operator()(const string& s1, const string& s2) const;
60 };
61
62 struct InAddr_HashComp
63 {
64         bool operator()(const in_addr &s1, const in_addr &s2) const;
65 };
66
67 namespace irc
68 {
69         struct irc_char_traits : std::char_traits<char> {
70                   static bool eq(char c1st, char c2nd);
71                   static bool ne(char c1st, char c2nd);
72                   static bool lt(char c1st, char c2nd);
73                   static int compare(const char* str1, const char* str2, size_t n);
74                   static const char* find(const char* s1, int  n, char c);
75         };
76
77         typedef basic_string<char, irc_char_traits, allocator<char> > string;
78 }
79
80 #endif