]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/numeric.h
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / include / numeric.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #pragma once
22
23 #include "numerics.h"
24
25 namespace Numeric
26 {
27         class Numeric;
28 }
29
30 class Numeric::Numeric
31 {
32         /** Numeric number
33          */
34         unsigned int numeric;
35
36         /** Parameters of the numeric
37          */
38         CommandBase::Params params;
39
40         /** Source server of the numeric, if NULL (the default) then it is the local server
41          */
42         Server* sourceserver;
43
44  public:
45         /** Constructor
46          * @param num Numeric number (RPL_*, ERR_*)
47          */
48         Numeric(unsigned int num)
49                 : numeric(num)
50                 , sourceserver(NULL)
51         {
52         }
53
54         /** Add a parameter to the numeric. The parameter will be converted to a string first with ConvToStr().
55          * @param x Parameter to add
56          */
57         template <typename T>
58         Numeric& push(const T& x)
59         {
60                 params.push_back(ConvToStr(x));
61                 return *this;
62         }
63
64         /** Set the source server of the numeric. The source server defaults to the local server.
65          * @param server Server to set as source
66          */
67         void SetServer(Server* server) { sourceserver = server; }
68
69         /** Get the source server of the numeric
70          * @return Source server or NULL if the source is the local server
71          */
72         Server* GetServer() const { return sourceserver; }
73
74         /** Get the number of the numeric as an unsigned integer
75          * @return Numeric number as an unsigned integer
76          */
77         unsigned int GetNumeric() const { return numeric; }
78
79         /** Get the parameters of the numeric
80          * @return Parameters of the numeric as a const vector of strings
81          */
82         const CommandBase::Params& GetParams() const { return params; }
83
84         /** Get the parameters of the numeric
85          * @return Parameters of the numeric as a vector of strings
86          */
87         CommandBase::Params& GetParams() { return params; }
88 };