]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/numericbuilder.h
Merge tag 'v2.0.26' into master.
[user/henk/code/inspircd.git] / include / numericbuilder.h
index cd418ea11be6d84968090575633f74717930b229..0d55093ca59c3db15d9f75b787f2872fa7dc918d 100644 (file)
@@ -22,6 +22,7 @@
 namespace Numeric
 {
        class WriteNumericSink;
+       class WriteRemoteNumericSink;
 
        template <char Sep, bool SendEmpty, typename Sink>
        class GenericBuilder;
@@ -52,6 +53,22 @@ class Numeric::WriteNumericSink
        }
 };
 
+class Numeric::WriteRemoteNumericSink
+{
+       User* const user;
+
+ public:
+       WriteRemoteNumericSink(User* u)
+               : user(u)
+       {
+       }
+
+       void operator()(Numeric& numeric) const
+       {
+               user->WriteRemoteNumeric(numeric);
+       }
+};
+
 template <char Sep, bool SendEmpty, typename Sink>
 class Numeric::GenericBuilder
 {
@@ -179,3 +196,57 @@ class Numeric::ParamBuilder : public GenericParamBuilder<NumStaticParams, SendEm
        {
        }
 };
+
+namespace Numerics
+{
+       class InvalidModeParameter;
+       class NoSuchChannel;
+       class NoSuchNick;
+}
+
+/* Builder for the ERR_INVALIDMODEPARAM numeric. */
+class Numerics::InvalidModeParameter : public Numeric::Numeric
+{
+ public:
+       InvalidModeParameter(Channel* chan, ModeHandler* mode, const std::string& parameter, const std::string& message = "")
+               : Numeric(ERR_INVALIDMODEPARAM)
+       {
+               push(chan->name);
+               push(mode->GetModeChar());
+               push(parameter);
+               push(message.empty() ? InspIRCd::Format("Invalid %s mode parameter", mode->name.c_str()) : message);
+       }
+
+       InvalidModeParameter(User* user, ModeHandler* mode, const std::string& parameter, const std::string& message = "")
+               : Numeric(ERR_INVALIDMODEPARAM)
+       {
+               push(user->registered & REG_NICK ? user->nick : "*");
+               push(mode->GetModeChar());
+               push(parameter);
+               push(message.empty() ? InspIRCd::Format("Invalid %s mode parameter", mode->name.c_str()) : message);
+       }
+};
+
+/** Builder for the ERR_NOSUCHCHANNEL numeric. */
+class Numerics::NoSuchChannel : public Numeric::Numeric
+{
+ public:
+       NoSuchChannel(const std::string& chan)
+               : Numeric(ERR_NOSUCHCHANNEL)
+       {
+               push(chan);
+               push("No such channel");
+       }
+};
+
+/** Builder for the ERR_NOSUCHNICK numeric. */
+class Numerics::NoSuchNick : public Numeric::Numeric
+{
+ public:
+       NoSuchNick(const std::string& nick)
+               : Numeric(ERR_NOSUCHNICK)
+       {
+               push(nick);
+               push("No such nick");
+       }
+};