Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2005, 3:10:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/world_entities: merged the Trunk to the world_entities branche
merged with command
svn merge -r5516:HEAD ../trunk/ world_entities/
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/lib/shell/shell_command.cc

    r5374 r5558  
    259259tList<ShellCommandAlias>* ShellCommandClass::aliasList = NULL;
    260260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270////////////////////////
     271// SHELL COMMAND BASE //
     272////////////////////////
    261273/**
    262274 * constructs and registers a new Command
     
    264276 * @param className the name of the class to apply this command to
    265277 * @param paramCount the count of parameters this command takes
    266  * @return self
    267278 */
    268279ShellCommandBase::ShellCommandBase(const char* commandName, const char* className, unsigned int paramCount, ...)
     
    282293  this->paramCount = paramCount;
    283294  this->parameters = new unsigned int[paramCount];
     295  this->defaultValue = new MultiType[paramCount];
    284296
    285297  va_list parameterList;
    286298  va_start(parameterList, paramCount);
    287299
     300  // What Parameters we have got
    288301  for (unsigned int i = 0; i < paramCount; i++)
    289   {
    290302    this->parameters[i] = va_arg(parameterList, int);
    291 
    292     switch (this->parameters[i])
    293     {
    294       case ParameterBool:
    295         this->defaultBools[i] = va_arg(parameterList, int);
    296         break;
    297       case ParameterChar:
    298         this->defaultStrings[i] = new char[2];
    299         sprintf(this->defaultStrings[0], "%c",  va_arg(parameterList, int));
    300         break;
    301       case ParameterString:
    302         this->defaultStrings[i] = va_arg(parameterList, char*);
    303         break;
    304       case ParameterInt:
    305         this->defaultInts[i] = va_arg(parameterList, int);
    306         break;
    307       case ParameterUInt:
    308         this->defaultInts[i] = va_arg(parameterList, unsigned int);
    309         break;
    310       case ParameterFloat:
    311         this->defaultFloats[i] = va_arg(parameterList, double);
    312         break;
    313       case ParameterLong:
    314         this->defaultInts[i] = va_arg(parameterList, long);
    315         break;
    316       default:
    317         break;
    318     }
    319   }
    320303}
    321304
    322305/**
    323306 * deconstructs a ShellCommand
    324  * @return
    325307 */
    326308ShellCommandBase::~ShellCommandBase()
    327309{
    328310  delete[] this->parameters;
     311  delete[] this->defaultValue;
    329312  if (this->alias != NULL && ShellCommandClass::aliasList != NULL)
    330313  {
     
    417400 * @return true on success, false otherwise.
    418401 */
    419 #include  "stdlibincl.h"
    420402bool ShellCommandBase::execute(const char* executionString)
    421403{
     
    598580  for (unsigned int i = 0; i < count; i++)
    599581  {
     582
     583
    600584    switch (this->parameters[i])
    601585    {
    602586      case ParameterBool:
    603         this->defaultBools[i] = va_arg(defaultList, int);
     587        this->defaultValue[i].setInt(va_arg(defaultList, int));
    604588        break;
    605589      case ParameterChar:
    606         this->defaultStrings[i] = new char[2];
    607         sprintf(this->defaultStrings[0], "%c",  va_arg(defaultList, int));
     590        this->defaultValue[i].setChar((char)va_arg(defaultList, int));
    608591        break;
    609592      case ParameterString:
    610         this->defaultStrings[i] = va_arg(defaultList, char*);
     593        this->defaultValue[i].setString(va_arg(defaultList, char*));
    611594        break;
    612595      case ParameterInt:
    613         this->defaultInts[i] = va_arg(defaultList, int);
     596        this->defaultValue[i].setInt(va_arg(defaultList, int));
    614597        break;
    615598      case ParameterUInt:
    616         this->defaultInts[i] = va_arg(defaultList, unsigned int);
     599        this->defaultValue[i].setInt((int)va_arg(defaultList, unsigned int));
    617600        break;
    618601      case ParameterFloat:
    619         this->defaultFloats[i] = va_arg(defaultList, double);
     602        this->defaultValue[i].setFloat(va_arg(defaultList, double));
    620603        break;
    621604      case ParameterLong:
    622         this->defaultInts[i] = va_arg(defaultList, long);
     605        this->defaultValue[i].setInt((int) va_arg(defaultList, long));
    623606        break;
    624607      default:
     
    626609    }
    627610  }
    628 
    629611  return this;
    630612}
Note: See TracChangeset for help on using the changeset viewer.