From b40ba0cf91603b695f1f2380cbd39966a458f22f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 27 Sep 2009 19:58:24 +0200 Subject: Use Unicode-aware String class instead of std::string --- src/Client/CommandParser.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/Client/CommandParser.cpp') diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index a271860..9b5c6bf 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -63,7 +63,7 @@ const CommandParser::Command CommandParser::commands[] = { }; -const CommandParser::Command* CommandParser::findCommand(const std::string& command) { +const CommandParser::Command* CommandParser::findCommand(const Core::String& command) { for(int i = 0; commands[i].commands[0] != 0; ++i) { for(int j = 0; commands[i].commands[j] != 0; ++j) { if(command == commands[i].commands[j]) { @@ -75,7 +75,7 @@ const CommandParser::Command* CommandParser::findCommand(const std::string& comm return 0; } -void CommandParser::printUsage(const std::string& command) { +void CommandParser::printUsage(const Core::String& command) { const CommandParser::Command *cmd = findCommand(command); if(cmd) @@ -83,14 +83,14 @@ void CommandParser::printUsage(const std::string& command) { } -std::map CommandParser::parseHostList(const std::vector &args, bool mustBeActive) { - const std::map& hosts = application->getInformationManager()->getDaemons(); - std::map ret; +std::map CommandParser::parseHostList(const std::vector &args, bool mustBeActive) { + const std::map& hosts = application->getInformationManager()->getDaemons(); + std::map ret; - for(std::vector::const_iterator arg = args.begin(); arg != args.end(); ++arg) { + for(std::vector::const_iterator arg = args.begin(); arg != args.end(); ++arg) { if(*arg == "*") { if(mustBeActive) { - for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { if(host->second.getState() != Common::HostInfo::INACTIVE) ret.insert(*host); } @@ -103,7 +103,7 @@ std::map CommandParser::parseHostList(const std:: } } else { - std::map::const_iterator host = hosts.find(*arg); + std::map::const_iterator host = hosts.find(*arg); if(host == hosts.end()) std::cerr << "Host '" << *arg << "' doesn't exist." << std::endl; @@ -117,7 +117,7 @@ std::map CommandParser::parseHostList(const std:: return ret; } -void CommandParser::helpCommand(const std::vector &args) { +void CommandParser::helpCommand(const std::vector &args) { if(args.size() == 1) { std::cout << "Available commands:" << std::endl << std::endl; @@ -146,8 +146,8 @@ void CommandParser::helpCommand(const std::vector &args) { } } -void CommandParser::listHostsCommand(const std::vector &args) { - const std::map& hosts = application->getInformationManager()->getDaemons(); +void CommandParser::listHostsCommand(const std::vector &args) { + const std::map& hosts = application->getInformationManager()->getDaemons(); if(args.size() == 1) { if(hosts.empty()) { @@ -157,7 +157,7 @@ void CommandParser::listHostsCommand(const std::vector &args) { bool output = false; - for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { if(host->second.getState() == Common::HostInfo::INACTIVE) continue; @@ -186,7 +186,7 @@ void CommandParser::listHostsCommand(const std::vector &args) { std::cout << "Host list:" << std::endl; - for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { + for(std::map::const_iterator host = hosts.begin(); host != hosts.end(); ++host) { std::cout << " " << host->first << " (" << (host->second.getState() == Common::HostInfo::RUNNING ? "running" : "inactive") << ")" << std::endl; } @@ -198,7 +198,7 @@ void CommandParser::listHostsCommand(const std::vector &args) { } } -void CommandParser::exitCommand(const std::vector &/*args*/) { +void CommandParser::exitCommand(const std::vector &/*args*/) { boost::shared_ptr request(new Common::Requests::DisconnectRequest(application)); application->getRequestManager()->sendRequest(connection, request); @@ -212,26 +212,26 @@ void CommandParser::exitCommand(const std::vector &/*args*/) { disconnect = true; } -bool CommandParser::parse(const std::string &cmd) { - std::vector splitCmd; +bool CommandParser::parse(const Core::String &cmd) { + std::vector splitCmd; - Core::Tokenizer::tokenize(cmd.c_str(), splitCmd); + Core::Tokenizer::tokenize(cmd, splitCmd); if(splitCmd.empty()) return true; - const Command* command = findCommand(splitCmd[0].extract()); + const Command* command = findCommand(splitCmd[0]); if(command) { - std::vector strings; + std::vector strings; - for(std::vector::iterator it = splitCmd.begin(); it != splitCmd.end(); ++it) - strings.push_back(it->extract()); + for(std::vector::iterator it = splitCmd.begin(); it != splitCmd.end(); ++it) + strings.push_back(*it); command->function(this, strings); } else { - std::cerr << "Unknown command '" << splitCmd[0].extract() << "'." << std::endl; + std::cerr << "Unknown command '" << splitCmd[0] << "'." << std::endl; } return true; -- cgit v1.2.3