]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/hashcomp.h
Add irc::dynamicbitmask class. Feel free to take a look and offer suggestions, as...
[user/henk/code/inspircd.git] / include / hashcomp.h
index 013523df3374293a489782b69dce67a169f0dd32..4a5dd72ad63d6ad9c2abbd5c9eda04f47fbc6c17 100644 (file)
@@ -333,10 +333,22 @@ namespace irc
                /** Ending port in a range of ports
                 */
                long range_end;
+               /** Allow overlapped port ranges
+                */
+               bool overlapped;
+               /** Used to determine overlapping of ports
+                * without O(n) algorithm being used
+                */
+               std::map<long, bool> overlap_set;
+               /** Returns true if val overlaps an existing range
+                */
+               bool Overlaps(long val);
         public:
                /** Create a portparser and fill it with the provided data
+                * @param source The source text to parse from
+                * @param allow_overlapped Allow overlapped ranges
                 */
-               portparser(const std::string &source);
+               portparser(const std::string &source, bool allow_overlapped = true);
                /** Frees the internal commasepstream object
                 */
                ~portparser();
@@ -346,6 +358,26 @@ namespace irc
                long GetToken();
        };
 
+       typedef std::pair<size_t, unsigned char> bitfield;
+
+       class dynamicbitmask : public classbase
+       {
+        private:
+               unsigned char* bits;
+               unsigned char* freebits;
+               size_t bits_size;
+        public:
+               dynamicbitmask();
+
+               ~dynamicbitmask();
+
+               bitfield Allocate();
+
+               bool Deallocate(bitfield &pos);
+
+               void Toggle(bitfield &pos, bool state);
+       };
+
        /** 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.