]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/hashcomp.h
Tidy up source files:
[user/henk/code/inspircd.git] / include / hashcomp.h
index 07ec49a665bf34e8827b5889035078e62d0a4bd9..e4b3cfe79e1de86279bfd866b6b98480535746b1 100644 (file)
@@ -1,18 +1,28 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2011 Adam <Adam@anope.org>
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2005-2009 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
  *
- * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef _HASHCOMP_H_
-#define _HASHCOMP_H_
+
+#pragma once
 
 #include <cstring>
 #include <string>
@@ -20,7 +30,7 @@
 #include <deque>
 #include <map>
 #include <set>
-#include "hash_map.h"
+#include "inspircd.h"
 
 /*******************************************************
  * This file contains classes and templates that deal
@@ -146,7 +156,7 @@ namespace irc
 
        /** Compose a hex string from raw data.
         * @param raw The raw data to compose hex from
-        * @pram rawsz The size of the raw data buffer
+        * @param rawsz The size of the raw data buffer
         * @return The hex string.
         */
        CoreExport std::string hex(const unsigned char *raw, size_t rawsz);
@@ -269,15 +279,7 @@ namespace irc
                 * mode changes to be obtained.
                 */
                int GetStackedLine(std::vector<std::string> &result, int max_line_size = 360);
-
-               /** deprecated compatability interface - TODO remove */
-               int GetStackedLine(std::deque<std::string> &result, int max_line_size = 360) {
-                       std::vector<std::string> 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.
@@ -430,7 +432,7 @@ namespace irc
 
                /** Used to split on commas
                 */
-               commasepstream* sep;
+               commasepstream sep;
 
                /** Current position in a range of ports
                 */
@@ -451,7 +453,7 @@ namespace irc
                /** Used to determine overlapping of ports
                 * without O(n) algorithm being used
                 */
-               std::map<long, bool> overlap_set;
+               std::set<long> overlap_set;
 
                /** Returns true if val overlaps an existing range
                 */
@@ -464,10 +466,6 @@ 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
                 */
@@ -584,71 +582,20 @@ 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<irc::string, std::less<irc::string> >
-       {
-       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<std::string, std::less<std::string> >
+namespace std
+{
+       namespace tr1
        {
-       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
+               
+               struct insensitive
                {
-                       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<std::string>
-#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
+                       size_t CoreExport operator()(const std::string &s) const;
+               };
+               
+        /** Convert a string to lower case respecting RFC1459
+        * @param n A string to lowercase
+        */
+        void strlower(char *n);
+               
+       }
+}