From a0c90ee606ad4ddc49440a5157a13d4ab6f54e2b Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 9 Jan 2015 14:56:28 +0100 Subject: m_spanningtree Add overload for add() and has_room(), giving more flexibility to subclasses of CommandFJoin::Builder --- src/modules/m_spanningtree/commands.h | 16 ++++++++++++++-- src/modules/m_spanningtree/fjoin.cpp | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/modules/m_spanningtree') diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index c0043f0a4..d901d69e0 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -143,10 +143,22 @@ class CommandFJoin : public ServerCommand static const size_t maxline = 480; std::string::size_type pos; + protected: + void add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend); + bool has_room(std::string::size_type nummodes) const; + public: Builder(Channel* chan, TreeServer* source = Utils->TreeRoot); - void add(Membership* memb); - bool has_room(Membership* memb) const; + void add(Membership* memb) + { + add(memb, memb->modes.begin(), memb->modes.end()); + } + + bool has_room(Membership* memb) const + { + return has_room(memb->modes.size()); + } + void clear(); const std::string& finalize(); }; diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index f0d804880..bcd8afe73 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -245,16 +245,16 @@ CommandFJoin::Builder::Builder(Channel* chan, TreeServer* source) push_raw(chan->ChanModes(true)).push_raw(" :"); } -void CommandFJoin::Builder::add(Membership* memb) +void CommandFJoin::Builder::add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend) { - push_raw(memb->modes).push_raw(',').push_raw(memb->user->uuid); + push_raw(mbegin, mend).push_raw(',').push_raw(memb->user->uuid); push_raw(':').push_raw_int(memb->id); push_raw(' '); } -bool CommandFJoin::Builder::has_room(Membership* memb) const +bool CommandFJoin::Builder::has_room(std::string::size_type nummodes) const { - return ((str().size() + memb->modes.size() + UIDGenerator::UUID_LENGTH + 2 + membid_max_digits + 1) <= maxline); + return ((str().size() + nummodes + UIDGenerator::UUID_LENGTH + 2 + membid_max_digits + 1) <= maxline); } void CommandFJoin::Builder::clear() -- cgit v1.2.3