diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-02-24 22:39:33 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-02-24 22:39:33 +0100 |
commit | 35ab037e7e6ac08e214b053de8ed87e3f35586fc (patch) | |
tree | 540d5b40a6e342f2cd6e0c61aec20347f8bb17b8 /src/Client | |
parent | f85b6d5ab264910f272e69ce5997cebec54886ce (diff) | |
download | mad-35ab037e7e6ac08e214b053de8ed87e3f35586fc.tar mad-35ab037e7e6ac08e214b053de8ed87e3f35586fc.zip |
Einigen unnoetigen Code entfernt
Diffstat (limited to 'src/Client')
-rw-r--r-- | src/Client/CommandParser.cpp | 63 | ||||
-rw-r--r-- | src/Client/CommandParser.h | 2 |
2 files changed, 3 insertions, 62 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 6665ea2..ff93aec 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -242,9 +242,9 @@ void CommandParser::shutdownCommand(const std::vector<std::string> &args) { void CommandParser::statusCommand(const std::vector<std::string> &args) { if(args.size() == 1) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished)))); else if(args.size() == 2) - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished)))); else { Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str()); printUsage("status"); @@ -257,7 +257,7 @@ void CommandParser::statusCommand(const std::vector<std::string> &args) { void CommandParser::listUsersCommand(const std::vector<std::string>&) { ++CommandManager::get()->activeRequests; - Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequestBase>(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished)))); + Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::XmlRequest>(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished)))); } void CommandParser::exitCommand(const std::vector<std::string>&) { @@ -266,63 +266,6 @@ void CommandParser::exitCommand(const std::vector<std::string>&) { Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished)))); } -bool CommandParser::split(const std::string &str, std::vector<std::string> &ret) { - std::string temp; - bool quoteSingle = false, quoteDouble = false, escape = false; - - size_t beg = 0; - - for(size_t cur = 0; cur < str.length(); ++cur) { - if(!escape) { - if(str[cur] == ' ' && !quoteSingle && !quoteDouble) { - if(cur == beg && temp.empty()) { - ++beg; - } - else { - temp += str.substr(beg, cur-beg); - ret.push_back(temp); - temp.clear(); - beg = cur+1; - } - - continue; - } - - if(str[cur] == '"' && !quoteSingle) { - temp += str.substr(beg, cur-beg); - beg = cur+1; - - quoteDouble = !quoteDouble; - continue; - } - if(str[cur] == '\'' && !quoteDouble) { - temp += str.substr(beg, cur-beg); - beg = cur+1; - - quoteSingle = !quoteSingle; - continue; - } - - if(str[cur] == '\\') { - escape = true; - continue; - } - } - - if(escape && ((!quoteSingle && !quoteDouble) || (quoteSingle && str[cur] == '\'') || (quoteDouble && (str[cur] == '"' || str[cur] == '\\')))) { - temp += str.substr(beg, cur-beg-1); - beg = cur; - } - - escape = false; - } - - temp += str.substr(beg, std::string::npos); - ret.push_back(temp); - - return true; -} - bool CommandParser::parse(const std::string &cmd) { std::vector<std::string> splitCmd; diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h index de65788..cb38588 100644 --- a/src/Client/CommandParser.h +++ b/src/Client/CommandParser.h @@ -53,8 +53,6 @@ class CommandParser { Net::Connection *connection; - bool split(const std::string &str, std::vector<std::string> &ret); - const Command* findCommand(const std::string& command); void printUsage(const std::string& command); |