From 02fe4a30856a7bc931e680e8667ab9fa13149b15 Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 2 Oct 2006 08:47:14 +0000 Subject: modestacker class, stacks modes and returns a string list of up to MAXMODES modes git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5389 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/hashcomp.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/hashcomp.cpp') diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 7eb7075c7..d0a4ab104 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -309,3 +309,31 @@ const char* irc::Spacify(char* n) } +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); +} + +std::deque irc::modestacker::GetStackedLine() +{ + std::deque result; + result.push_back(""); + + while (!sequence[0].empty() && (sequence.size() > 1)) + { + result[0] += *(sequence[0].begin()); + result.push_back(sequence[1]); + sequence[0].erase(sequence[0].begin()); + sequence.erase(sequence.begin() + 1); + } + + return result; +} + -- cgit v1.2.3