summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-01-09 14:56:28 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-01-09 14:56:28 +0100
commita0c90ee606ad4ddc49440a5157a13d4ab6f54e2b (patch)
tree3b79a02963d73a3e6349cebcbac5637a6d6a1961
parentf52e092d1a8c1af53aac422fce1e8d5edd3577a3 (diff)
m_spanningtree Add overload for add() and has_room(), giving more flexibility to subclasses of CommandFJoin::Builder
-rw-r--r--src/modules/m_spanningtree/commands.h16
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp8
2 files changed, 18 insertions, 6 deletions
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()