Changeset 7221 in orxonox.OLD for trunk/src/lib/shell/shell_command.cc
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r7201 r7221 41 41 PRINTF(5)("create shellcommand %s %s\n", commandName, className); 42 42 this->setName(commandName); 43 this->description = NULL;44 this->alias = NULL;45 43 this->executor = executor.clone(); 46 44 this->executor->setName(commandName); … … 153 151 * @return true on success, false otherwise. 154 152 */ 155 bool ShellCommand::execute(const char*executionString)153 bool ShellCommand::execute(const std::string& executionString) 156 154 { 157 155 if (ShellCommandClass::commandClassList == NULL) … … 177 175 for (alias = ShellCommandClass::aliasList->begin(); alias != ShellCommandClass::aliasList->end(); alias++ ) 178 176 { 179 if ( (*alias)->getName() != NULL && !strcmp((*alias)->getName(), inputSplits.getString(0)) && (*alias)->getCommand() != NULL &&177 if (inputSplits.getString(0) == (*alias)->getName() && (*alias)->getCommand() != NULL && 180 178 (*alias)->getCommand()->shellClass != NULL ) 181 179 { … … 184 182 { 185 183 if (inputSplits.getCount() > 1) 186 (*alias)->getCommand()->executor->execute(objectList->front(), executionString+inputSplits.getOffset(1)); 184 { 185 186 (*alias)->getCommand()->executor->execute(objectList->front(), executionString.substr(inputSplits.getOffset(1))); /// TODO CHECK IF OK 187 } 187 188 else 188 189 (*alias)->getCommand()->executor->execute(objectList->front(), ""); … … 198 199 for (commandClassIT = ShellCommandClass::commandClassList->begin(); commandClassIT != ShellCommandClass::commandClassList->end(); commandClassIT++) 199 200 { 200 if ((*commandClassIT)->getName() && !strcasecmp(inputSplits.getString(0), (*commandClassIT)->getName()))201 if ((*commandClassIT)->getName() && inputSplits.getString(0) == (*commandClassIT)->getName()) 201 202 { 202 203 //elemCL->getName(); … … 217 218 for (object = objectList->begin(); object != objectList->end(); object++) 218 219 { 219 if ((*object)->getName() != NULL && !strcasecmp((*object)->getName(), inputSplits.getString(1)))220 if ((*object)->getName() != NULL && inputSplits.getString(1) == (*object)->getName() ) 220 221 { 221 222 objectPointer = (*object); … … 235 236 for (cmdIT = commandClass->commandList.begin(); cmdIT != commandClass->commandList.end(); cmdIT++) 236 237 { 237 if ( !strcmp((*cmdIT)->getName(), inputSplits.getString(fktPos)))238 if (inputSplits.getString(fktPos) == (*cmdIT)->getName()) 238 239 { 239 240 if (objectPointer == NULL && (*cmdIT)->executor->getType() & Executor_Objective) 240 241 return false; 241 242 if (inputSplits.getCount() > fktPos+1) 242 (*cmdIT)->executor->execute(objectPointer, executionString +inputSplits.getOffset(fktPos +1));243 (*cmdIT)->executor->execute(objectPointer, executionString.substr(inputSplits.getOffset(fktPos +1))); /// TODO CHECK IF OK 243 244 else 244 245 (*cmdIT)->executor->execute(objectPointer, ""); … … 255 256 * @param description the description of the Given command 256 257 */ 257 ShellCommand* ShellCommand::describe(const char*description)258 ShellCommand* ShellCommand::describe(const std::string& description) 258 259 { 259 260 if (this == NULL) … … 326 327 for (classIT = ShellCommandClass::commandClassList->begin(); classIT != ShellCommandClass::commandClassList->end(); classIT++) 327 328 { 328 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className , (*classIT)->commandList.size());329 PRINT(0)("Class:'%s' registered %d commands: \n", (*classIT)->className.c_str(), (*classIT)->commandList.size()); 329 330 330 331 list<ShellCommand*>::iterator cmdIT; … … 335 336 /* for (unsigned int i = 0; i< elem->paramCount; i++) 336 337 printf("%s ", ShellCommand::paramToString(elem->parameters[i]));*/ 337 if ( (*cmdIT)->description != NULL)338 printf("- %s", (*cmdIT)->description);338 if (!(*cmdIT)->description.empty()) 339 printf("- %s", (*cmdIT)->description.c_str()); 339 340 printf("\n"); 340 341
Note: See TracChangeset
for help on using the changeset viewer.