2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 CmdBuilder(const char* cmd)
35 content.append(ServerInstance->Config->GetSID());
39 CmdBuilder(TreeServer* src, const char* cmd)
42 content.append(src->GetID());
46 CmdBuilder(User* src, const char* cmd)
49 content.append(src->uuid);
53 CmdBuilder& push_raw(const std::string& s)
59 CmdBuilder& push_raw(const char* s)
65 CmdBuilder& push_raw(char c)
72 CmdBuilder& push_raw_int(T i)
74 content.append(ConvToStr(i));
78 template <typename InputIterator>
79 CmdBuilder& push_raw(InputIterator first, InputIterator last)
81 content.append(first, last);
85 CmdBuilder& push(const std::string& s)
87 content.push_back(' ');
92 CmdBuilder& push(const char* s)
94 content.push_back(' ');
99 CmdBuilder& push(char c)
101 content.push_back(' ');
102 content.push_back(c);
106 template <typename T>
107 CmdBuilder& push_int(T i)
109 content.push_back(' ');
110 content.append(ConvToStr(i));
114 CmdBuilder& push_last(const std::string& s)
116 content.push_back(' ');
117 content.push_back(':');
122 CmdBuilder& push_tags(const ClientProtocol::TagMap& tags)
126 char separator = '@';
128 for (ClientProtocol::TagMap::const_iterator iter = tags.begin(); iter != tags.end(); ++iter)
130 taglist.push_back(separator);
133 taglist.append(iter->first);
134 if (!iter->second.value.empty())
136 taglist.push_back('=');
137 taglist.append(iter->second.value);
140 taglist.push_back(' ');
141 content.insert(0, taglist);
147 CmdBuilder& insert(const T& cont)
149 for (typename T::const_iterator i = cont.begin(); i != cont.end(); ++i)
154 void push_back(const std::string& s) { push(s); }
156 const std::string& str() const { return content; }
157 operator const std::string&() const { return str(); }
159 void Broadcast() const
161 Utils->DoOneToMany(*this);
164 void Forward(TreeServer* omit) const
166 Utils->DoOneToAllButSender(*this, omit);
169 void Unicast(User* target) const
171 Utils->DoOneToOne(*this, target->server);