]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/commandbuilder.h
Fix broken linking over IPv4 on IPv6 capable systems.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / commandbuilder.h
index 07f7c94d0c0d616d622bbf045290706b8a669231..4bbb60e47ee52e418930975271ad579c088328a2 100644 (file)
@@ -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 <typename T>
+       CmdBuilder& push_raw_int(T i)
+       {
+               content.append(ConvToStr(i));
+               return *this;
+       }
+
+       template <typename InputIterator>
+       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);
        }
 };