X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fhashcomp.h;h=c1e8a0ec51215cb5f1822472aa662d2b541f74d2;hb=a2e9e2837da14f7408b794750f86cca0d4cfd884;hp=0340cb6349adcde95a0ab7dae5e320ceb8115af7;hpb=808a0a09577009c2d6e494979c2189426b332aef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/hashcomp.h b/include/hashcomp.h index 0340cb634..c1e8a0ec5 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -22,8 +22,7 @@ */ -#ifndef HASHCOMP_H -#define HASHCOMP_H +#pragma once #include #include @@ -31,7 +30,7 @@ #include #include #include -#include "hash_map.h" +#include "inspircd.h" /******************************************************* * This file contains classes and templates that deal @@ -110,6 +109,11 @@ namespace irc bool operator()(const std::string& s1, const std::string& s2) const; }; + struct insensitive + { + size_t CoreExport operator()(const std::string &s) const; + }; + /** The irc_char_traits class is used for RFC-style comparison of strings. * This class is used to implement irc::string, a case-insensitive, RFC- * comparing string class. @@ -281,14 +285,6 @@ namespace irc */ int GetStackedLine(std::vector &result, int max_line_size = 360); - /** deprecated compatability interface - TODO remove */ - int GetStackedLine(std::deque &result, int max_line_size = 360) { - std::vector r; - int n = GetStackedLine(r, max_line_size); - result.clear(); - result.insert(result.end(), r.begin(), r.end()); - return n; - } }; /** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812. @@ -441,7 +437,7 @@ namespace irc /** Used to split on commas */ - commasepstream* sep; + commasepstream sep; /** Current position in a range of ports */ @@ -462,7 +458,7 @@ namespace irc /** Used to determine overlapping of ports * without O(n) algorithm being used */ - std::map overlap_set; + std::set overlap_set; /** Returns true if val overlaps an existing range */ @@ -475,22 +471,12 @@ namespace irc */ portparser(const std::string &source, bool allow_overlapped = true); - /** Frees the internal commasepstream object - */ - ~portparser(); - /** Fetch the next token from the stream * @return The next port number is returned, or 0 if none remain */ long GetToken(); }; - /** Turn _ characters in a string into spaces - * @param n String to translate - * @return The new value with _ translated to space. - */ - CoreExport const char* Spacify(const char* n); - struct hash { /** Hash an irc::string using RFC1459 case sensitivity rules @@ -594,72 +580,3 @@ 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(WINDOWS) && !defined(HAS_TR1_UNORDERED) - template<> class CoreExport hash_compare > - { - 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 > - { - 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 - { - 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 -#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 - -#endif