Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

re-implemented parameter evaluation in CommandEvaluation and simplified parse() and evaluateParams() in Executor.

  • Property svn:eol-style set to native
File size: 3.0 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
36#include "util/SubString.h"
37#include "util/MultiType.h"
38#include "ArgumentCompletionListElement.h"
39#include "Functor.h"
40
41namespace orxonox
42{
43    class _CoreExport CommandEvaluation
44    {
45        friend class CommandExecutor;
46
47        public:
48            CommandEvaluation();
49
50            int execute();
51            MultiType query(int* error = 0);
52
53            std::string complete();
54            std::string hint();
55
56            int evaluateParams(bool bPrintError = false);
57
58            inline bool isValid() const
59                { return (this->execCommand_ != 0); }
60
61            inline _ConsoleCommand* getConsoleCommand() const
62                { return this->execCommand_; }
63
64            void setEvaluatedParameter(unsigned int index, const MultiType& param);
65            MultiType getEvaluatedParameter(unsigned int index) const;
66
67        private:
68            void initialize(const std::string& command);
69
70            unsigned int getNumberOfArguments() const;
71            const std::string& getLastArgument() const;
72            const std::string& getToken(unsigned int i) const;
73
74            void retrievePossibleArguments();
75
76            static void strip(ArgumentCompletionList& list, const std::string& fragment);
77
78            static std::string dump(const ArgumentCompletionList& list);
79            static std::string dump(const _ConsoleCommand* command);
80
81            static std::string getCommonBegin(const ArgumentCompletionList& list);
82
83            _ConsoleCommand* execCommand_;
84            _ConsoleCommand* hintCommand_;
85            SubString tokens_;
86            std::string string_;
87            unsigned int execArgumentsOffset_;
88            unsigned int hintArgumentsOffset_;
89            bool bPossibleArgumentsRetrieved_;
90            ArgumentCompletionList possibleArguments_;
91
92            bool bEvaluatedParams_;
93            bool bTriedToEvaluatedParams_;
94            unsigned int numberOfEvaluatedParams_;
95            MultiType param_[MAX_FUNCTOR_ARGUMENTS];
96    };
97}
98
99#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.