]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/hashcomp.h
More efficient modestacker
[user/henk/code/inspircd.git] / include / hashcomp.h
index 0a39deb1f7243359bc30553623a7901f26d149ea..1f659209318d42fef5e0a3b9fee086d836b4c10c 100644 (file)
@@ -123,6 +123,17 @@ namespace irc
                bool operator()(const insp_inaddr &s1, const insp_inaddr &s2) const;
        };
 
+       class modestacker
+       {
+        private:
+               std::deque<std::string> sequence;
+               bool adding;
+        public:
+               modestacker(bool add);
+               void Push(char modeletter, const std::string &parameter);
+               int GetStackedLine(std::deque<std::string> &result);
+       };
+
        /** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812.
         * It will split the string into 'tokens' each containing one parameter
         * from the string.
@@ -161,22 +172,39 @@ namespace irc
         * the next token, until none remain, at which point the method returns
         * an empty string.
         */
-       class commasepstream
+       class sepstream : public classbase
        {
         private:
                std::string tokens;
                std::string::iterator last_starting_position;
                std::string::iterator n;
+               char sep;
         public:
                /** Create a commasepstream and fill it with the provided data
                 */
-               commasepstream(const std::string &source);
-               ~commasepstream();
+               sepstream(const std::string &source, char seperator);
+               virtual ~sepstream();
 
                /** Fetch the next token from the stream
                 * @returns The next token is returned, or an empty string if none remain
                 */
-               const std::string GetToken();
+               virtual const std::string GetToken();
+       };
+
+       class commasepstream : public sepstream
+       {
+        public:
+               commasepstream(const std::string &source) : sepstream(source, ',')
+               {
+               }
+       };
+
+       class spacesepstream : public sepstream
+       {
+        public:
+               spacesepstream(const std::string &source) : sepstream(source, ' ')
+               {
+               }
        };