InspIRCd  3.0
command_parse.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2013-2014, 2016, 2018 Attila Molnar <[email protected]>
5  * Copyright (C) 2012-2013, 2017-2018 Sadie Powell <[email protected]>
6  * Copyright (C) 2012 Robby <[email protected]>
7  * Copyright (C) 2009 Uli Schlachter <[email protected]>
8  * Copyright (C) 2009 Daniel De Graaf <[email protected]rcd.org>
9  * Copyright (C) 2007 Robin Burchell <[email protected]>
10  * Copyright (C) 2007 Dennis Friis <[email protected]>
11  * Copyright (C) 2006-2008, 2010 Craig Edwards <[email protected]>
12  *
13  * This file is part of InspIRCd. InspIRCd is free software: you can
14  * redistribute it and/or modify it under the terms of the GNU General Public
15  * License as published by the Free Software Foundation, version 2.
16  *
17  * This program is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20  * details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
34 class CoreExport CommandParser
35 {
36  public:
37  typedef TR1NS::unordered_map<std::string, Command*, irc::insensitive, irc::StrHashComp> CommandMap;
38 
39  private:
45  void ProcessCommand(LocalUser* user, std::string& command, CommandBase::Params& parameters);
46 
49  CommandMap cmdlist;
50 
51  public:
54  CommandParser();
55 
59  const CommandMap& GetCommands() const { return cmdlist; }
60 
73  CmdResult CallHandler(const std::string& commandname, const CommandBase::Params& parameters, User* user, Command** cmd = NULL);
74 
79  Command* GetHandler(const std::string &commandname);
80 
118  static bool LoopCall(User* user, Command* handler, const CommandBase::Params& parameters, unsigned int splithere, int extra = -1, bool usemax = true);
119 
124  void ProcessBuffer(LocalUser* user, const std::string& buffer);
125 
130  bool AddCommand(Command *f);
131 
134  void RemoveCommand(Command* x);
135 
143  static void TranslateSingleParam(TranslateType to, const std::string& item, std::string& dest, CommandBase* custom_translator = NULL, unsigned int paramnumber = 0);
144 
152  static std::string TranslateUIDs(const std::vector<TranslateType>& to, const CommandBase::Params& source, bool prefix_final = false, CommandBase* custom_translator = NULL);
153 };
CommandParser
Definition: command_parse.h:34
CommandBase
Definition: ctables.h:113
User
Definition: users.h:233
CommandParser::GetCommands
const CommandMap & GetCommands() const
Definition: command_parse.h:59
Command
Definition: ctables.h:224
CommandBase::Params
Definition: ctables.h:117
LocalUser
Definition: users.h:727