summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-07-01 09:04:52 (GMT)
committerfluxgen <fluxgen>2003-07-01 09:04:52 (GMT)
commit6ad9158c4f1e1adf1fbb80b205523aa1bc5fe4b7 (patch)
tree632809ed729315a849385df225f5d0e9fa91e8d7
parent015c61ede0661fe4e563052b4d8418ac6223e843 (diff)
downloadfluxbox_lack-6ad9158c4f1e1adf1fbb80b205523aa1bc5fe4b7.zip
fluxbox_lack-6ad9158c4f1e1adf1fbb80b205523aa1bc5fe4b7.tar.bz2
not using showCommands
-rw-r--r--src/CommandParser.cc26
-rw-r--r--src/CommandParser.hh6
2 files changed, 10 insertions, 22 deletions
diff --git a/src/CommandParser.cc b/src/CommandParser.cc
index 1355cf9..aebb99a 100644
--- a/src/CommandParser.cc
+++ b/src/CommandParser.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: CommandParser.cc,v 1.2 2003/07/01 01:49:09 rathnor Exp $ 23// $Id: CommandParser.cc,v 1.3 2003/07/01 09:04:52 fluxgen Exp $
24 24
25#include "CommandParser.hh" 25#include "CommandParser.hh"
26 26
@@ -28,8 +28,8 @@
28 28
29#include <vector> 29#include <vector>
30#include <iostream> 30#include <iostream>
31#include <iterator>
32using namespace std; 31using namespace std;
32
33namespace { 33namespace {
34 34
35string::size_type removeFirstWhitespace(std::string &str) { 35string::size_type removeFirstWhitespace(std::string &str) {
@@ -60,7 +60,7 @@ CommandParser &CommandParser::instance() {
60} 60}
61 61
62FbTk::Command *CommandParser::parseLine(const std::string &line) { 62FbTk::Command *CommandParser::parseLine(const std::string &line) {
63 63
64 // parse arguments and command 64 // parse arguments and command
65 string command = line; 65 string command = line;
66 string arguments; 66 string arguments;
@@ -70,7 +70,7 @@ FbTk::Command *CommandParser::parseLine(const std::string &line) {
70 // ok we have arguments, parsing them here 70 // ok we have arguments, parsing them here
71 arguments = command.substr(second_pos); 71 arguments = command.substr(second_pos);
72 removeFirstWhitespace(arguments); 72 removeFirstWhitespace(arguments);
73 command.erase(second_pos); // remove argument from command 73 command.erase(second_pos); // remove argument from command
74 } 74 }
75 75
76 // now we have parsed command and arguments 76 // now we have parsed command and arguments
@@ -82,23 +82,12 @@ FbTk::Command *CommandParser::parseLine(const std::string &line) {
82 command = FbTk::StringUtil::toLower(command); 82 command = FbTk::StringUtil::toLower(command);
83 83
84 // we didn't find any matching command in default commands, 84 // we didn't find any matching command in default commands,
85 // so we search in the command creators modules for a matching command string 85 // so we search in the command creators modules for a
86 // matching command string
86 return toCommand(command, arguments); 87 return toCommand(command, arguments);
87 88
88} 89}
89 90
90ostream &operator << (ostream &the_stream, const CommandParser::CommandFactoryMap::value_type &value) {
91 the_stream<<value.first;
92 return the_stream;
93}
94
95void CommandParser::showCommands(std::ostream &the_stream) const {
96 // copy command strings to stream
97 copy(m_commandfactorys.begin(),
98 m_commandfactorys.end(),
99 ostream_iterator<CommandFactoryMap::value_type>(the_stream, "\n"));
100}
101
102FbTk::Command *CommandParser::toCommand(const std::string &command_str, const std::string &arguments) { 91FbTk::Command *CommandParser::toCommand(const std::string &command_str, const std::string &arguments) {
103 if (m_commandfactorys[command_str] != 0) 92 if (m_commandfactorys[command_str] != 0)
104 return m_commandfactorys[command_str]->stringToCommand(command_str, arguments); 93 return m_commandfactorys[command_str]->stringToCommand(command_str, arguments);
@@ -115,7 +104,8 @@ void CommandParser::associateCommand(const std::string &command, CommandFactory
115} 104}
116 105
117void CommandParser::removeAssociation(CommandFactory &factory) { 106void CommandParser::removeAssociation(CommandFactory &factory) {
118 std::vector<std::string> commands; // commands that are associated with the factory 107 // commands that are associated with the factory
108 std::vector<std::string> commands;
119 // find associations 109 // find associations
120 CommandFactoryMap::iterator factory_it = m_commandfactorys.begin(); 110 CommandFactoryMap::iterator factory_it = m_commandfactorys.begin();
121 const CommandFactoryMap::iterator factory_it_end = m_commandfactorys.end(); 111 const CommandFactoryMap::iterator factory_it_end = m_commandfactorys.end();
diff --git a/src/CommandParser.hh b/src/CommandParser.hh
index 1a58c35..7872ef2 100644
--- a/src/CommandParser.hh
+++ b/src/CommandParser.hh
@@ -20,14 +20,13 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: CommandParser.hh,v 1.1 2003/06/30 14:44:43 fluxgen Exp $ 23// $Id: CommandParser.hh,v 1.2 2003/07/01 09:01:20 fluxgen Exp $
24 24
25#ifndef COMMANDPARSER_HH 25#ifndef COMMANDPARSER_HH
26#define COMMANDPARSER_HH 26#define COMMANDPARSER_HH
27 27
28#include <string> 28#include <string>
29#include <map> 29#include <map>
30#include <ostream>
31 30
32#include "RefCount.hh" 31#include "RefCount.hh"
33 32
@@ -54,8 +53,7 @@ public:
54 53
55 /// @return parses and returns a command matching the line 54 /// @return parses and returns a command matching the line
56 FbTk::Command *parseLine(const std::string &line); 55 FbTk::Command *parseLine(const std::string &line);
57 /// lists all commands to an ostream 56
58 void showCommands(std::ostream &the_stream) const;
59 /// @return instance of command parser 57 /// @return instance of command parser
60 static CommandParser &instance(); 58 static CommandParser &instance();
61private: 59private: