X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fcommandbuilder.h;h=4bbb60e47ee52e418930975271ad579c088328a2;hb=b4599531f97a9e6207b6bb8d728d7523b6995523;hp=07f7c94d0c0d616d622bbf045290706b8a669231;hpb=1031f333332cf1b09db4fd632f141143ee637c34;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h index 07f7c94d0..4bbb60e47 100644 --- a/src/modules/m_spanningtree/commandbuilder.h +++ b/src/modules/m_spanningtree/commandbuilder.h @@ -25,6 +25,7 @@ class TreeServer; class CmdBuilder { + protected: std::string content; public: @@ -49,15 +50,15 @@ class CmdBuilder push(cmd); } - CmdBuilder& push_raw(const std::string& str) + CmdBuilder& push_raw(const std::string& s) { - content.append(str); + content.append(s); return *this; } - CmdBuilder& push_raw(const char* str) + CmdBuilder& push_raw(const char* s) { - content.append(str); + content.append(s); return *this; } @@ -67,17 +68,31 @@ class CmdBuilder return *this; } - CmdBuilder& push(const std::string& str) + template + CmdBuilder& push_raw_int(T i) + { + content.append(ConvToStr(i)); + return *this; + } + + template + CmdBuilder& push_raw(InputIterator first, InputIterator last) + { + content.append(first, last); + return *this; + } + + CmdBuilder& push(const std::string& s) { content.push_back(' '); - content.append(str); + content.append(s); return *this; } - CmdBuilder& push(const char* str) + CmdBuilder& push(const char* s) { content.push_back(' '); - content.append(str); + content.append(s); return *this; } @@ -96,11 +111,35 @@ class CmdBuilder return *this; } - CmdBuilder& push_last(const std::string& str) + CmdBuilder& push_last(const std::string& s) { content.push_back(' '); content.push_back(':'); - content.append(str); + content.append(s); + return *this; + } + + CmdBuilder& push_tags(const ClientProtocol::TagMap& tags) + { + if (!tags.empty()) + { + char separator = '@'; + std::string taglist; + for (ClientProtocol::TagMap::const_iterator iter = tags.begin(); iter != tags.end(); ++iter) + { + taglist.push_back(separator); + separator = ';'; + + taglist.append(iter->first); + if (!iter->second.value.empty()) + { + taglist.push_back('='); + taglist.append(iter->second.value); + } + } + taglist.push_back(' '); + content.insert(0, taglist); + } return *this; } @@ -112,7 +151,7 @@ class CmdBuilder return *this; } - void push_back(const std::string& str) { push(str); } + void push_back(const std::string& s) { push(s); } const std::string& str() const { return content; } operator const std::string&() const { return str(); } @@ -127,13 +166,8 @@ class CmdBuilder Utils->DoOneToAllButSender(*this, omit); } - bool Unicast(const std::string& target) const - { - return Utils->DoOneToOne(*this, target); - } - - bool Unicast(User* target) const + void Unicast(User* target) const { - return Unicast(target->server); + Utils->DoOneToOne(*this, target->server); } };