[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 _CommandExecutor_H__ |
---|
| 30 | #define _CommandExecutor_H__ |
---|
| 31 | |
---|
[7203] | 32 | #include "core/CorePrereqs.h" |
---|
[1505] | 33 | |
---|
| 34 | #include <map> |
---|
[3196] | 35 | #include <set> |
---|
| 36 | #include <string> |
---|
[1505] | 37 | |
---|
[3196] | 38 | #include "util/MultiType.h" |
---|
[1505] | 39 | #include "CommandEvaluation.h" |
---|
| 40 | |
---|
[2710] | 41 | // tolua_begin |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
[1505] | 44 | class _CoreExport CommandExecutor |
---|
| 45 | { |
---|
[2710] | 46 | // tolua_end |
---|
[1505] | 47 | public: |
---|
[1771] | 48 | static bool execute(const std::string& command, bool useTcl = true); // tolua_export |
---|
[3035] | 49 | |
---|
[7189] | 50 | static MultiType queryMT(const std::string& command, bool* success = 0, bool useTcl = true); |
---|
| 51 | static std::string query(const std::string& command, bool* success = 0, bool useTcl = true); // tolua_export |
---|
| 52 | |
---|
[1505] | 53 | static std::string complete(const std::string& command); |
---|
| 54 | static std::string hint(const std::string& command); |
---|
| 55 | |
---|
| 56 | static CommandEvaluation evaluate(const std::string& command); |
---|
| 57 | static const CommandEvaluation& getLastEvaluation(); |
---|
| 58 | |
---|
| 59 | private: |
---|
| 60 | CommandExecutor() {} |
---|
| 61 | CommandExecutor(const CommandExecutor& other); |
---|
| 62 | ~CommandExecutor() {} |
---|
| 63 | |
---|
| 64 | static CommandExecutor& getInstance(); |
---|
| 65 | static CommandEvaluation& getEvaluation(); |
---|
| 66 | |
---|
| 67 | static void parseIfNeeded(const std::string& command); |
---|
| 68 | static void parse(const std::string& command, bool bInitialize = true); |
---|
| 69 | |
---|
| 70 | static unsigned int argumentsFinished(); |
---|
| 71 | static unsigned int argumentsGiven(); |
---|
| 72 | static bool enoughArgumentsGiven(ConsoleCommand* command); |
---|
[6417] | 73 | static const std::string& getArgument(unsigned int index); |
---|
| 74 | static const std::string& getLastArgument(); |
---|
[1505] | 75 | |
---|
| 76 | static void createListOfPossibleIdentifiers(const std::string& fragment); |
---|
| 77 | static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0); |
---|
| 78 | static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param); |
---|
| 79 | |
---|
| 80 | static Identifier* getPossibleIdentifier(const std::string& name); |
---|
| 81 | static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0); |
---|
[6417] | 82 | static const std::string& getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param); |
---|
[1505] | 83 | |
---|
| 84 | static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param); |
---|
| 85 | static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list); |
---|
| 86 | static std::string getCommonBegin(const ArgumentCompletionList& list); |
---|
| 87 | |
---|
| 88 | CommandEvaluation evaluation_; |
---|
[1755] | 89 | }; // tolua_export |
---|
| 90 | } // tolua_export |
---|
[1505] | 91 | |
---|
| 92 | #endif /* _CommandExecutor_H__ */ |
---|