InspIRCd  3.0
numeric.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2016 Attila Molnar <[email protected]>
5  *
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.
9  *
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
13  * details.
14  *
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/>.
17  */
18 
19 
20 #pragma once
21 
22 #include "numerics.h"
23 
24 namespace Numeric
25 {
26  class Numeric;
27 }
28 
30 {
33  unsigned int numeric;
34 
37  std::vector<std::string> params;
38 
41  Server* sourceserver;
42 
43  public:
47  Numeric(unsigned int num)
48  : numeric(num)
49  , sourceserver(NULL)
50  {
51  }
52 
56  template <typename T>
57  Numeric& push(const T& x)
58  {
59  params.push_back(ConvToStr(x));
60  return *this;
61  }
62 
66  void SetServer(Server* server) { sourceserver = server; }
67 
71  Server* GetServer() const { return sourceserver; }
72 
76  unsigned int GetNumeric() const { return numeric; }
77 
81  const std::vector<std::string>& GetParams() const { return params; }
82 
86  std::vector<std::string>& GetParams() { return params; }
87 };
88 
89 namespace Numerics
90 {
94  {
95  public:
96  NoSuchNick(const std::string& nick)
97  : Numeric(ERR_NOSUCHNICK)
98  {
99  push(nick);
100  push("No such nick/channel");
101  }
102  };
103 }
Definition: server.h:22
Definition: numeric.h:24
Numeric(unsigned int num)
Definition: numeric.h:47
Definition: numeric.h:29
unsigned int GetNumeric() const
Definition: numeric.h:76
Definition: numeric.h:93
Numeric & push(const T &x)
Definition: numeric.h:57
void SetServer(Server *server)
Definition: numeric.h:66
Server * GetServer() const
Definition: numeric.h:71
Definition: numeric.h:89
const std::vector< std::string > & GetParams() const
Definition: numeric.h:81
std::vector< std::string > & GetParams()
Definition: numeric.h:86