Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell_completion.h @ 7410

Last change on this file since 7410 was 7406, checked in by bensch, 19 years ago

sync

File size: 2.4 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;
18
19namespace OrxShell
20{
21  //! A class for Completing the an InputString.
22  class ShellCompletion
23  {
24      //! an enumerator for different types the Shell can complete.
25      typedef enum {
26        NullCompletion         = 0,
27        ClassCompletion        = 1,
28        ObjectCompletion       = 2,
29        FunctionCompletion     = 4,
30        AliasCompletion        = 8,
31    } CompletionType;
32
33      //! A struct for ShellElements (these are used as containers to identify an Input for what it is)
34      struct CompletionElement
35      {
36        std::string     name;     //!< the Name of the Element to be completed.
37        CompletionType  type;     //!< the type of the Element
38      };
39
40    public:
41      ShellCompletion();
42      virtual ~ShellCompletion();
43
44
45      // Functions to produce the Complete Lists.
46      bool autoComplete(std::string& input);
47
48      static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type);
49
50    private:
51      bool objectComplete(const std::string& objectBegin, long classID);
52      bool commandComplete(const std::string& commandBegin, const std::string& className);
53      bool aliasComplete(const std::string& aliasBegin);
54
55      // Generally Completes.
56      bool generalComplete(std::string& input,
57                           const std::string& begin, const std::string& displayAs = "%s",
58                           const std::string& addBack = "", const std::string& addFront = "");
59
60
61      bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
62      bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
63
64      // Helpers.
65      void clearCompletionList();
66
67    private:
68      std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
69
70      static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
71  };
72
73}
74
75#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.