Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ceguilua/src/core/CommandEvaluation.h @ 2214

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

merged core3 back to trunk

  • Property svn:eol-style set to native
File size: 3.7 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 "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    enum CommandState
44    {
45        CS_Uninitialized,
46        CS_Empty,
47        CS_ShortcutOrIdentifier,
48        CS_Function,
49        CS_ParamPreparation,
50        CS_Params,
51        CS_Finished,
52        CS_Error
53    };
54
55    class _CoreExport CommandEvaluation
56    {
57        friend class CommandExecutor;
58
59        public:
60            CommandEvaluation();
61
62            void initialize(const std::string& command);
63
64            bool execute() const;
65            std::string complete();
66            std::string hint() const;
67            void evaluateParams();
68
69            bool isValid() const;
70
71            inline ConsoleCommand* getConsoleCommand() const
72                { return this->function_; }
73            inline const std::string& getOriginalCommand() const
74                { return this->originalCommand_; }
75            inline const std::string& getCommand() const
76                { return this->command_; }
77
78            inline void setAdditionalParameter(const std::string& param)
79                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
80            inline std::string getAdditionalParameter() const
81                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
82
83            void setEvaluatedParameter(unsigned int index, MultiType param);
84            MultiType getEvaluatedParameter(unsigned int index) const;
85
86            bool hasReturnvalue() const;
87            MultiType getReturnvalue() const;
88
89        private:
90            unsigned int getStartindex() const;
91            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
92            static std::string dump(const ArgumentCompletionList& list);
93            static std::string dump(const ConsoleCommand* command);
94
95
96            bool bNewCommand_;
97            bool bCommandChanged_;
98
99            std::string originalCommand_;
100            std::string command_;
101            SubString commandTokens_;
102            std::string additionalParameter_;
103
104            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
105            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
106            ArgumentCompletionList listOfPossibleArguments_;
107
108            Identifier* functionclass_;
109            ConsoleCommand* function_;
110            std::string possibleArgument_;
111            std::string argument_;
112
113            std::string errorMessage_;
114            CommandState state_;
115
116            bool bEvaluatedParams_;
117            MultiType param_[5];
118    };
119}
120
121#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.