Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/CommandEvaluation.h @ 6133

Last change on this file since 6133 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 3.8 KB
RevLine 
[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
32#include "CorePrereqs.h"
33
34#include <string>
35#include <list>
36
37#include "ArgumentCompletionListElement.h"
38#include "util/SubString.h"
[1747]39#include "util/MultiType.h"
[1505]40
41namespace orxonox
42{
[3280]43    namespace CommandState
[1505]44    {
[3280]45        enum Value
46        {
47            Uninitialized,
48            Empty,
49            ShortcutOrIdentifier,
50            Function,
51            ParamPreparation,
52            Params,
53            Finished,
54            Error
55        };
56    }
[1505]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            std::string complete();
69            std::string hint() const;
70            void evaluateParams();
71
72            bool isValid() const;
73
74            inline ConsoleCommand* getConsoleCommand() const
75                { return this->function_; }
76            inline const std::string& getOriginalCommand() const
77                { return this->originalCommand_; }
78            inline const std::string& getCommand() const
79                { return this->command_; }
80
81            inline void setAdditionalParameter(const std::string& param)
82                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
83            inline std::string getAdditionalParameter() const
84                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
85
[1747]86            void setEvaluatedParameter(unsigned int index, MultiType param);
87            MultiType getEvaluatedParameter(unsigned int index) const;
[1505]88
89            bool hasReturnvalue() const;
[1747]90            MultiType getReturnvalue() const;
[1505]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_;
[3280]117            CommandState::Value state_;
[1505]118
119            bool bEvaluatedParams_;
[1747]120            MultiType param_[5];
[1505]121    };
122}
123
124#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.