From 384ef31bc01e4a1a2e59d082c9066002410ba54a Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 26 Jul 2018 19:43:54 +0100 Subject: Use CommandBase::Params instead of std::vector. This is presently a typedef but will soon be replaced with a class that encapsulates both tags and parameters. --- src/command_parse.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/command_parse.cpp') diff --git a/src/command_parse.cpp b/src/command_parse.cpp index 61f59ac0b..1ead005c4 100644 --- a/src/command_parse.cpp +++ b/src/command_parse.cpp @@ -43,7 +43,7 @@ bool InspIRCd::PassCompare(Extensible* ex, const std::string& data, const std::s return TimingSafeCompare(data, input); } -bool CommandParser::LoopCall(User* user, Command* handler, const std::vector& parameters, unsigned int splithere, int extra, bool usemax) +bool CommandParser::LoopCall(User* user, Command* handler, const CommandBase::Params& parameters, unsigned int splithere, int extra, bool usemax) { if (splithere >= parameters.size()) return false; @@ -82,7 +82,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vector new_parameters(parameters); + CommandBase::Params new_parameters(parameters); new_parameters[splithere] = item; if (extra >= 0) @@ -93,7 +93,7 @@ bool CommandParser::LoopCall(User* user, Command* handler, const std::vectorHandle(new_parameters, user); + CmdResult result = handler->Handle(user, new_parameters); if (localuser) { // Run the OnPostCommand hook with the last parameter (original line) being empty @@ -118,7 +118,7 @@ Command* CommandParser::GetHandler(const std::string &commandname) // calls a handler function for a command -CmdResult CommandParser::CallHandler(const std::string& commandname, const std::vector& parameters, User* user, Command** cmd) +CmdResult CommandParser::CallHandler(const std::string& commandname, const CommandBase::Params& parameters, User* user, Command** cmd) { CommandMap::iterator n = cmdlist.find(commandname); @@ -152,7 +152,7 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const std:: { if (cmd) *cmd = n->second; - return n->second->Handle(parameters,user); + return n->second->Handle(user, parameters); } } } @@ -161,7 +161,7 @@ CmdResult CommandParser::CallHandler(const std::string& commandname, const std:: void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) { - std::vector command_p; + CommandBase::Params command_p; irc::tokenstream tokens(cmd); std::string command, token; tokens.GetToken(command); @@ -236,12 +236,12 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) */ // Iterator to the last parameter that will be kept - const std::vector::iterator lastkeep = command_p.begin() + (handler->max_params - 1); + const CommandBase::Params::iterator lastkeep = command_p.begin() + (handler->max_params - 1); // Iterator to the first excess parameter - const std::vector::iterator firstexcess = lastkeep + 1; + const CommandBase::Params::iterator firstexcess = lastkeep + 1; // Append all excess parameter(s) to the last parameter, seperated by spaces - for (std::vector::const_iterator i = firstexcess; i != command_p.end(); ++i) + for (CommandBase::Params::const_iterator i = firstexcess; i != command_p.end(); ++i) { lastkeep->push_back(' '); lastkeep->append(*i); @@ -329,7 +329,7 @@ void CommandParser::ProcessCommand(LocalUser *user, std::string &cmd) /* * WARNING: be careful, the user may be deleted soon */ - CmdResult result = handler->Handle(command_p, user); + CmdResult result = handler->Handle(user, command_p); FOREACH_MOD(OnPostCommand, (handler, command_p, user, result, cmd)); } @@ -363,7 +363,7 @@ void CommandBase::EncodeParameter(std::string& parameter, unsigned int index) { } -RouteDescriptor CommandBase::GetRouting(User* user, const std::vector& parameters) +RouteDescriptor CommandBase::GetRouting(User* user, const Params& parameters) { return ROUTE_LOCALONLY; } -- cgit v1.3.1-10-gc9f91