not using showCommands
This commit is contained in:
parent
015c61ede0
commit
6ad9158c4f
2 changed files with 10 additions and 22 deletions
|
@ -20,7 +20,7 @@
|
|||
// 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 <vector>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
string::size_type removeFirstWhitespace(std::string &str) {
|
||||
|
@ -60,7 +60,7 @@ CommandParser &CommandParser::instance() {
|
|||
}
|
||||
|
||||
FbTk::Command *CommandParser::parseLine(const std::string &line) {
|
||||
|
||||
|
||||
// parse arguments and command
|
||||
string command = line;
|
||||
string arguments;
|
||||
|
@ -70,7 +70,7 @@ FbTk::Command *CommandParser::parseLine(const std::string &line) {
|
|||
// 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 @@ FbTk::Command *CommandParser::parseLine(const std::string &line) {
|
|||
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 @@ void CommandParser::associateCommand(const std::string &command, CommandFactory
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -20,14 +20,13 @@
|
|||
// 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 @@ public:
|
|||
|
||||
/// @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:
|
||||
|
|
Loading…
Reference in a new issue