Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7235 was 7235, checked in by landauf, 14 years ago
  • fixed error if a command doesn't exist not being shown while using auto-completion
  • fixed error if a command doesn't exist not being redirected to sub-command auto-completion
  • fixed unneeded line-breaks in auto-completion list
  • Property svn:eol-style set to native
File size: 3.3 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            size_t getPossibleArgumentsSize() const
71                { return CommandEvaluation::getSize(this->possibleArguments_); }
72
73        private:
74            void initialize(const std::string& command);
75
76            unsigned int getNumberOfArguments() const;
77            const std::string& getLastArgument() const;
78            const std::string& getToken(unsigned int i) const;
79
80            void retrievePossibleArguments();
81
82            static void strip(ArgumentCompletionList& list, const std::string& fragment);
83            static size_t getSize(const ArgumentCompletionList& list);
84
85            static std::string dump(const ArgumentCompletionList& list);
86            static std::string dump(const _ConsoleCommand* command);
87
88            static std::string getCommonBegin(const ArgumentCompletionList& list);
89
90            _ConsoleCommand* execCommand_;
91            _ConsoleCommand* hintCommand_;
92            SubString tokens_;
93            std::string string_;
94            unsigned int execArgumentsOffset_;
95            unsigned int hintArgumentsOffset_;
96            bool bPossibleArgumentsRetrieved_;
97            ArgumentCompletionList possibleArguments_;
98
99            bool bEvaluatedParams_;
100            bool bTriedToEvaluatedParams_;
101            unsigned int numberOfEvaluatedParams_;
102            MultiType param_[MAX_FUNCTOR_ARGUMENTS];
103    };
104}
105
106#endif /* _CommandEvaluation_H__ */
Note: See TracBrowser for help on using the repository browser.