InspIRCd  3.0
command_parse.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2009-2010 Daniel De Graaf <[email protected]>
5  * Copyright (C) 2007 Robin Burchell <[email protected]>
6  * Copyright (C) 2007 Dennis Friis <[email protected]>
7  * Copyright (C) 2005-2007 Craig Edwards <[email protected]>
8  *
9  * This file is part of InspIRCd. InspIRCd is free software: you can
10  * redistribute it and/or modify it under the terms of the GNU General Public
11  * License as published by the Free Software Foundation, version 2.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #pragma once
24 
30 class CoreExport CommandParser
31 {
32  public:
33  typedef TR1NS::unordered_map<std::string, Command*> CommandMap;
34 
35  private:
40  void ProcessCommand(LocalUser* user, std::string& cmd);
41 
44  CommandMap cmdlist;
45 
46  public:
49  CommandParser();
50 
54  const CommandMap& GetCommands() const { return cmdlist; }
55 
68  CmdResult CallHandler(const std::string& commandname, const std::vector<std::string>& parameters, User* user, Command** cmd = NULL);
69 
74  Command* GetHandler(const std::string &commandname);
75 
113  static bool LoopCall(User* user, Command* handler, const std::vector<std::string>& parameters, unsigned int splithere, int extra = -1, bool usemax = true);
114 
119  void ProcessBuffer(std::string &buffer,LocalUser *user);
120 
125  bool AddCommand(Command *f);
126 
129  void RemoveCommand(Command* x);
130 
138  static void TranslateSingleParam(TranslateType to, const std::string& item, std::string& dest, CommandBase* custom_translator = NULL, unsigned int paramnumber = 0);
139 
147  static std::string TranslateUIDs(const std::vector<TranslateType>& to, const std::vector<std::string>& source, bool prefix_final = false, CommandBase* custom_translator = NULL);
148 };
149 
155 const int duration_multi[] =
156 {
157  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
158  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
159  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
160  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
161  1, 1, 1, 1, 1, 1, 1, 1, 86400, 1, 1, 1, 3600,
162  1, 1, 1, 1, 60, 1, 1, 1, 1, 1, 1, 1, 1, 1,
163  604800, 1, 31557600, 1, 1, 1, 1, 1, 1, 1, 1,
164  1, 1, 86400, 1, 1, 1, 3600, 1, 1, 1, 1, 60,
165  1, 1, 1, 1, 1, 1, 1, 1, 1, 604800, 1, 31557600,
166  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
167  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
168  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
169  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
170  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
171  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
172  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
173  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
174  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
175 };
const CommandMap & GetCommands() const
Definition: command_parse.h:54
Definition: users.h:224
Definition: command_parse.h:30
Definition: ctables.h:204
Definition: users.h:742
Definition: ctables.h:107