Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 972


Ignore:
Timestamp:
Apr 3, 2008, 12:05:15 AM (16 years ago)
Author:
landauf
Message:

CommandExecutor autocompletes now to correct casing (even if you're writing all lowercase or UPPERCASE or sOMethINg eLSe)

Location:
code/branches/core2/src/orxonox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/Orxonox.cc

    r955 r972  
    9999            void listen() const
    100100            {
    101                 std::cout << "> -->" << this->ib_->get() << "<--" << std::endl;
     101                std::cout << "> " << this->ib_->get() << std::endl;
    102102            }
    103103            void execute() const
    104104            {
    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;
    107108                this->ib_->clear();
    108109            }
    109110            void hintandcomplete() const
    110111            {
    111 std::cout << "### HINT!" << std::endl;
    112112                std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl;
    113113                this->ib_->set(CommandExecutor::complete(this->ib_->get()));
     
    115115            void clear() const
    116116            {
    117 std::cout << "### CLEAR!" << std::endl;
    118117                this->ib_->clear();
    119118            }
    120119            void removeLast() const
    121120            {
    122 std::cout << "### REMOVELAST!" << std::endl;
    123121                this->ib_->removeLast();
    124122            }
  • code/branches/core2/src/orxonox/core/CommandExecutor.cc

    r967 r972  
    9898        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
    9999        {
    100             return (this->shortcut_ != 0);
     100            return this->shortcut_;
    101101        }
    102102        else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
    103103        {
    104             return ((this->functionclass_ != 0) && (this->function_ != 0));
     104            return (this->functionclass_ && this->function_);
    105105        }
    106106        else if (this->state_ == CS_ConfigValueType || this->state_ == CS_ConfigValueFinished)
    107107        {
    108             return ((this->configvalueclass_ != 0) && (this->configvalue_ != 0));
     108            return (this->configvalueclass_ && this->configvalue_);
    109109        }
    110110        else if (this->state_ == CS_KeybindCommand || this->state_ == CS_KeybindFinished)
    111111        {
    112             return (this->key_ != 0);
     112            return this->key_;
    113113        }
    114114        else
     
    128128        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
    129129        {
    130             if (this->shortcut_ != 0)
     130            if (this->shortcut_)
    131131            {
    132132                if (this->shortcut_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
     
    139139        else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
    140140        {
    141             if (this->function_ != 0)
     141            if (this->function_)
    142142            {
    143143                if (this->function_->evaluate(this->processedCommand_ + this->getAdditionalParameter(), this->param_, " "))
     
    227227        SubString tokens(evaluation.processedCommand_, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    228228
    229         if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_ != 0)
     229        if (evaluation.bEvaluatedParams_ && evaluation.evaluatedExecutor_)
    230230        {
    231231            (*evaluation.evaluatedExecutor_)(evaluation.param_[0], evaluation.param_[1], evaluation.param_[2], evaluation.param_[3], evaluation.param_[4]);
     
    244244            case CS_Shortcut_Finished:
    245245                // call the shortcut
    246                 if (evaluation.shortcut_ != 0)
     246                if (evaluation.shortcut_)
    247247                {
    248248                    if (tokens.size() >= 2)
     
    258258            case CS_Function_Finished:
    259259                // call the shortcut
    260                 if (evaluation.function_ != 0)
     260                if (evaluation.function_)
    261261                {
    262262                    if (tokens.size() >= 3)
     
    274274            case CS_ConfigValueFinished:
    275275                // set the config value
    276                 if (evaluation.configvalue_ != 0)
     276                if (evaluation.configvalue_)
    277277                {
    278278                    if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE))
     
    319319        SubString tokens(evaluation.processedCommand_, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    320320
    321         std::list<const std::string*> temp;
     321        std::list<std::pair<const std::string*, const std::string*> > temp;
    322322        if (evaluation.state_ == CS_Empty)
    323323        {
     
    336336                break;
    337337            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() + " ");
    340340                break;
    341341            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                }
    342349                break;
    343350            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_));
    346353                break;
    347354            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() + " ");
    350357                break;
    351358            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                }
    352366                break;
    353367            case CS_ConfigValueClass:
    354368                if (tokens.size() >= 1)
    355                     return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_);
     369                    return (tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleConfigValueClasses_));
    356370                break;
    357371            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_));
    360374                break;
    361375            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() + " ");
    364378                break;
    365379            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());
    366382                break;
    367383            case CS_KeybindKey:
    368384                if (tokens.size() >= 1)
    369                     return tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_);
     385                    return (tokens[0] + " " + CommandExecutor::getCommonBegin(evaluation.listOfPossibleKeys_));
    370386                break;
    371387            case CS_KeybindCommand:
     
    404420                break;
    405421            case CS_Shortcut_Params:
    406                 if (evaluation.shortcut_ != 0)
     422                if (evaluation.shortcut_)
    407423                    return CommandExecutor::dump(evaluation.shortcut_);
    408424                break;
    409425            case CS_Shortcut_Finished:
    410                 if (evaluation.shortcut_ != 0)
     426                if (evaluation.shortcut_)
    411427                    return CommandExecutor::dump(evaluation.shortcut_);
    412428                break;
     
    415431                break;
    416432            case CS_Function_Params:
    417                 if (evaluation.function_ != 0)
     433                if (evaluation.function_)
    418434                    return CommandExecutor::dump(evaluation.function_);
    419435                break;
    420436            case CS_Function_Finished:
    421                 if (evaluation.function_ != 0)
     437                if (evaluation.function_)
    422438                    return CommandExecutor::dump(evaluation.function_);
    423439                break;
     
    429445                break;
    430446            case CS_ConfigValueType:
    431                 if (evaluation.configvalue_ != 0)
     447                if (evaluation.configvalue_)
    432448                    return CommandExecutor::dump(evaluation.configvalue_);
    433449                break;
    434450            case CS_ConfigValueFinished:
    435                 if (evaluation.configvalue_ != 0)
     451                if (evaluation.configvalue_)
    436452                    return CommandExecutor::dump(evaluation.configvalue_);
    437453                break;
     
    440456                break;
    441457            case CS_KeybindCommand:
    442                 if (evaluation.key_ != 0)
     458                if (evaluation.key_)
    443459                    return CommandExecutor::dump(evaluation.key_);
    444460                break;
    445461            case CS_KeybindFinished:
    446                 if (evaluation.key_ != 0)
     462                if (evaluation.key_)
    447463                    return CommandExecutor::dump(evaluation.key_);
    448464                break;
     
    483499                    CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
    484500
    485                     if ((CommandExecutor::getEvaluation().functionclass_ != 0) || (CommandExecutor::getEvaluation().shortcut_ != 0))
     501                    if ((CommandExecutor::getEvaluation().functionclass_) || (CommandExecutor::getEvaluation().shortcut_))
    486502                    {
    487503                        // Yes, there is a class or a shortcut with the searched name
     
    501517                        // There's only one possible class
    502518                        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);
    505521                        return;
    506522                    }
    507523                    else if ((CommandExecutor::getEvaluation().listOfPossibleFunctionClasses_.size() == 0) && (CommandExecutor::getEvaluation().listOfPossibleShortcuts_.size() == 1))
    508524                    {
    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))
    512528                        {
    513529                            // There's only one possible shortcut
    514530                            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))
    519535                        {
    520536                            // It's the 'set' or 'tset' keyword
    521537                            CommandExecutor::getEvaluation().state_ = CS_ConfigValueClass;
    522538                        }
    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)
    524540                        {
    525541                            // It's the 'bind' keyword
     
    527543                        }
    528544
    529                         CommandExecutor::parse(**CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin() + " ", false);
     545                        CommandExecutor::parse(*(*CommandExecutor::getEvaluation().listOfPossibleShortcuts_.begin()).first + " ", false);
    530546                        return;
    531547                    }
     
    560576                    }
    561577
    562                     if (CommandExecutor::getEvaluation().functionclass_ == 0)
     578                    if (!CommandExecutor::getEvaluation().functionclass_)
    563579                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0));
    564                     if (CommandExecutor::getEvaluation().shortcut_ == 0)
     580                    if (!CommandExecutor::getEvaluation().shortcut_)
    565581                        CommandExecutor::getEvaluation().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
    566582
    567                     if ((CommandExecutor::getEvaluation().functionclass_ == 0) && (CommandExecutor::getEvaluation().shortcut_ == 0))
     583                    if ((!CommandExecutor::getEvaluation().functionclass_) && (!CommandExecutor::getEvaluation().shortcut_))
    568584                    {
    569585                        // Argument 1 seems to be wrong
     
    573589                        return;
    574590                    }
    575                     else if (CommandExecutor::getEvaluation().shortcut_ != 0)
     591                    else if (CommandExecutor::getEvaluation().shortcut_)
    576592                    {
    577593                        // Argument 1 is a shortcut: Return the needed parameter types
     
    595611                break;
    596612            case CS_Shortcut_Params:
    597                 if (CommandExecutor::getEvaluation().shortcut_ != 0)
     613                if (CommandExecutor::getEvaluation().shortcut_)
    598614                {
    599615                    // Valid command
     
    613629                break;
    614630            case CS_Function:
    615                 if (CommandExecutor::getEvaluation().functionclass_ != 0)
     631                if (CommandExecutor::getEvaluation().functionclass_)
    616632                {
    617633                    // We have a valid classname
     
    621637                        // There is a second argument: Check if it's a valid functionname
    622638                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getEvaluation().functionclass_);
    623                         if (CommandExecutor::getEvaluation().function_ == 0)
     639                        if (!CommandExecutor::getEvaluation().function_)
    624640                        {
    625641                            // Argument 2 seems to be wrong
     
    644660                        {
    645661                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getEvaluation().functionclass_);
    646                             if (CommandExecutor::getEvaluation().function_ != 0)
     662                            if (CommandExecutor::getEvaluation().function_)
    647663                            {
    648664                                // There is a perfect match: Add a whitespace and continue parsing
     
    661677                            // There's only one possible function
    662678                            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);
    665681                            return;
    666682                        }
     
    677693                break;
    678694            case CS_Function_Params:
    679                 if ((CommandExecutor::getEvaluation().functionclass_ != 0) && (CommandExecutor::getEvaluation().function_ != 0))
     695                if (CommandExecutor::getEvaluation().functionclass_ && CommandExecutor::getEvaluation().function_)
    680696                {
    681697                    // Valid command
     
    703719                        // There is a second argument: Check if it's a valid classname
    704720                        CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
    705                         if (CommandExecutor::getEvaluation().configvalueclass_ == 0)
     721                        if (!CommandExecutor::getEvaluation().configvalueclass_)
    706722                        {
    707723                            // Argument 2 seems to be wrong
     
    726742                        {
    727743                            CommandExecutor::getEvaluation().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
    728                             if (CommandExecutor::getEvaluation().configvalueclass_ != 0)
     744                            if (CommandExecutor::getEvaluation().configvalueclass_)
    729745                            {
    730746                                // There is a perfect match: Add a whitespace and continue parsing
     
    743759                            // There's only one possible classname
    744760                            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);
    747763                            return;
    748764                        }
     
    760776                break;
    761777            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_))
    763779                {
    764780                    // Check if there is a third argument
     
    767783                        // There is a third argument: Check if it's a valid config value
    768784                        CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_);
    769                         if (CommandExecutor::getEvaluation().configvalue_ == 0)
     785                        if (!CommandExecutor::getEvaluation().configvalue_)
    770786                        {
    771787                            // Argument 3 seems to be wrong
     
    790806                        {
    791807                            CommandExecutor::getEvaluation().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getEvaluation().configvalueclass_);
    792                             if (CommandExecutor::getEvaluation().configvalue_ != 0)
     808                            if (CommandExecutor::getEvaluation().configvalue_)
    793809                            {
    794810                                // There is a perfect match: Add a whitespace and continue parsing
     
    807823                            // There's only one possible config value
    808824                            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);
    811827                            return;
    812828                        }
     
    824840                break;
    825841            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_)
    827843                {
    828844                    // Valid command
    829845                    // 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))
    831847                    {
    832848                        CommandExecutor::getEvaluation().state_ = CS_ConfigValueFinished;
     
    942958    {
    943959        unsigned int neededParams = head + executor->getParamCount();
     960        /*
    944961        for (unsigned int i = executor->getParamCount() - 1; i >= 0; i--)
    945962        {
     
    949966                break;
    950967        }
    951         return (CommandExecutor::getEvaluation().tokens_.size() >= neededParams);
     968        */
     969        return ((CommandExecutor::getEvaluation().tokens_.size() >= neededParams) && (CommandExecutor::getEvaluation().tokens_[neededParams - 1] != COMMAND_EXECUTOR_CURSOR));
    952970    }
    953971
     
    960978                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    961979                {
    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()));
    963981                }
    964982            }
     
    974992            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    975993            {
    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()));
    977995            }
    978996        }
     
    9871005            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    9881006            {
    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()));
    9901008            }
    9911009        }
     
    10021020                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    10031021                {
    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()));
    10051023                }
    10061024            }
     
    10161034            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    10171035            {
    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()));
    10191037            }
    10201038        }
     
    10301048    }
    10311049
    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));
    10351053    }
    10361054
     
    10891107    }
    10901108
    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)
    10921110    {
    10931111        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)
    10951113        {
    10961114            if (it != list.begin())
    10971115                output += " ";
    10981116
    1099             output += (**it);
     1117            output += *(*it).second;
    11001118        }
    11011119        return output;
     
    11311149    }
    11321150
    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)
    11341152    {
    11351153        if (list.size() == 0)
     
    11391157        else if (list.size() == 1)
    11401158        {
    1141             return ((**list.begin()) + " ");
     1159            return ((*(*list.begin()).first) + " ");
    11421160        }
    11431161        else
     
    11471165            {
    11481166                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)
    11521170                    {
    11531171                        if (it == list.begin())
    11541172                        {
    1155                             temp = (**it)[i];
     1173                            temp = (*(*it).first)[i];
    11561174                        }
    11571175                        else
    11581176                        {
    1159                             if (temp != (**it)[i])
     1177                            if (temp != (*(*it).first)[i])
    11601178                                return output;
    11611179                        }
  • code/branches/core2/src/orxonox/core/CommandExecutor.h

    r967 r972  
    3737#include "CorePrereqs.h"
    3838
    39 #define COMMAND_EXECUTOR_CURSOR '$'
     39#define COMMAND_EXECUTOR_CURSOR "$"
    4040
    4141namespace orxonox
     
    9191            std::string additionalParameter_;
    9292
    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_;
    9999
    100100            Identifier* functionclass_;
     
    173173            static void createListOfPossibleKeys(const std::string& fragment);
    174174
    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);
    176176
    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);
    178178            static std::string dump(const ExecutorStatic* executor);
    179179            static std::string dump(const ConfigValueContainer* container);
    180180
    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);
    182182
    183183            static Identifier* getIdentifierOfPossibleFunctionClass(const std::string& name);
  • code/branches/core2/src/orxonox/core/ConfigValueContainer.h

    r957 r972  
    7979                { this->value_.getValue(value); return *this; }
    8080
     81            inline const std::string& getName()
     82                { return this->varname_; }
     83
    8184            void description(const std::string& description);
    8285            const std::string& getDescription() const;
  • code/branches/core2/src/orxonox/core/InputBuffer.cc

    r966 r972  
    5757    void InputBuffer::set(const std::string& input)
    5858    {
    59         this->clear();
     59        this->buffer_ = "";
    6060        this->append(input);
    61         this->updated();
    6261    }
    6362
Note: See TracChangeset for help on using the changeset viewer.