1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
20 #include "inspircd_config.h"
23 #include <ext/hash_map>
29 #define nspace __gnu_cxx
39 template<> struct hash<in_addr>
41 template<> struct nspace::hash<in_addr>
44 size_t operator()(const struct in_addr &a) const;
47 template<> struct hash<string>
49 template<> struct nspace::hash<string>
52 size_t operator()(const string &s) const;
56 /** This class returns true if two strings match.
57 * Case sensitivity is ignored, and the RFC 'character set'
62 /** The operator () does the actual comparison in hash_map
64 bool operator()(const string& s1, const string& s2) const;
67 /** This class returns true if two in_addr structs match.
68 * Checking is done by copying both into a size_t then doing a
69 * numeric comparison of the two.
71 struct InAddr_HashComp
73 /** The operator () does the actual comparison in hash_map
75 bool operator()(const in_addr &s1, const in_addr &s2) const;
78 /** The irc namespace contains a number of helper classes.
82 /** The irc_char_traits class is used for RFC-style comparison of strings.
83 * This class is used to implement irc::string, a case-insensitive, RFC-
84 * comparing string class.
86 struct irc_char_traits : std::char_traits<char> {
88 /** Check if two chars match
90 static bool eq(char c1st, char c2nd);
92 /** Check if two chars do NOT match
94 static bool ne(char c1st, char c2nd);
96 /** Check if one char is less than another
98 static bool lt(char c1st, char c2nd);
100 /** Compare two strings of size n
102 static int compare(const char* str1, const char* str2, size_t n);
104 /** Find a char within a string up to position n
106 static const char* find(const char* s1, int n, char c);
109 /** This typedef declares irc::string based upon irc_char_traits
111 typedef basic_string<char, irc_char_traits, allocator<char> > string;