all repos — fluxbox @ 6ad9158c4f1e1adf1fbb80b205523aa1bc5fe4b7

custom fork of the fluxbox windowmanager

not using showCommands
fluxgen fluxgen
commit

6ad9158c4f1e1adf1fbb80b205523aa1bc5fe4b7

parent

015c61ede0661fe4e563052b4d8418ac6223e843

2 files changed, 10 insertions(+), 22 deletions(-)

jump to
M src/CommandParser.ccsrc/CommandParser.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: CommandParser.cc,v 1.2 2003/07/01 01:49:09 rathnor Exp $ +// $Id: CommandParser.cc,v 1.3 2003/07/01 09:04:52 fluxgen Exp $ #include "CommandParser.hh"

@@ -28,8 +28,8 @@ #include "StringUtil.hh"

#include <vector> #include <iostream> -#include <iterator> using namespace std; + namespace { string::size_type removeFirstWhitespace(std::string &str) {

@@ -60,7 +60,7 @@ return singleton;

} FbTk::Command *CommandParser::parseLine(const std::string &line) { - + // parse arguments and command string command = line; string arguments;

@@ -70,7 +70,7 @@ if (second_pos != string::npos) {

// ok we have arguments, parsing them here arguments = command.substr(second_pos); removeFirstWhitespace(arguments); - command.erase(second_pos); // remove argument from command + command.erase(second_pos); // remove argument from command } // now we have parsed command and arguments

@@ -82,23 +82,12 @@

command = FbTk::StringUtil::toLower(command); // we didn't find any matching command in default commands, - // so we search in the command creators modules for a matching command string + // so we search in the command creators modules for a + // matching command string return toCommand(command, arguments); } -ostream &operator << (ostream &the_stream, const CommandParser::CommandFactoryMap::value_type &value) { - the_stream<<value.first; - return the_stream; -} - -void CommandParser::showCommands(std::ostream &the_stream) const { - // copy command strings to stream - copy(m_commandfactorys.begin(), - m_commandfactorys.end(), - ostream_iterator<CommandFactoryMap::value_type>(the_stream, "\n")); -} - FbTk::Command *CommandParser::toCommand(const std::string &command_str, const std::string &arguments) { if (m_commandfactorys[command_str] != 0) return m_commandfactorys[command_str]->stringToCommand(command_str, arguments);

@@ -115,7 +104,8 @@ m_commandfactorys[command] = &factory;

} void CommandParser::removeAssociation(CommandFactory &factory) { - std::vector<std::string> commands; // commands that are associated with the factory + // commands that are associated with the factory + std::vector<std::string> commands; // find associations CommandFactoryMap::iterator factory_it = m_commandfactorys.begin(); const CommandFactoryMap::iterator factory_it_end = m_commandfactorys.end();
M src/CommandParser.hhsrc/CommandParser.hh

@@ -20,14 +20,13 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: CommandParser.hh,v 1.1 2003/06/30 14:44:43 fluxgen Exp $ +// $Id: CommandParser.hh,v 1.2 2003/07/01 09:01:20 fluxgen Exp $ #ifndef COMMANDPARSER_HH #define COMMANDPARSER_HH #include <string> #include <map> -#include <ostream> #include "RefCount.hh"

@@ -54,8 +53,7 @@ typedef std::map<std::string, CommandFactory *> CommandFactoryMap;

/// @return parses and returns a command matching the line FbTk::Command *parseLine(const std::string &line); - /// lists all commands to an ostream - void showCommands(std::ostream &the_stream) const; + /// @return instance of command parser static CommandParser &instance(); private: