Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7233 was 7233, checked in by landauf, 14 years ago
  • console commands "setMMSoundPath" and "printObjects" are now hidden.
  • added "unhide" command to show hidden commands
  • extended auto-completion capability by allowing multi-word ArgumentCompleter and more
  • added new auto-completion function that allows other commands as argument for a command (for example "delay [time] [command]")
  • Property svn:eol-style set to native
File size: 3.2 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            const ArgumentCompletionList& getPossibleArguments() const
68                { return this->possibleArguments_; }
69
70        private:
71            void initialize(const std::string& command);
72
73            unsigned int getNumberOfArguments() const;
74            const std::string& getLastArgument() const;
75            const std::string& getToken(unsigned int i) const;
76
77            void retrievePossibleArguments();
78
79            static void strip(ArgumentCompletionList& list, const std::string& fragment);
80            static size_t getSize(const ArgumentCompletionList& list);
81
82            static std::string dump(const ArgumentCompletionList& list);
83            static std::string dump(const _ConsoleCommand* command);
84
85            static std::string getCommonBegin(const ArgumentCompletionList& list);
86
87            _ConsoleCommand* execCommand_;
88            _ConsoleCommand* hintCommand_;
89            SubString tokens_;
90            std::string string_;
91            unsigned int execArgumentsOffset_;
92            unsigned int hintArgumentsOffset_;
93            bool bPossibleArgumentsRetrieved_;
94            ArgumentCompletionList possibleArguments_;
95
96            bool bEvaluatedParams_;
97            bool bTriedToEvaluatedParams_;
98            unsigned int numberOfEvaluatedParams_;
99            MultiType param_[MAX_FUNCTOR_ARGUMENTS];
100    };
101}
102
103#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.