Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

ConsoleCommand::getCommand should return a const pointer

  • Property svn:eol-style set to native
File size: 3.4 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            std::string getCommandSuggestion() const;
57
58            int evaluateParams(bool bPrintError = false);
59
60            inline bool isValid() const
61                { return (this->execCommand_ != 0); }
62
63            inline const ConsoleCommand* getConsoleCommand() const
64                { return this->execCommand_; }
65
66            void setEvaluatedParameter(unsigned int index, const MultiType& param);
67            MultiType getEvaluatedParameter(unsigned int index) const;
68
69            const ArgumentCompletionList& getPossibleArguments() const
70                { return this->possibleArguments_; }
71
72            size_t getPossibleArgumentsSize() const
73                { return CommandEvaluation::getSize(this->possibleArguments_); }
74
75        private:
76            void initialize(const std::string& command);
77
78            unsigned int getNumberOfArguments() const;
79            const std::string& getLastArgument() const;
80            const std::string& getToken(unsigned int i) const;
81
82            void retrievePossibleArguments();
83
84            static void strip(ArgumentCompletionList& list, const std::string& fragment);
85            static size_t getSize(const ArgumentCompletionList& list);
86
87            static std::string dump(const ArgumentCompletionList& list);
88            static std::string dump(const ConsoleCommand* command);
89
90            static std::string getCommonBegin(const ArgumentCompletionList& list);
91
92            const ConsoleCommand* execCommand_;
93            const ConsoleCommand* hintCommand_;
94            SubString tokens_;
95            std::string string_;
96            unsigned int execArgumentsOffset_;
97            unsigned int hintArgumentsOffset_;
98            bool bPossibleArgumentsRetrieved_;
99            ArgumentCompletionList possibleArguments_;
100
101            bool bEvaluatedParams_;
102            bool bTriedToEvaluatedParams_;
103            unsigned int numberOfEvaluatedParams_;
104            MultiType param_[MAX_FUNCTOR_ARGUMENTS];
105    };
106}
107
108#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.