Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ai/src/lib/shell/shell_completion.h @ 10127

Last change on this file since 10127 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.7 KB
Line 
1/*!
2 * @file shell_completion.h
3 * @brief The Shell Completion Tasks
4 *
5 * @todo if the second string is a Command, the third should not be completed!
6 * @todo also make some completion for registered (or special) Types
7*/
8
9#ifndef _SHELL_COMPLETION_H
10#define _SHELL_COMPLETION_H
11
12#include <vector>
13#include <list>
14#include <string>
15
16// FORWARD DECLARATION
17class BaseObject;
18class ObjectListBase;
19
20namespace OrxShell
21{
22  class ShellCommand;
23
24  //! A class for Completing the an InputString.
25  class ShellCompletion
26  {
27      //! an enumerator for different types the Shell can complete.
28      typedef enum {
29        NullCompletion         = 0,
30        ClassCompletion        = 1,
31        ObjectCompletion       = 2,
32        FunctionCompletion     = 4,
33        AliasCompletion        = 8,
34        ParamCompletion        = 16,
35    } CompletionType;
36
37      //! A struct for ShellElements (these are used as containers to identify an Input for what it is)
38      struct CompletionElement
39      {
40        CompletionElement(std::string name, CompletionType type) : name(name), type(type) {}
41        std::string     name;     //!< the Name of the Element to be completed.
42        CompletionType  type;     //!< the type of the Element
43      };
44
45    public:
46      ShellCompletion();
47      virtual ~ShellCompletion();
48
49
50      // Functions to produce the Complete Lists.
51      bool autoComplete(std::string& input);
52
53      static const std::string& typeToString(ShellCompletion::CompletionType type);
54
55    private:
56      bool objectComplete(const std::string& objectBegin, const ObjectListBase* const objectList);
57      bool commandComplete(const std::string& commandBegin, const std::string& className);
58      bool aliasComplete(const std::string& aliasBegin);
59      bool paramComplete(const std::string& paramBegin, const ShellCommand* command, unsigned int paramNumber);
60
61      // Generally Completes.
62      bool generalComplete(std::string& input,
63                           const std::string& begin, const std::string& displayAs = "%s",
64                           const std::string& addBack = "", const std::string& addFront = "");
65
66
67      bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
68      bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
69
70      // Helpers.
71      void clearCompletionList();
72
73    private:
74      std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
75
76      static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
77  };
78
79}
80
81#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.