[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _CommandEvaluation_H__ |
---|
| 30 | #define _CommandEvaluation_H__ |
---|
| 31 | |
---|
[7203] | 32 | #include "core/CorePrereqs.h" |
---|
[1505] | 33 | |
---|
| 34 | #include <string> |
---|
| 35 | |
---|
| 36 | #include "util/SubString.h" |
---|
[1747] | 37 | #include "util/MultiType.h" |
---|
[7230] | 38 | #include "ArgumentCompletionListElement.h" |
---|
| 39 | #include "Functor.h" |
---|
[1505] | 40 | |
---|
| 41 | namespace orxonox |
---|
| 42 | { |
---|
| 43 | class _CoreExport CommandEvaluation |
---|
| 44 | { |
---|
| 45 | friend class CommandExecutor; |
---|
| 46 | |
---|
| 47 | public: |
---|
| 48 | CommandEvaluation(); |
---|
| 49 | |
---|
[7230] | 50 | int execute(); |
---|
| 51 | MultiType query(int* error = 0); |
---|
[1505] | 52 | |
---|
[7230] | 53 | std::string complete(); |
---|
| 54 | std::string hint(); |
---|
[1505] | 55 | |
---|
[7238] | 56 | std::string getCommandSuggestion() const; |
---|
| 57 | |
---|
[7230] | 58 | int evaluateParams(bool bPrintError = false); |
---|
| 59 | |
---|
[7228] | 60 | inline bool isValid() const |
---|
| 61 | { return (this->execCommand_ != 0); } |
---|
[1505] | 62 | |
---|
[7236] | 63 | inline ConsoleCommand* getConsoleCommand() const |
---|
[7228] | 64 | { return this->execCommand_; } |
---|
[1505] | 65 | |
---|
[7230] | 66 | void setEvaluatedParameter(unsigned int index, const MultiType& param); |
---|
| 67 | MultiType getEvaluatedParameter(unsigned int index) const; |
---|
[1505] | 68 | |
---|
[7233] | 69 | const ArgumentCompletionList& getPossibleArguments() const |
---|
| 70 | { return this->possibleArguments_; } |
---|
| 71 | |
---|
[7235] | 72 | size_t getPossibleArgumentsSize() const |
---|
| 73 | { return CommandEvaluation::getSize(this->possibleArguments_); } |
---|
| 74 | |
---|
[1505] | 75 | private: |
---|
[7228] | 76 | void initialize(const std::string& command); |
---|
[1505] | 77 | |
---|
[7228] | 78 | unsigned int getNumberOfArguments() const; |
---|
| 79 | const std::string& getLastArgument() const; |
---|
| 80 | const std::string& getToken(unsigned int i) const; |
---|
[1505] | 81 | |
---|
[7230] | 82 | void retrievePossibleArguments(); |
---|
[1505] | 83 | |
---|
[7228] | 84 | static void strip(ArgumentCompletionList& list, const std::string& fragment); |
---|
[7233] | 85 | static size_t getSize(const ArgumentCompletionList& list); |
---|
[1505] | 86 | |
---|
[7228] | 87 | static std::string dump(const ArgumentCompletionList& list); |
---|
[7236] | 88 | static std::string dump(const ConsoleCommand* command); |
---|
[1505] | 89 | |
---|
[7228] | 90 | static std::string getCommonBegin(const ArgumentCompletionList& list); |
---|
[1505] | 91 | |
---|
[7236] | 92 | ConsoleCommand* execCommand_; |
---|
| 93 | ConsoleCommand* hintCommand_; |
---|
[7228] | 94 | SubString tokens_; |
---|
| 95 | std::string string_; |
---|
| 96 | unsigned int execArgumentsOffset_; |
---|
| 97 | unsigned int hintArgumentsOffset_; |
---|
[7230] | 98 | bool bPossibleArgumentsRetrieved_; |
---|
| 99 | ArgumentCompletionList possibleArguments_; |
---|
| 100 | |
---|
| 101 | bool bEvaluatedParams_; |
---|
| 102 | bool bTriedToEvaluatedParams_; |
---|
| 103 | unsigned int numberOfEvaluatedParams_; |
---|
| 104 | MultiType param_[MAX_FUNCTOR_ARGUMENTS]; |
---|
[1505] | 105 | }; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | #endif /* _CommandEvaluation_H__ */ |
---|