Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/CommandEvaluation.h @ 1546

Last change on this file since 1546 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: 3.6 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/MultiTypeMath.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 void setAdditionalParameter(const std::string& param)
72                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
73            inline std::string getAdditionalParameter() const
74                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
75
76            void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
77            MultiTypeMath getEvaluatedParameter(unsigned int index) const;
78
79            bool hasReturnvalue() const;
80            MultiTypeMath getReturnvalue() const;
81
82        private:
83            unsigned int getStartindex() const;
84            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
85            static std::string dump(const ArgumentCompletionList& list);
86            static std::string dump(const ConsoleCommand* command);
87
88
89            bool bNewCommand_;
90            bool bCommandChanged_;
91
92            std::string originalCommand_;
93            std::string command_;
94            SubString commandTokens_;
95            std::string additionalParameter_;
96
97            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
98            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
99            ArgumentCompletionList listOfPossibleArguments_;
100
101            Identifier* functionclass_;
102            ConsoleCommand* function_;
103            std::string possibleArgument_;
104            std::string argument_;
105
106            std::string errorMessage_;
107            CommandState state_;
108
109            bool bEvaluatedParams_;
110            MultiTypeMath param_[5];
111    };
112}
113
114#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.