Fixing command list delimiter depth.

This commit is contained in:
Brad Arant committed 2022-07-26 16:07:37 -07:00
1 parent 45aee7ab6f
commit 9af17daed6
5 files changed
+101 -105

No files matched your search

+16 -19
View File
@@ -2,50 +2,47 @@
#include "Log.h"
namespace core {
CommandList::CommandList(std::string delimiter, int depth) : delimiter(delimiter), depth(depth) {}
void CommandList::add(Command &command, std::string name) {
commands.insert(std::make_pair(name, &command));
}
void CommandList::remove(Command &command) {}
bool CommandList::processRequest(coreutils::ZString &request, TCPSession &session) {
int CommandList::processRequest(coreutils::ZString &request, TCPSession &session) {
if(session.grab != NULL)
return session.grab->processCommand(request, session);
return session.grab->processCommand(request, session);
else {
if(request.equals(""))
return false;
request.split(delimiter, 10);
return 0;
request.split(delimiter, depth);
request.reset();
try {
auto command = commands.at(request[0].str());
return command->processCommand(request, session);
return command->processCommand(request, session);
}
catch(...) {
return false;
return 0;
}
}
return true;
}
bool CommandList::grabInput(TCPSession &session, Command &command) {
session.grab = &command;
return true;
}
void CommandList::clearGrab(TCPSession &session) {
session.grab = NULL;
}
int CommandList::processCommand(coreutils::ZString &request, TCPSession &session) {
// for(Command *command : commands)
// session.out << command->getName() << std::endl;
// for(Command *command : commands)
// session.out << command->getName() << std::endl;
return true;
}
}