InspIRCd  4.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 <danieldg[email protected]>
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 std::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:
55  const CommandMap& GetCommands() const { return cmdlist; }
56 
69  CmdResult CallHandler(const std::string& commandname, const CommandBase::Params& parameters, User* user, Command** cmd = NULL);
70 
75  Command* GetHandler(const std::string &commandname);
76 
114  static bool LoopCall(User* user, Command* handler, const CommandBase::Params& parameters, unsigned int splithere, int extra = -1, bool usemax = true);
115 
120  void ProcessBuffer(LocalUser* user, const std::string& buffer);
121 
126  bool AddCommand(Command *f);
127 
130  void RemoveCommand(Command* x);
131 
139  static void TranslateSingleParam(TranslateType to, const std::string& item, std::string& dest, CommandBase* custom_translator = NULL, unsigned int paramnumber = 0);
140 
148  static std::string TranslateUIDs(const std::vector<TranslateType>& to, const CommandBase::Params& source, bool prefix_final = false, CommandBase* custom_translator = NULL);
149 };
Definition: ctables.h:128
Definition: ctables.h:124
Definition: ctables.h:208
Definition: command_parse.h:35
const CommandMap & GetCommands() const
Definition: command_parse.h:55
Definition: users.h:658
Definition: users.h:238