aboutsummaryrefslogtreecommitdiff
path: root/src/CommandParser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/CommandParser.cc')
-rw-r--r--src/CommandParser.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/CommandParser.cc b/src/CommandParser.cc
index 582fa44..d4c6a28 100644
--- a/src/CommandParser.cc
+++ b/src/CommandParser.cc
@@ -23,22 +23,14 @@
23// $Id$ 23// $Id$
24 24
25#include "CommandParser.hh" 25#include "CommandParser.hh"
26 26#include "FbTk/StringUtil.hh"
27#include "StringUtil.hh"
28 27
29#include <vector> 28#include <vector>
30using namespace std;
31
32namespace {
33
34string::size_type removeFirstWhitespace(std::string &str) {
35 string::size_type first_pos = str.find_first_not_of(" \t");
36 if (first_pos != string::npos)
37 str.erase(0, first_pos);
38 return first_pos;
39}
40 29
41}; // end anonymous namespace 30using std::string;
31using std::vector;
32using FbTk::StringUtil::removeFirstWhitespace;
33using FbTk::StringUtil::toLower;
42 34
43CommandFactory::CommandFactory() { 35CommandFactory::CommandFactory() {
44 36
@@ -49,7 +41,7 @@ CommandFactory::~CommandFactory() {
49 CommandParser::instance().removeAssociation(*this); 41 CommandParser::instance().removeAssociation(*this);
50} 42}
51 43
52void CommandFactory::addCommand(const std::string &command_name) { 44void CommandFactory::addCommand(const string &command_name) {
53 CommandParser::instance().associateCommand(command_name, *this); 45 CommandParser::instance().associateCommand(command_name, *this);
54} 46}
55 47
@@ -58,7 +50,7 @@ CommandParser &CommandParser::instance() {
58 return singleton; 50 return singleton;
59} 51}
60 52
61FbTk::Command *CommandParser::parseLine(const std::string &line) { 53FbTk::Command *CommandParser::parseLine(const string &line) {
62 54
63 // parse arguments and command 55 // parse arguments and command
64 string command = line; 56 string command = line;
@@ -74,7 +66,7 @@ FbTk::Command *CommandParser::parseLine(const std::string &line) {
74 66
75 // now we have parsed command and arguments 67 // now we have parsed command and arguments
76 68
77 command = FbTk::StringUtil::toLower(command); 69 command = toLower(command);
78 70
79 // we didn't find any matching command in default commands, 71 // we didn't find any matching command in default commands,
80 // so we search in the command creators modules for a 72 // so we search in the command creators modules for a
@@ -100,7 +92,7 @@ void CommandParser::associateCommand(const std::string &command, CommandFactory
100 92
101void CommandParser::removeAssociation(CommandFactory &factory) { 93void CommandParser::removeAssociation(CommandFactory &factory) {
102 // commands that are associated with the factory 94 // commands that are associated with the factory
103 std::vector<std::string> commands; 95 vector<string> commands;
104 // find associations 96 // find associations
105 CommandFactoryMap::iterator factory_it = m_commandfactorys.begin(); 97 CommandFactoryMap::iterator factory_it = m_commandfactorys.begin();
106 const CommandFactoryMap::iterator factory_it_end = m_commandfactorys.end(); 98 const CommandFactoryMap::iterator factory_it_end = m_commandfactorys.end();