Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

hashcomp.h

Go to the documentation of this file.
00001 /*       +------------------------------------+
00002  *       | Inspire Internet Relay Chat Daemon |
00003  *       +------------------------------------+
00004  *
00005  *  Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
00006  *                       E-mail:
00007  *                <brain@chatspike.net>
00008  *                <Craig@chatspike.net>
00009  *
00010  * Written by Craig Edwards, Craig McLure, and others.
00011  * This program is free but copyrighted software; see
00012  *            the file COPYING for details.
00013  *
00014  * ---------------------------------------------------
00015  */
00016 
00017 #ifndef _HASHCOMP_H_
00018 #define _HASHCOMP_H_
00019 
00020 #include "inspircd_config.h"
00021 
00022 /*******************************************************
00023  * This file contains classes and templates that deal
00024  * with the comparison and hashing of 'irc strings'.
00025  * An 'irc string' is a string which compares in a
00026  * case insensitive manner, and as per RFC 1459 will
00027  * treat [ identical to {, ] identical to }, and \
00028  * as identical to |.
00029  *
00030  * Our hashing functions are designed  to accept
00031  * std::string and compare/hash them as type irc::string
00032  * by converting them internally. This makes them
00033  * backwards compatible with other code which is not
00034  * aware of irc::string.
00035  *******************************************************/
00036 
00037 #ifdef GCC3
00038 #include <ext/hash_map>
00039 #else
00040 #include <hash_map>
00041 #endif
00042 
00043 #ifdef GCC3
00044 #define nspace __gnu_cxx
00045 #else
00046 #define nspace std
00047 #endif
00048 
00049 using namespace std;
00050 
00051 namespace nspace
00052 {
00053 #ifdef GCC34
00054         template<> struct hash<in_addr>
00055 #else
00056         template<> struct nspace::hash<in_addr>
00057 #endif
00058         {
00059                 size_t operator()(const struct in_addr &a) const;
00060         };
00061 #ifdef GCC34
00062         template<> struct hash<string>
00063 #else
00064         template<> struct nspace::hash<string>
00065 #endif
00066         {
00067                 size_t operator()(const string &s) const;
00068         };
00069 }
00070 
00073 namespace irc
00074 {
00075 
00080         struct StrHashComp
00081         {
00084                 bool operator()(const std::string& s1, const std::string& s2) const;
00085         };
00086 
00087 
00092         struct InAddr_HashComp
00093         {
00096                 bool operator()(const in_addr &s1, const in_addr &s2) const;
00097         };
00098 
00099 
00104         struct irc_char_traits : std::char_traits<char> {
00105 
00108                 static bool eq(char c1st, char c2nd);
00109 
00112                 static bool ne(char c1st, char c2nd);
00113 
00116                 static bool lt(char c1st, char c2nd);
00117 
00120                 static int compare(const char* str1, const char* str2, size_t n);
00121 
00124                 static const char* find(const char* s1, int  n, char c);
00125         };
00126 
00129         typedef basic_string<char, irc_char_traits, allocator<char> > string;
00130 }
00131 
00132 #endif

Generated on Wed May 25 21:42:13 2005 for InspIRCd by doxygen 1.3.3