Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1390


Ignore:
Timestamp:
May 23, 2008, 2:10:52 AM (16 years ago)
Author:
landauf
Message:

only girls sleep at this time :P

(started new implementation of ConsoleExecutor parser, but it's still buggy)

Location:
code/branches/console/src/core
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CMakeLists.txt

    r1341 r1390  
    2020  CommandExecutor.cc
    2121  CommandEvaluation.cc
     22  ConsoleCommand.cc
     23  ArgumentCompletionFunctions.cc
    2224  ConsoleCommandCompilation.cc
    2325  Language.cc
  • code/branches/console/src/core/CommandEvaluation.cc

    r1351 r1390  
    5252        this->bEvaluatedParams_ = false;
    5353
    54         this->listOfPossibleFunctionClasses_.clear();
     54        this->listOfPossibleIdentifiers_.clear();
    5555        this->listOfPossibleFunctions_.clear();
    5656
     
    6464    bool CommandEvaluation::isValid() const
    6565    {
    66         if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
    67         {
    68             return this->function_;
    69         }
    70         else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
    71         {
    72             return (this->functionclass_ && this->function_);
    73         }
    74         else
    75         {
    76             return false;
    77         }
     66        return (this->function_);
    7867    }
    7968
     
    9483        unsigned int startindex = this->getStartindex();
    9584        if (this->originalCommandTokens_.size() > startindex)
    96             return evaluation.shortcut_->parse(removeSlashes(this->originalCommandTokens_.subSet(startindex).join() + evaluation.getAdditionalParameter()));
     85            return this->function_->parse(removeSlashes(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
    9786        else
    98             return evaluation.shortcut_->parse(removeSlashes(evaluation.additionalParameter_));
     87            return this->function_->parse(removeSlashes(this->additionalParameter_));
    9988    }
    10089
     
    10392        switch (this->state_)
    10493        {
     94            case CS_Uninitialized:
    10595            case CS_Empty:
    106                 std::list<std::pair<const std::string*, const std::string*> > temp;
    107                 if (evaluation.state_ == CS_Empty)
    108                 {
    109                     temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end());
    110                     temp.insert(temp.end(), this->listOfPossibleFunctionClasses_.begin(), this->listOfPossibleFunctionClasses_.end());
    111                 }
    112                 return (CommandEvaluation::getCommonBegin(temp));
     96            case CS_ShortcutOrIdentifier:
     97                {
     98                    std::list<std::pair<const std::string*, const std::string*> > temp;
     99                    if (this->state_ == CS_Empty)
     100                    {
     101                        temp.insert(temp.end(), this->listOfPossibleFunctions_.begin(), this->listOfPossibleFunctions_.end());
     102                        temp.insert(temp.end(), this->listOfPossibleIdentifiers_.begin(), this->listOfPossibleIdentifiers_.end());
     103                    }
     104                    return (CommandEvaluation::getCommonBegin(temp));
     105                }
    113106                break;
    114107            case CS_Shortcut_Params:
    115108                if (this->function_)
    116                     return (this->function_->getName() + " ");
     109                {
     110                    if (this->commandTokens_.size() > 1)
     111                        return (this->function_->getName() + " " + this->commandTokens_.subSet(1, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
     112                    else
     113                        return (this->function_->getName() + " ");
     114                }
    117115                break;
    118116            case CS_Shortcut_Finished:
    119117                if (this->function_)
    120118                {
    121                     if (this->function_->getParamCount() == 0)
     119                    if (this->commandTokens_.size() > 1)
     120                        return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1, this->originalCommandTokens_.size() - 1).join());
     121                    else
    122122                        return (this->function_->getName());
    123                     else if (this->originalCommandTokens_.size() > 1)
    124                         return (this->function_->getName() + " " + this->originalCommandTokens_.subSet(1).join());
    125123                }
    126124                break;
     
    131129            case CS_Function_Params:
    132130                if (this->functionclass_ && this->function_)
    133                     return (this->functionclass_->getName() + " " + this->function_->getName() + " ");
     131                {
     132                    if (this->commandTokens_.size() > 2)
     133                        return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->commandTokens_.subSet(2, this->commandTokens_.size() - 1).join() + " " + CommandEvaluation::getCommonBegin(this->listOfPossibleArguments_));
     134                    else
     135                        return (this->functionclass_->getName() + " " + this->function_->getName() + " ");
     136                }
    134137                break;
    135138            case CS_Function_Finished:
    136139                if (this->functionclass_ && this->function_)
    137140                {
    138                     if (this->function_->getParamCount() == 0)
    139                         return (this->functionclass_->getName() + " " + this->unction_->getName());
    140                     else if (this->originalCommandTokens_.size() > 2)
    141                         return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2).join());
    142                 }
     141                    if (this->commandTokens_.size() > 2)
     142                        return (this->functionclass_->getName() + " " + this->function_->getName() + " " + this->originalCommandTokens_.subSet(2, this->originalCommandTokens_.size() - 1).join());
     143                    else
     144                        return (this->functionclass_->getName() + " " + this->function_->getName());
     145                }
     146               break;
     147            case CS_Error:
    143148                break;
    144149        }
     
    151156        switch (this->state_)
    152157        {
     158            case CS_Uninitialized:
     159                break;
    153160            case CS_Empty:
    154                 return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandExecutor::dump(this->listOfPossibleFunctionClasses_));
     161            case CS_ShortcutOrIdentifier:
     162                return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
    155163                break;
    156164            case CS_Function:
     
    158166                break;
    159167            case CS_Shortcut_Params:
     168            case CS_Function_Params:
     169                return CommandEvaluation::dump(this->listOfPossibleArguments_);
    160170            case CS_Shortcut_Finished:
    161             case CS_Function_Params:
    162171            case CS_Function_Finished:
    163172                if (this->function_)
     
    175184    {
    176185        this->bEvaluatedParams_ = false;
    177         this->evaluatedExecutor_ = 0;
    178186
    179187        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
     
    188196        {
    189197            if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
    190             {
    191198                this->bEvaluatedParams_ = true;
    192                 this->evaluatedExecutor_ = this->function_;
    193             }
    194199        }
    195200        else if (this->originalCommandTokens_.size() > startindex)
    196201        {
    197202            if (this->function_->evaluate(this->originalCommandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
    198             {
    199203                this->bEvaluatedParams_ = true;
    200                 this->evaluatedExecutor_ = this->function_;
    201             }
    202204        }
    203205    }
     
    238240        if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished)
    239241            return 1;
    240         else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
     242        else if (this->state_ == CS_Function || this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished)
    241243            return 2;
    242244        else
  • code/branches/console/src/core/CommandEvaluation.h

    r1351 r1390  
    4444        CS_Uninitialized,
    4545        CS_Empty,
    46         CS_FunctionClass_Or_Shortcut,
     46        CS_ShortcutOrIdentifier,
    4747        CS_Shortcut_Params,
    4848        CS_Shortcut_Finished,
     
    6060            void initialize(const std::string& command);
    6161
    62             void execute() const;
     62            bool execute() const;
    6363            std::string complete() const;
    6464            std::string hint() const;
     
    101101                { this->bNewCommand_ = bNewCommand; }
    102102
    103             inline std::list<std::pair<const std::string*, const std::string*> >& getListOfPossibleFunctionClasses()
    104                 { return this->listOfPossibleFunctionClasses_; }
     103            inline std::list<std::pair<const std::string*, const std::string*> >& getListOfPossibleIdentifiers()
     104                { return this->listOfPossibleIdentifiers_; }
    105105            inline std::list<std::pair<const std::string*, const std::string*> >& getListOfPossibleFunctions()
    106106                { return this->listOfPossibleFunctions_; }
     107            inline std::list<std::pair<const std::string*, const std::string*> >& getListOfPossibleArguments()
     108                { return this->listOfPossibleArguments_; }
    107109
    108110            inline void setAdditionalParameter(const std::string& param)
     
    132134            std::string additionalParameter_;
    133135
    134             std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctionClasses_;
     136            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
    135137            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
     138            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleArguments_;
    136139
    137140            Identifier* functionclass_;
  • code/branches/console/src/core/CommandExecutor.cc

    r1351 r1390  
    5656    ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command)
    5757    {
     58        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
     59        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
     60        {
     61            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
     62        }
     63
     64
    5865        CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command;
    5966        CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(command->getName())] = command;
     
    135142        switch (CommandExecutor::getEvaluation().getState())
    136143        {
    137         }
    138     }
    139 
    140     bool CommandExecutor::argumentsFinished(unsigned int num)
    141     {
    142         return (CommandExecutor::argumentsFinished() >= num);
     144            case CS_Uninitialized:
     145                // Impossible
     146                break;
     147            case CS_Empty:
     148                CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
     149                CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
     150
     151                if (CommandExecutor::argumentsGiven() > 0)
     152                {
     153                    CommandExecutor::getEvaluation().setState(CS_ShortcutOrIdentifier);
     154                    CommandExecutor::parse(command, false);
     155                    return;
     156                }
     157                break;
     158            case CS_ShortcutOrIdentifier:
     159                if (CommandExecutor::argumentsFinished() > 0 || !CommandExecutor::getEvaluation().isNewCommand())
     160                {
     161                    // There's already a finished first argument - check if it's function or a classname
     162                    CommandExecutor::getEvaluation().setIdentifier(CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0)));
     163                    CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0)));
     164
     165                    if (CommandExecutor::getEvaluation().getFunction())
     166                    {
     167                        // It's a shortcut - continue parsing
     168                        CommandExecutor::getEvaluation().setState(CS_Shortcut_Params);
     169                        if (CommandExecutor::argumentsFinished() > 0 )
     170                            CommandExecutor::parse(command, false);
     171                        else
     172                            CommandExecutor::parse(command + " ", false);
     173                        return;
     174                    }
     175                    else if (CommandExecutor::getEvaluation().getIdentifier())
     176                    {
     177                        // It's a classname - continue parsing
     178                        CommandExecutor::getEvaluation().setState(CS_Function);
     179                        if (CommandExecutor::argumentsFinished() > 0 )
     180                            CommandExecutor::parse(command, false);
     181                        else
     182                            CommandExecutor::parse(command + " ", false);
     183                        return;
     184                    }
     185                }
     186
     187                if (CommandExecutor::argumentsFinished() == 0)
     188                {
     189                    // There is no finished first argument
     190                    unsigned int numIdentifiers = CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().size();
     191                    unsigned int numCommands = CommandExecutor::getEvaluation().getListOfPossibleFunctions().size();
     192
     193                    if (numCommands == 1 && numIdentifiers == 0)
     194                    {
     195                        // It must be this command
     196                        const std::string* possibleCommand = (*CommandExecutor::getEvaluation().getListOfPossibleFunctions().begin()).second;
     197                        CommandExecutor::getEvaluation().setState(CS_Shortcut_Params);
     198                        CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(*possibleCommand));
     199                        CommandExecutor::parse(*possibleCommand + " ", false);
     200                        return;
     201                    }
     202                    else if (numIdentifiers == 1 && numCommands == 0)
     203                    {
     204                        // It must be this classname
     205                        const std::string* possibleIdentifier = (*CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().begin()).second;
     206                        CommandExecutor::getEvaluation().setState(CS_Function);
     207                        CommandExecutor::getEvaluation().setIdentifier(CommandExecutor::getPossibleIdentifier(*possibleIdentifier));
     208                        CommandExecutor::parse(*possibleIdentifier + " ", false);
     209                        return;
     210                    }
     211                }
     212
     213                // It's not a shortcut nor a classname
     214                CommandExecutor::getEvaluation().setState(CS_Error);
     215                AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
     216                CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".");
     217                break;
     218            case CS_Function:
     219                if (CommandExecutor::getEvaluation().getIdentifier() && CommandExecutor::argumentsGiven() > 1)
     220                {
     221                    if (CommandExecutor::argumentsFinished() > 1 || !CommandExecutor::getEvaluation().isNewCommand())
     222                    {
     223                        // There is already a second argument - check if it's a valid function
     224                        CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().getIdentifier()));
     225
     226                        if (CommandExecutor::getEvaluation().getFunction())
     227                        {
     228                            // It's a shortcut - continue parsing
     229                            CommandExecutor::getEvaluation().setState(CS_Function_Params);
     230                            if (CommandExecutor::argumentsFinished() > 1 )
     231                                CommandExecutor::parse(command, false);
     232                            else
     233                                CommandExecutor::parse(command + " ", false);
     234                            return;
     235                        }
     236                    }
     237
     238                    if (CommandExecutor::argumentsFinished() <= 1)
     239                    {
     240                        // There is no finished second argument
     241                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0), CommandExecutor::getEvaluation().getIdentifier());
     242                        unsigned int numFunctions = CommandExecutor::getEvaluation().getListOfPossibleFunctions().size();
     243
     244                        if (numFunctions == 1)
     245                        {
     246                            // It must be this command
     247                            const std::string* possibleCommand = (*CommandExecutor::getEvaluation().getListOfPossibleFunctions().begin()).second;
     248                            CommandExecutor::getEvaluation().setState(CS_Function_Params);
     249                            CommandExecutor::getEvaluation().setFunction(CommandExecutor::getPossibleCommand(*possibleCommand));
     250                            CommandExecutor::parse(*possibleCommand + " ", false);
     251                            return;
     252                        }
     253                    }
     254
     255                    // It's not a function
     256                    AddLanguageEntry("commandexecutorunknowncommand", "is not a valid commandname");
     257                    CommandExecutor::getEvaluation().setError("Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknowncommand") + ".");
     258                }
     259
     260                // Bad state
     261                CommandExecutor::getEvaluation().setState(CS_Error);
     262                break;
     263            case CS_Shortcut_Params:
     264            case CS_Function_Params:
     265                if (CommandExecutor::getEvaluation().getFunction())
     266                {
     267                    unsigned int startindex = 0;
     268                    if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params)
     269                        startindex = 1;
     270                    else if (CommandExecutor::getEvaluation().getState() == CS_Function_Params)
     271                        startindex = 2;
     272
     273                    if (CommandExecutor::argumentsGiven() >= startindex)
     274                    {
     275                        if (CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().getFunction()))
     276                        {
     277                            if (CommandExecutor::getEvaluation().getState() == CS_Shortcut_Params)
     278                                CommandExecutor::getEvaluation().setState(CS_Shortcut_Finished);
     279                            else if (CommandExecutor::getEvaluation().getState() == CS_Function_Params)
     280                                CommandExecutor::getEvaluation().setState(CS_Function_Finished);
     281                            return;
     282                        }
     283                        else
     284                        {
     285                            CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getOriginalTokens().size() - startindex);
     286                            unsigned int numArguments = CommandExecutor::getEvaluation().getListOfPossibleArguments().size();
     287
     288                            if (numArguments == 1)
     289                            {
     290                                // There is exactly one possible argument
     291                                const std::string* possibleArgument = (*CommandExecutor::getEvaluation().getListOfPossibleArguments().begin()).second;
     292                                CommandExecutor::parse(CommandExecutor::getEvaluation().getTokens().subSet(0, CommandExecutor::getEvaluation().getTokens().size() - 1 - startindex).join() + " " + (*possibleArgument) + " ");
     293                                return;
     294                            }
     295
     296                            if (!CommandExecutor::getEvaluation().isNewCommand())
     297                            {
     298                                // There is more than one argument, but the user wants to use this - check if there is a perfect match
     299                                const std::string* possibleArgument = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().getFunction(), CommandExecutor::getEvaluation().getOriginalTokens().size() - startindex);
     300                                if (possibleArgument)
     301                                {
     302                                    // There is such an argument - use it
     303                                    CommandExecutor::parse(command + " ", false);
     304                                    return;
     305                                }
     306                            }
     307                        }
     308                    }
     309                }
     310
     311                // Bad state
     312                CommandExecutor::getEvaluation().setState(CS_Error);
     313                break;
     314            case CS_Shortcut_Finished:
     315            case CS_Function_Finished:
     316            case CS_Error:
     317                break;
     318        }
    143319    }
    144320
     
    152328    }
    153329
    154     std::string CommandExecutor::getToken(unsigned int index)
     330    unsigned int CommandExecutor::argumentsGiven()
     331    {
     332        return CommandExecutor::getEvaluation().getOriginalTokens().size();
     333    }
     334
     335    bool CommandExecutor::enoughArgumentsGiven(ConsoleCommand* command)
     336    {
     337        if (CommandExecutor::getEvaluation().getIdentifier())
     338            return (CommandExecutor::argumentsGiven() >= (2 + command->getParamCount()));
     339        else
     340            return (CommandExecutor::argumentsGiven() >= (1 + command->getParamCount()));
     341    }
     342
     343    std::string CommandExecutor::getArgument(unsigned int index)
    155344    {
    156345        if ((index >= 0) && index < (CommandExecutor::getEvaluation().getOriginalTokens().size()))
     
    160349    }
    161350
    162     unsigned int CommandExecutor::argumentsGiven()
    163     {
    164         return CommandExecutor::getEvaluation().getOriginalTokens().size();
    165     }
    166 
    167     bool CommandExecutor::enoughArgumentsGiven(ConsoleCommand* command, unsigned int head)
    168     {
    169         return (CommandExecutor::argumentsGiven() >= (head + command->getParamCount()));
    170     }
    171 
    172     void CommandExecutor::createListOfPossibleFunctionClasses(const std::string& fragment)
     351    std::string CommandExecutor::getLastArgument()
     352    {
     353        if (CommandExecutor::getEvaluation().getOriginalTokens().size() > 0)
     354            return CommandExecutor::getEvaluation().getOriginalTokens()[0];
     355        else
     356            return "";
     357    }
     358
     359    void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
    173360    {
    174361        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
    175362            if ((*it).second->hasConsoleCommands())
    176363                if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
    177                     CommandExecutor::getEvaluation().getListOfPossibleFunctionClasses().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
    178 
    179         CommandExecutor::getEvaluation().getListOfPossibleFunctionClasses().sort(CommandExecutor::compareStringsInList);
     364                    CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
     365
     366        CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().sort(CommandExecutor::compareStringsInList);
    180367    }
    181368
     
    197384    }
    198385
     386    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
     387    {
     388        for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
     389            if ((*it).first.find(getLowercase(fragment)) == 0 || fragment == "")
     390                CommandExecutor::getEvaluation().getListOfPossibleArguments().push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second));
     391
     392        CommandExecutor::getEvaluation().getListOfPossibleIdentifiers().sort(CommandExecutor::compareStringsInList);
     393
     394    }
     395
    199396    Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
    200397    {
     
    223420    }
    224421
     422    const std::string* CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
     423    {
     424        std::string lowercasename = getLowercase(name);
     425        for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(param); it != command->getArgumentCompletionListEnd(param); ++it)
     426            if ((*it).first == lowercasename)
     427                return &(*it).second;
     428
     429        return 0;
     430    }
     431
    225432    bool CommandExecutor::compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second)
    226433    {
  • code/branches/console/src/core/CommandExecutor.h

    r1351 r1390  
    7878            static void parse(const std::string& command, bool bInitialize = true);
    7979
    80             static bool argumentsFinished(unsigned int num);
    8180            static unsigned int argumentsFinished();
    8281            static unsigned int argumentsGiven();
    83             static bool enoughArgumentsGiven(ConsoleCommand* command, unsigned int head);
    84             static std::string getToken(unsigned int index);
     82            static bool enoughArgumentsGiven(ConsoleCommand* command);
     83            static std::string getArgument(unsigned int index);
     84            static std::string getLastArgument();
    8585
    86             static void createListOfPossibleFunctionClasses(const std::string& fragment);
     86            static void createListOfPossibleIdentifiers(const std::string& fragment);
    8787            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
     88            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
    8889
    8990            static Identifier* getPossibleIdentifier(const std::string& name);
    9091            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
     92            static const std::string* getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
    9193
    9294            static bool compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second);
  • code/branches/console/src/core/ConsoleCommand.h

    r1341 r1390  
    3636#include "Identifier.h"
    3737#include "CommandExecutor.h"
     38#include "ArgumentCompletionFunctions.h"
    3839
    3940
     
    7374    {
    7475        public:
    75             ConsoleCommand(FunctorStatic* functor, const std::string& name = "") : ExecutorStatic(functor, name), accessLevel_(AccessLevel::None) {}
     76            ConsoleCommand(FunctorStatic* functor, const std::string& name = "");
    7677
    7778            inline ConsoleCommand& setDescription(const std::string& description)
     
    99100                { return this->accessLevel_; }
    100101
     102            ConsoleCommand& setArgumentCompletionList(unsigned int param, const std::list<std::pair<std::string, std::string> >& (*function) (void));
     103
     104            const std::list<std::pair<std::string, std::string> >& getArgumentCompletionList(unsigned int param) const;
     105            std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListBegin(unsigned int param) const;
     106            std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListEnd(unsigned int param) const;
     107
    101108        private:
    102109            AccessLevel::Level accessLevel_;
     110            const std::list<std::pair<std::string, std::string> >& (*autocompletionFunction_[5]) (void);
    103111    };
    104112
  • code/branches/console/src/core/Identifier.cc

    r1341 r1390  
    231231    void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
    232232    {
     233        std::map<std::string, ConfigValueContainer*>::const_iterator it = this->configValues_.find(varname);
     234        if (it != this->configValues_.end())
     235        {
     236            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
     237        }
     238
    233239        this->bHasConfigValues_ = true;
    234240        this->configValues_[varname] = container;
     
    272278    ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)
    273279    {
     280        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());
     281        if (it != this->consoleCommands_.end())
     282        {
     283            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
     284        }
     285
    274286        this->bHasConsoleCommands_ = true;
    275287        this->consoleCommands_[command->getName()] = command;
Note: See TracChangeset for help on using the changeset viewer.