src/commands/ICommand.cpp

00001 #include "ICommand.h"
00002 
00003 ICommand::ICommand(std::string &params)
00004         :myParameters(params)
00005 {
00006 }
00007 
00008 ICommand::~ICommand()
00009 {
00010 }
00011 
00012 std::string ICommand::getParam(Uint16 param, bool toTheEnd){
00013         std::string tmpString;
00014         std::string::size_type spos, epos;
00015         
00016         tmpString = this->myParameters;
00017         
00018         // Finds the starting position.
00019         for(int counter = 0; counter < param; counter++){ // that's bad :(
00020                 spos = tmpString.find(" ");
00021                 if(spos != std::string::npos) // ok found
00022                         tmpString.assign(tmpString, (spos+1), tmpString.size());
00023         }
00024         
00025         if(spos != std::string::npos){
00026                 if(!toTheEnd){ // Take only this parameter, ignore what follows.
00027                         epos = tmpString.find(" "); // Finds the ending position.
00028                         tmpString.assign(tmpString, 0, epos); // Fills the result string.
00029                 }
00030         }
00031         else
00032                 tmpString = "";
00033         
00034         
00035         return tmpString;
00036 
00037 }

Generated on Mon Dec 3 04:30:12 2007 for lo-testserver by  doxygen 1.3.9.1