Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands3/src/libraries/core/command/CommandEvaluation.h @ 7221

Last change on this file since 7221 was 7221, checked in by landauf, 14 years ago

adapted CommandExecutor and CommandEvaluation to make it compile again, but it doesn't run yet. ready for refactoring.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
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
32#include "core/CorePrereqs.h"
33
34#include <string>
35#include <list>
36
37#include "ArgumentCompletionListElement.h"
38#include "util/SubString.h"
39#include "util/MultiType.h"
40
41namespace orxonox
42{
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
58    class _CoreExport CommandEvaluation
59    {
60        friend class CommandExecutor;
61
62        public:
63            CommandEvaluation();
64
65            void initialize(const std::string& command);
66
67            bool execute() const;
68            MultiType query(bool* success = 0) const;
69
70            const std::string& complete();
71            std::string hint() const;
72            void evaluateParams();
73
74            bool isValid() const
75                { return this->function_; }
76
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);
95            static std::string dump(const ArgumentCompletionList& list);
96            static std::string dump(const _ConsoleCommand* command);
97
98
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];
121    };
122}
123
124#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.