Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: list to vector

File size: 2.6 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 ShellInput;
19#ifndef NULL
20#define NULL 0            //!< a pointer to NULL
21#endif
22
23
24//! A class for Completing the an InputString.
25class ShellCompletion
26{
27
28  //! an enumerator for different types the Shell can complete.
29  typedef enum {
30    NullCompletion         = 0,
31    ClassCompletion        = 1,
32    ObjectCompletion       = 2,
33    FunctionCompletion     = 4,
34    AliasCompletion        = 8,
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    std::string     name;     //!< the Name of the Element to be completed.
41    CompletionType type;     //!< the type of the Element
42  };
43
44public:
45  ShellCompletion();
46  virtual ~ShellCompletion();
47
48
49  // Functions to produce the Complete Lists.
50  bool autoComplete(std::string& input);
51  bool classComplete(const std::string& classBegin);
52  //  long classMatch(const char* input, unsigned int* length);
53  bool objectComplete(const std::string& objectBegin, long classID);
54  //  bool objectMatch(const char* objectBegin, long classID, unsigned int* length);
55  bool functionComplete(const std::string& functionBegin, const std::string& className);
56  //  bool functionMatch(const char* functionBegin, long classID, unsigned int* length);
57  bool aliasComplete(const std::string& aliasBegin);
58
59  bool generalComplete(std::string& input,
60                       const std::string& begin, const std::string& displayAs = "%s",
61                       const std::string& addBack = "", const std::string& addFront = "");
62
63
64  bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
65  bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
66  void clearCompletionList();
67
68
69  // Helpers.
70  static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type);
71
72private:
73  std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
74
75  static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
76};
77
78#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.