Changeset 5207 in orxonox.OLD for trunk/src/lib/shell
- Timestamp:
- Sep 19, 2005, 10:00:45 AM (19 years ago)
- Location:
- trunk/src/lib/shell
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_command.cc
r5204 r5207 572 572 return this; 573 573 } 574 575 /** 576 * sets default Values of the Commands 577 * @param count how many default Values to set. 578 * @param ... the default Values in order. They will be cast to the right type 579 * @returns itself 580 * 581 * Be aware, that when you use this Function, you !!MUST!! match the input as 582 * count, [EXACTLY THE SAME AS IF YOU WOULD CALL THE FUNCTION UP TO count ARGUMENTS] 583 */ 584 ShellCommandBase* ShellCommandBase::defaultValues(unsigned int count, ...) 585 { 586 if (this == NULL) 587 return NULL; 588 if (count == 0) 589 return this; 590 if (count > this->paramCount) 591 count = this->paramCount; 592 593 va_list defaultList; 594 va_start(defaultList, count); 595 596 for (unsigned int i = 0; i < count; i++) 597 { 598 switch (this->parameters[i]) 599 { 600 case ParameterBool: 601 this->defaultBools[i] = va_arg(defaultList, int); 602 break; 603 case ParameterChar: 604 this->defaultStrings[i] = new char[2]; 605 sprintf(this->defaultStrings[0], "%c", va_arg(defaultList, int)); 606 break; 607 case ParameterString: 608 this->defaultStrings[i] = va_arg(defaultList, char*); 609 break; 610 case ParameterInt: 611 this->defaultInts[i] = va_arg(defaultList, int); 612 break; 613 case ParameterUInt: 614 this->defaultInts[i] = va_arg(defaultList, unsigned int); 615 break; 616 case ParameterFloat: 617 this->defaultFloats[i] = va_arg(defaultList, double); 618 break; 619 case ParameterLong: 620 this->defaultInts[i] = va_arg(defaultList, long); 621 break; 622 default: 623 break; 624 } 625 } 626 627 return this; 628 } 629 574 630 575 631 /** -
trunk/src/lib/shell/shell_command.h
r5204 r5207 2 2 * @file shell_command.h 3 3 * Definition of a on-screen-shell 4 * @todo simple way to supply Default Values with the macro.5 4 */ 6 5 … … 87 86 ShellCommandBase* describe(const char* description); 88 87 ShellCommandBase* setAlias(const char* alias); 88 ShellCommandBase* defaultValues(unsigned int count, ...); 89 89 90 90 /** @returns the CommandList of the Shell */ -
trunk/src/lib/shell/shell_input.cc
r5204 r5207 36 36 ->describe("retrieve some help about the input mode") 37 37 ->setAlias("help"); 38 39 38 /** 40 39 * standard constructor … … 179 178 void ShellInput::help(const char* className, const char* functionName) 180 179 { 180 printf("%s::%s\n", className, functionName); 181 181 182 if (strlen(className) == 0) 182 183 {
Note: See TracChangeset
for help on using the changeset viewer.