Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/CommandExecutor.h @ 1441

Last change on this file since 1441 was 1441, checked in by landauf, 16 years ago

you'll love this: separated displayed strings in autocompletion from actually inserted strings, to make fancy things like a really good autocompletion for files and directories.

@bensch: this is the "better system" I was talking about

File size: 5.6 KB
RevLine 
[947]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1056]3 *                    > www.orxonox.net <
[947]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
[1062]32#include "CorePrereqs.h"
33
[947]34#include <map>
35
[1341]36#include "CommandEvaluation.h"
[947]37
38namespace orxonox
39{
[952]40    class _CoreExport CommandExecutor
41    {
42        public:
[1198]43            static bool execute(const std::string& command, bool useTcl = true);
[947]44            static std::string complete(const std::string& command);
45            static std::string hint(const std::string& command);
46
[953]47            static CommandEvaluation evaluate(const std::string& command);
[1194]48            static const CommandEvaluation& getLastEvaluation();
49
[1341]50            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command);
51            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
52            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
[947]53
54            /** @brief Returns the map that stores all console commands. @return The const_iterator */
[1341]55            static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
[947]56            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
[1341]57            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
[947]58            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
[1341]59            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
[947]60
61            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
[1341]62            static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
[947]63            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
[1341]64            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
[947]65            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
[1341]66            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
[947]67
68        private:
[950]69            CommandExecutor() {}
[1064]70            CommandExecutor(const CommandExecutor& other);
[950]71            ~CommandExecutor() {}
72
[949]73            static CommandExecutor& getInstance();
[952]74            static CommandEvaluation& getEvaluation();
[949]75
[1402]76            static void parseIfNeeded(const std::string& command);
[947]77            static void parse(const std::string& command, bool bInitialize = true);
78
[1351]79            static unsigned int argumentsFinished();
[947]80            static unsigned int argumentsGiven();
[1390]81            static bool enoughArgumentsGiven(ConsoleCommand* command);
82            static std::string getArgument(unsigned int index);
83            static std::string getLastArgument();
[947]84
[1390]85            static void createListOfPossibleIdentifiers(const std::string& fragment);
[1351]86            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
[1390]87            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
[947]88
[1351]89            static Identifier* getPossibleIdentifier(const std::string& name);
90            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
[1427]91            static std::string getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
[1351]92
[1430]93            static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
[1424]94            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
[1441]95            static std::string getCommonBegin(const ArgumentCompletionList& list);
[947]96
[952]97            CommandEvaluation evaluation_;
[1341]98            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
99            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
[947]100    };
101}
102
103#endif /* _CommandExecutor_H__ */
Note: See TracBrowser for help on using the repository browser.