Changeset 972 for code/branches/core2/src/orxonox
- Timestamp:
- Apr 3, 2008, 12:05:15 AM (17 years ago)
- Location:
- code/branches/core2/src/orxonox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/Orxonox.cc
r955 r972 99 99 void listen() const 100 100 { 101 std::cout << "> -->" << this->ib_->get() << "<--"<< std::endl;101 std::cout << "> " << this->ib_->get() << std::endl; 102 102 } 103 103 void execute() const 104 104 { 105 std::cout << "### EXECUTE!" << std::endl; 106 CommandExecutor::execute(this->ib_->get()); 105 std::cout << ">> " << this->ib_->get() << std::endl; 106 if (!CommandExecutor::execute(this->ib_->get())) 107 std::cout << "Error" << std::endl; 107 108 this->ib_->clear(); 108 109 } 109 110 void hintandcomplete() const 110 111 { 111 std::cout << "### HINT!" << std::endl;112 112 std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl; 113 113 this->ib_->set(CommandExecutor::complete(this->ib_->get())); … … 115 115 void clear() const 116 116 { 117 std::cout << "### CLEAR!" << std::endl;118 117 this->ib_->clear(); 119 118 } 120 119 void removeLast() const 121 120 { 122 std::cout << "### REMOVELAST!" << std::endl;123 121 this->ib_->removeLast(); 124 122 } -
code/branches/core2/src/orxonox/core/CommandExecutor.cc
r967 r972 98 98 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 99 99 { 100 return (this->shortcut_ != 0);100 return this->shortcut_; 101 101 } 102 102 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 103 103 { 104 return ( (this->functionclass_ != 0) && (this->function_ != 0));104 return (this->functionclass_ && this->function_); 105 105 } 106 106 else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished) 107 107 { 108 return ( (this->configvalueclass_ != 0) && (this->configvalue_ != 0));108 return (this->configvalueclass_ && this->configvalue_); 109 109 } 110 110 else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished) 111 111 { 112 return (this->key_ != 0);112 return this->key_; 113 113 } 114 114 else … … 128 128 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 129 129 { 130 if (this->shortcut_ != 0)130 if (this->shortcut_) 131 131 { 132 132 if (this->shortcut_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " ")) … … 139 139 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 140 140 { 141 if (this->function_ != 0)141 if (this->function_) 142 142 { 143 143 if (this->function_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " ")) … … 227 227 SubString tokens(evaluation.processedCommand_, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0'); 228 228 229 if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_ != 0)229 if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_) 230 230 { 231 231 (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]); … … 244 244 case CS_Shortcut_Finished: 245 245 // call the shortcut 246 if (evaluation.shortcut_ != 0)246 if (evaluation.shortcut_) 247 247 { 248 248 if (tokens.size() >= 2) … … 258 258 case CS_Function_Finished: 259 259 // call the shortcut 260 if (evaluation.function_ != 0)260 if (evaluation.function_) 261 261 { 262 262 if (tokens.size() >= 3) … … 274 274 case CS_ConfigValueFinished: 275 275 // set the config value 276 if (evaluation.configvalue_ != 0)276 if (evaluation.configvalue_) 277 277 { 278 278 if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)) … … 319 319 SubString tokens(evaluation.processedCommand_, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0'); 320 320 321 std::list< const std::string*> temp;321 std::list<std::pair<const std::string*, const std::string*> > temp; 322 322 if (evaluation.state_ == CS_Empty) 323 323 { … … 336 336 break; 337 337 case CS_Shortcut_Params: 338 if ( (evaluation.processedCommand_.size() >= 1) && (evaluation.processedCommand_[evaluation.processedCommand_.size() - 1] != ' '))339 return (evaluation. processedCommand_+ " ");338 if (evaluation.shortcut_) 339 return (evaluation.shortcut_->getName() + " "); 340 340 break; 341 341 case CS_Shortcut_Finished: 342 if (evaluation.shortcut_) 343 { 344 if (evaluation.shortcut_->getParamCount() == 0) 345 return (evaluation.shortcut_->getName()); 346 else if (tokens.size() >= 2) 347 return (evaluation.shortcut_->getName() + " " + tokens.subSet(1).join()); 348 } 342 349 break; 343 350 case CS_Function: 344 if ( tokens.size() >= 1)345 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_);351 if (evaluation.functionclass_) 352 return (evaluation.functionclass_->getName() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleFunctions_)); 346 353 break; 347 354 case CS_Function_Params: 348 if ( (evaluation.processedCommand_.size() >= 1) && (evaluation.processedCommand_[evaluation.processedCommand_.size() - 1] != ' '))349 return (evaluation. processedCommand_+ " ");355 if (evaluation.functionclass_ && evaluation.function_) 356 return (evaluation.functionclass_->getName() + " " + evaluation.function_->getName() + " "); 350 357 break; 351 358 case CS_Function_Finished: 359 if (evaluation.functionclass_ && evaluation.function_) 360 { 361 if (evaluation.function_->getParamCount() == 0) 362 return (evaluation.functionclass_->getName() + " " + evaluation.function_->getName()); 363 else if (tokens.size() >= 3) 364 return (evaluation.functionclass_->getName() + " " + evaluation.function_->getName() + " " + tokens.subSet(2).join()); 365 } 352 366 break; 353 367 case CS_ConfigValueClass: 354 368 if (tokens.size() >= 1) 355 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_);369 return (tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_)); 356 370 break; 357 371 case CS_ConfigValue: 358 if ( tokens.size() >= 2)359 return tokens[0] + " " + tokens[1] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_);372 if ((tokens.size() >= 1) && evaluation.configvalueclass_) 373 return (tokens[0] + " " + evaluation.configvalueclass_->getName() + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValues_)); 360 374 break; 361 375 case CS_ConfigValueType: 362 if (( evaluation.processedCommand_.size() >= 1) && (evaluation.processedCommand_[evaluation.processedCommand_.size() - 1] != ' '))363 return ( evaluation.processedCommand_+ " ");376 if ((tokens.size() >= 1) && evaluation.configvalueclass_ && evaluation.configvalue_) 377 return (tokens[0] + " " + evaluation.configvalueclass_->getName() + " " + evaluation.configvalue_->getName() + " "); 364 378 break; 365 379 case CS_ConfigValueFinished: 380 if ((tokens.size() >= 1) && evaluation.configvalueclass_ && evaluation.configvalue_ && (tokens.size() >= 4)) 381 return (tokens[0] + " " + evaluation.configvalueclass_->getName() + " " + evaluation.configvalue_->getName() + " " + tokens.subSet(3).join()); 366 382 break; 367 383 case CS_KeybindKey: 368 384 if (tokens.size() >= 1) 369 return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_);385 return (tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_)); 370 386 break; 371 387 case CS_KeybindCommand: … … 404 420 break; 405 421 case CS_Shortcut_Params: 406 if (evaluation.shortcut_ != 0)422 if (evaluation.shortcut_) 407 423 return CommandExecutor::dump(evaluation.shortcut_); 408 424 break; 409 425 case CS_Shortcut_Finished: 410 if (evaluation.shortcut_ != 0)426 if (evaluation.shortcut_) 411 427 return CommandExecutor::dump(evaluation.shortcut_); 412 428 break; … … 415 431 break; 416 432 case CS_Function_Params: 417 if (evaluation.function_ != 0)433 if (evaluation.function_) 418 434 return CommandExecutor::dump(evaluation.function_); 419 435 break; 420 436 case CS_Function_Finished: 421 if (evaluation.function_ != 0)437 if (evaluation.function_) 422 438 return CommandExecutor::dump(evaluation.function_); 423 439 break; … … 429 445 break; 430 446 case CS_ConfigValueType: 431 if (evaluation.configvalue_ != 0)447 if (evaluation.configvalue_) 432 448 return CommandExecutor::dump(evaluation.configvalue_); 433 449 break; 434 450 case CS_ConfigValueFinished: 435 if (evaluation.configvalue_ != 0)451 if (evaluation.configvalue_) 436 452 return CommandExecutor::dump(evaluation.configvalue_); 437 453 break; … … 440 456 break; 441 457 case CS_KeybindCommand: 442 if (evaluation.key_ != 0)458 if (evaluation.key_) 443 459 return CommandExecutor::dump(evaluation.key_); 444 460 break; 445 461 case CS_KeybindFinished: 446 if (evaluation.key_ != 0)462 if (evaluation.key_) 447 463 return CommandExecutor::dump(evaluation.key_); 448 464 break; … … 483 499 CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0)); 484 500 485 if ((CommandExecutor::getEvaluation().functionclass_ != 0) || (CommandExecutor::getEvaluation().shortcut_ != 0))501 if ((CommandExecutor::getEvaluation().functionclass_) || (CommandExecutor::getEvaluation().shortcut_)) 486 502 { 487 503 // Yes, there is a class or a shortcut with the searched name … … 501 517 // There's only one possible class 502 518 CommandExecutor::getEvaluation().state_ = CS_Function; 503 CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(* *CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin());504 CommandExecutor::parse(* *CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin()+ " ", false);519 CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(*(*CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin()).first); 520 CommandExecutor::parse(*(*CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.begin()).first + " ", false); 505 521 return; 506 522 } 507 523 else if ((CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.size() == 0) && (CommandExecutor::getEvaluation().listOfPossibleShortcuts_.size() == 1)) 508 524 { 509 if ((* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()!= COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)510 && (* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()!= COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)511 && (* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()!= COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND))525 if ((*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first != COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) 526 && (*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first != COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY) 527 && (*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first != COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND)) 512 528 { 513 529 // There's only one possible shortcut 514 530 CommandExecutor::getEvaluation().state_ = CS_Shortcut_Params; 515 CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin());516 } 517 else if ((* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()== COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)518 || (* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()== COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY))531 CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first); 532 } 533 else if ((*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) 534 || (*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) 519 535 { 520 536 // It's the 'set' or 'tset' keyword 521 537 CommandExecutor::getEvaluation().state_ = CS_ConfigValueClass; 522 538 } 523 else if (* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()!= COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND)539 else if (*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first != COMMAND_EXECUTOR_KEYWORD_SET_KEYBIND) 524 540 { 525 541 // It's the 'bind' keyword … … 527 543 } 528 544 529 CommandExecutor::parse(* *CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()+ " ", false);545 CommandExecutor::parse(*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first + " ", false); 530 546 return; 531 547 } … … 560 576 } 561 577 562 if ( CommandExecutor::getEvaluation().functionclass_ == 0)578 if (!CommandExecutor::getEvaluation().functionclass_) 563 579 CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0)); 564 if ( CommandExecutor::getEvaluation().shortcut_ == 0)580 if (!CommandExecutor::getEvaluation().shortcut_) 565 581 CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0)); 566 582 567 if (( CommandExecutor::getEvaluation().functionclass_ == 0) && (CommandExecutor::getEvaluation().shortcut_ == 0))583 if ((!CommandExecutor::getEvaluation().functionclass_) && (!CommandExecutor::getEvaluation().shortcut_)) 568 584 { 569 585 // Argument 1 seems to be wrong … … 573 589 return; 574 590 } 575 else if (CommandExecutor::getEvaluation().shortcut_ != 0)591 else if (CommandExecutor::getEvaluation().shortcut_) 576 592 { 577 593 // Argument 1 is a shortcut: Return the needed parameter types … … 595 611 break; 596 612 case CS_Shortcut_Params: 597 if (CommandExecutor::getEvaluation().shortcut_ != 0)613 if (CommandExecutor::getEvaluation().shortcut_) 598 614 { 599 615 // Valid command … … 613 629 break; 614 630 case CS_Function: 615 if (CommandExecutor::getEvaluation().functionclass_ != 0)631 if (CommandExecutor::getEvaluation().functionclass_) 616 632 { 617 633 // We have a valid classname … … 621 637 // There is a second argument: Check if it's a valid functionname 622 638 CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getEvaluation().functionclass_); 623 if ( CommandExecutor::getEvaluation().function_ == 0)639 if (!CommandExecutor::getEvaluation().function_) 624 640 { 625 641 // Argument 2 seems to be wrong … … 644 660 { 645 661 CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getEvaluation().functionclass_); 646 if (CommandExecutor::getEvaluation().function_ != 0)662 if (CommandExecutor::getEvaluation().function_) 647 663 { 648 664 // There is a perfect match: Add a whitespace and continue parsing … … 661 677 // There's only one possible function 662 678 CommandExecutor::getEvaluation().state_ = CS_Function_Params; 663 CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(* *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().functionclass_);664 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + * *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()+ " ", false);679 CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(*(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first, CommandExecutor::getEvaluation().functionclass_); 680 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first + " ", false); 665 681 return; 666 682 } … … 677 693 break; 678 694 case CS_Function_Params: 679 if ( (CommandExecutor::getEvaluation().functionclass_ != 0) && (CommandExecutor::getEvaluation().function_ != 0))695 if (CommandExecutor::getEvaluation().functionclass_ && CommandExecutor::getEvaluation().function_) 680 696 { 681 697 // Valid command … … 703 719 // There is a second argument: Check if it's a valid classname 704 720 CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1)); 705 if ( CommandExecutor::getEvaluation().configvalueclass_ == 0)721 if (!CommandExecutor::getEvaluation().configvalueclass_) 706 722 { 707 723 // Argument 2 seems to be wrong … … 726 742 { 727 743 CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1)); 728 if (CommandExecutor::getEvaluation().configvalueclass_ != 0)744 if (CommandExecutor::getEvaluation().configvalueclass_) 729 745 { 730 746 // There is a perfect match: Add a whitespace and continue parsing … … 743 759 // There's only one possible classname 744 760 CommandExecutor::getEvaluation().state_ = CS_ConfigValue; 745 CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(* *CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin());746 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + * *CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin()+ " ", false);761 CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(*(*CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin()).first); 762 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + *(*CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.begin()).first + " ", false); 747 763 return; 748 764 } … … 760 776 break; 761 777 case CS_ConfigValue: 762 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getEvaluation().configvalueclass_ != 0))778 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getEvaluation().configvalueclass_)) 763 779 { 764 780 // Check if there is a third argument … … 767 783 // There is a third argument: Check if it's a valid config value 768 784 CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_); 769 if ( CommandExecutor::getEvaluation().configvalue_ == 0)785 if (!CommandExecutor::getEvaluation().configvalue_) 770 786 { 771 787 // Argument 3 seems to be wrong … … 790 806 { 791 807 CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_); 792 if (CommandExecutor::getEvaluation().configvalue_ != 0)808 if (CommandExecutor::getEvaluation().configvalue_) 793 809 { 794 810 // There is a perfect match: Add a whitespace and continue parsing … … 807 823 // There's only one possible config value 808 824 CommandExecutor::getEvaluation().state_ = CS_ConfigValueType; 809 CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(* *CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin(), CommandExecutor::getEvaluation().configvalueclass_);810 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + CommandExecutor::getToken(1) + " " + * *CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin()+ " ", false);825 CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(*(*CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin()).first, CommandExecutor::getEvaluation().configvalueclass_); 826 CommandExecutor::parse(CommandExecutor::getToken(0) + " " + CommandExecutor::getToken(1) + " " + *(*CommandExecutor::getEvaluation().listOfPossibleConfigValues_.begin()).first + " ", false); 811 827 return; 812 828 } … … 824 840 break; 825 841 case CS_ConfigValueType: 826 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getEvaluation().configvalueclass_ != 0) && (CommandExecutor::getEvaluation().configvalue_ != 0))842 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && CommandExecutor::getEvaluation().configvalueclass_ && CommandExecutor::getEvaluation().configvalue_) 827 843 { 828 844 // Valid command 829 845 // Check if there are enough parameters 830 if ( CommandExecutor::getEvaluation().tokens_.size() >= 4)846 if ((CommandExecutor::getEvaluation().tokens_.size() >= 4) && (CommandExecutor::getEvaluation().tokens_[3] != COMMAND_EXECUTOR_CURSOR)) 831 847 { 832 848 CommandExecutor::getEvaluation().state_ = CS_ConfigValueFinished; … … 942 958 { 943 959 unsigned int neededParams = head + executor->getParamCount(); 960 /* 944 961 for (unsigned int i = executor->getParamCount() - 1; i >= 0; i--) 945 962 { … … 949 966 break; 950 967 } 951 return (CommandExecutor::getEvaluation().tokens_.size() >= neededParams); 968 */ 969 return ((CommandExecutor::getEvaluation().tokens_.size() >= neededParams) && (CommandExecutor::getEvaluation().tokens_[neededParams - 1] != COMMAND_EXECUTOR_CURSOR)); 952 970 } 953 971 … … 960 978 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 961 979 { 962 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.push_back( &(*it).first);980 CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 963 981 } 964 982 } … … 974 992 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 975 993 { 976 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.push_back( &(*it).first);994 CommandExecutor::getEvaluation().listOfPossibleShortcuts_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 977 995 } 978 996 } … … 987 1005 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 988 1006 { 989 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back( &(*it).first);1007 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 990 1008 } 991 1009 } … … 1002 1020 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 1003 1021 { 1004 CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.push_back( &(*it).first);1022 CommandExecutor::getEvaluation().listOfPossibleConfigValueClasses_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 1005 1023 } 1006 1024 } … … 1016 1034 if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "") 1017 1035 { 1018 CommandExecutor::getEvaluation().listOfPossibleConfigValues_.push_back( &(*it).first);1036 CommandExecutor::getEvaluation().listOfPossibleConfigValues_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 1019 1037 } 1020 1038 } … … 1030 1048 } 1031 1049 1032 bool CommandExecutor::compareStringsInList(const std:: string* first, const std::string*second)1033 { 1034 return ((*first ) < (*second));1050 bool CommandExecutor::compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second) 1051 { 1052 return ((*first.first) < (*second.first)); 1035 1053 } 1036 1054 … … 1089 1107 } 1090 1108 1091 std::string CommandExecutor::dump(const std::list< const std::string*>& list)1109 std::string CommandExecutor::dump(const std::list<std::pair<const std::string*, const std::string*> >& list) 1092 1110 { 1093 1111 std::string output = ""; 1094 for (std::list< const std::string*>::const_iterator it = list.begin(); it != list.end(); ++it)1112 for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it) 1095 1113 { 1096 1114 if (it != list.begin()) 1097 1115 output += " "; 1098 1116 1099 output += (**it);1117 output += *(*it).second; 1100 1118 } 1101 1119 return output; … … 1131 1149 } 1132 1150 1133 std::string CommandExecutor::getCommonBegin(const std::list< const std::string*>& list)1151 std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list) 1134 1152 { 1135 1153 if (list.size() == 0) … … 1139 1157 else if (list.size() == 1) 1140 1158 { 1141 return ((* *list.begin()) + " ");1159 return ((*(*list.begin()).first) + " "); 1142 1160 } 1143 1161 else … … 1147 1165 { 1148 1166 char temp = 0; 1149 for (std::list< const std::string*>::const_iterator it = list.begin(); it != list.end(); ++it)1150 { 1151 if ((* *it).size() > i)1167 for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it) 1168 { 1169 if ((*(*it).first).size() > i) 1152 1170 { 1153 1171 if (it == list.begin()) 1154 1172 { 1155 temp = (* *it)[i];1173 temp = (*(*it).first)[i]; 1156 1174 } 1157 1175 else 1158 1176 { 1159 if (temp != (* *it)[i])1177 if (temp != (*(*it).first)[i]) 1160 1178 return output; 1161 1179 } -
code/branches/core2/src/orxonox/core/CommandExecutor.h
r967 r972 37 37 #include "CorePrereqs.h" 38 38 39 #define COMMAND_EXECUTOR_CURSOR '$'39 #define COMMAND_EXECUTOR_CURSOR "$" 40 40 41 41 namespace orxonox … … 91 91 std::string additionalParameter_; 92 92 93 std::list< const std::string*> listOfPossibleFunctionClasses_;94 std::list< const std::string*> listOfPossibleShortcuts_;95 std::list< const std::string*> listOfPossibleFunctions_;96 std::list< const std::string*> listOfPossibleConfigValueClasses_;97 std::list< const std::string*> listOfPossibleConfigValues_;98 std::list< const std::string*> listOfPossibleKeys_;93 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctionClasses_; 94 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleShortcuts_; 95 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_; 96 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValueClasses_; 97 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleConfigValues_; 98 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleKeys_; 99 99 100 100 Identifier* functionclass_; … … 173 173 static void createListOfPossibleKeys(const std::string& fragment); 174 174 175 static bool compareStringsInList(const std:: string* first, const std::string*second);175 static bool compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second); 176 176 177 static std::string dump(const std::list< const std::string*>& list);177 static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list); 178 178 static std::string dump(const ExecutorStatic* executor); 179 179 static std::string dump(const ConfigValueContainer* container); 180 180 181 static std::string getCommonBegin(const std::list< const std::string*>& list);181 static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list); 182 182 183 183 static Identifier* getIdentifierOfPossibleFunctionClass(const std::string& name); -
code/branches/core2/src/orxonox/core/ConfigValueContainer.h
r957 r972 79 79 { this->value_.getValue(value); return *this; } 80 80 81 inline const std::string& getName() 82 { return this->varname_; } 83 81 84 void description(const std::string& description); 82 85 const std::string& getDescription() const; -
code/branches/core2/src/orxonox/core/InputBuffer.cc
r966 r972 57 57 void InputBuffer::set(const std::string& input) 58 58 { 59 this-> clear();59 this->buffer_ = ""; 60 60 this->append(input); 61 this->updated();62 61 } 63 62
Note: See TracChangeset
for help on using the changeset viewer.