From 87025fd5ac24bb758eec053e2f92382835e8ecd1 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 3 Sep 2014 15:40:19 +0200 Subject: [PATCH] Remove irc::modestacker --- include/hashcomp.h | 71 ---------------------------------------------- src/hashcomp.cpp | 65 ------------------------------------------ 2 files changed, 136 deletions(-) diff --git a/include/hashcomp.h b/include/hashcomp.h index 6cd3fc3c0..c99b5d646 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -174,77 +174,6 @@ namespace irc */ std::string CoreExport stringjoiner(const std::vector& sequence, char separator = ' '); - /** irc::modestacker stacks mode sequences into a list. - * It can then reproduce this list, clamped to a maximum of MAXMODES - * values per line. - */ - class CoreExport modestacker - { - private: - /** The mode sequence and its parameters - */ - std::deque sequence; - - /** True if the mode sequence is initially adding - * characters, false if it is initially removing - * them - */ - bool adding; - public: - - /** Construct a new modestacker. - * @param add True if the stack is adding modes, - * false if it is removing them - */ - modestacker(bool add); - - /** Push a modeletter and its parameter onto the stack. - * No checking is performed as to if this mode actually - * requires a parameter. If you stack invalid mode - * sequences, they will be tidied if and when they are - * passed to a mode parser. - * @param modeletter The mode letter to insert - * @param parameter The parameter for the mode - */ - void Push(char modeletter, const std::string ¶meter); - - /** Push a modeletter without parameter onto the stack. - * No checking is performed as to if this mode actually - * requires a parameter. If you stack invalid mode - * sequences, they will be tidied if and when they are - * passed to a mode parser. - * @param modeletter The mode letter to insert - */ - void Push(char modeletter); - - /** Push a '+' symbol onto the stack. - */ - void PushPlus(); - - /** Push a '-' symbol onto the stack. - */ - void PushMinus(); - - /** Return zero or more elements which form the - * mode line. This will be clamped to a max of - * MAXMODES items (MAXMODES-1 mode parameters and - * one mode sequence string), and max_line_size - * characters. As specified below, this function - * should be called in a loop until it returns zero, - * indicating there are no more modes to return. - * @param result The vector to populate. This will not - * be cleared before it is used. - * @param max_line_size The maximum size of the line - * to build, in characters, seperate to MAXMODES. - * @return The number of elements in the deque. - * The function should be called repeatedly until it - * returns 0, in case there are multiple lines of - * mode changes to be obtained. - */ - int GetStackedLine(std::vector &result, int max_line_size = 360); - - }; - /** irc::sepstream allows for splitting token seperated lists. * Each successive call to sepstream::GetToken() returns * the next token, until none remain, at which point the method returns diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 895b500ae..46981e703 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -348,71 +348,6 @@ bool irc::sepstream::StreamEnd() return this->pos > this->tokens.length(); } -irc::modestacker::modestacker(bool add) : adding(add) -{ - sequence.clear(); - sequence.push_back(""); -} - -void irc::modestacker::Push(char modeletter, const std::string ¶meter) -{ - *(sequence.begin()) += modeletter; - sequence.push_back(parameter); -} - -void irc::modestacker::Push(char modeletter) -{ - this->Push(modeletter,""); -} - -void irc::modestacker::PushPlus() -{ - this->Push('+',""); -} - -void irc::modestacker::PushMinus() -{ - this->Push('-',""); -} - -int irc::modestacker::GetStackedLine(std::vector &result, int max_line_size) -{ - if (sequence.empty()) - { - return 0; - } - - unsigned int n = 0; - int size = 1; /* Account for initial +/- char */ - int nextsize = 0; - int start = result.size(); - std::string modeline = adding ? "+" : "-"; - result.push_back(modeline); - - if (sequence.size() > 1) - nextsize = sequence[1].length() + 2; - - while (!sequence[0].empty() && (sequence.size() > 1) && (n < ServerInstance->Config->Limits.MaxModes) && ((size + nextsize) < max_line_size)) - { - modeline += *(sequence[0].begin()); - if (!sequence[1].empty()) - { - result.push_back(sequence[1]); - size += nextsize; /* Account for mode character and whitespace */ - } - sequence[0].erase(sequence[0].begin()); - sequence.erase(sequence.begin() + 1); - - if (sequence.size() > 1) - nextsize = sequence[1].length() + 2; - - n++; - } - result[start] = modeline; - - return n; -} - std::string irc::stringjoiner(const std::vector& sequence, char separator) { std::string joined; -- 2.39.5