Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 27, 2010, 2:41:03 PM (14 years ago)
Author:
landauf
Message:

re-implemented CommandExecutor and CommandEvaluation. parameter evaluation is currently not implemented, will come soon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h

    r7221 r7228  
    3333
    3434#include <string>
    35 #include <list>
    3635
    3736#include "ArgumentCompletionListElement.h"
     
    4140namespace orxonox
    4241{
    43     namespace CommandState
    44     {
    45         enum Value
    46         {
    47             Uninitialized,
    48             Empty,
    49             ShortcutOrIdentifier,
    50             Function,
    51             ParamPreparation,
    52             Params,
    53             Finished,
    54             Error
    55         };
    56     }
    57 
    5842    class _CoreExport CommandEvaluation
    5943    {
     
    6347            CommandEvaluation();
    6448
     49            int execute() const;
     50            MultiType query(int* error = 0) const;
     51
     52            std::string complete() const;
     53            std::string hint() const;
     54
     55            inline bool isValid() const
     56                { return (this->execCommand_ != 0); }
     57
     58            inline _ConsoleCommand* getConsoleCommand() const
     59                { return this->execCommand_; }
     60
     61//            void setEvaluatedParameter(unsigned int index, MultiType param);
     62//            MultiType getEvaluatedParameter(unsigned int index) const;
     63
     64        private:
    6565            void initialize(const std::string& command);
    6666
    67             bool execute() const;
    68             MultiType query(bool* success = 0) const;
     67            unsigned int getNumberOfArguments() const;
     68            const std::string& getLastArgument() const;
     69            const std::string& getToken(unsigned int i) const;
    6970
    70             const std::string& complete();
    71             std::string hint() const;
    72             void evaluateParams();
     71            void retrievePossibleArguments() const;
    7372
    74             bool isValid() const
    75                 { return this->function_; }
     73            static void strip(ArgumentCompletionList& list, const std::string& fragment);
    7674
    77             inline _ConsoleCommand* getConsoleCommand() const
    78                 { return this->function_; }
    79             inline const std::string& getOriginalCommand() const
    80                 { return this->originalCommand_; }
    81             inline const std::string& getCommand() const
    82                 { return this->command_; }
    83 
    84             inline void setAdditionalParameter(const std::string& param)
    85                 { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
    86             inline std::string getAdditionalParameter() const
    87                 { return (!this->additionalParameter_.empty()) ? (' ' + this->additionalParameter_) : ""; }
    88 
    89             void setEvaluatedParameter(unsigned int index, MultiType param);
    90             MultiType getEvaluatedParameter(unsigned int index) const;
    91 
    92         private:
    93             unsigned int getStartindex() const;
    94             static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
    9575            static std::string dump(const ArgumentCompletionList& list);
    9676            static std::string dump(const _ConsoleCommand* command);
    9777
     78            static std::string getCommonBegin(const ArgumentCompletionList& list);
    9879
    99             bool bNewCommand_;
    100             bool bCommandChanged_;
    101 
    102             std::string originalCommand_;
    103             std::string command_;
    104             SubString commandTokens_;
    105             std::string additionalParameter_;
    106 
    107             std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
    108             std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
    109             ArgumentCompletionList listOfPossibleArguments_;
    110 
    111             Identifier* functionclass_;
    112             _ConsoleCommand* function_;
    113             std::string possibleArgument_;
    114             std::string argument_;
    115 
    116             std::string errorMessage_;
    117             CommandState::Value state_;
    118 
    119             bool bEvaluatedParams_;
    120             MultiType param_[5];
     80            _ConsoleCommand* execCommand_;
     81            _ConsoleCommand* hintCommand_;
     82            SubString tokens_;
     83            std::string string_;
     84            unsigned int execArgumentsOffset_;
     85            unsigned int hintArgumentsOffset_;
     86            mutable bool bPossibleArgumentsRetrieved_;
     87            mutable ArgumentCompletionList possibleArguments_;
    12188    };
    12289}
Note: See TracChangeset for help on using the changeset viewer.