Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: Typenames as std::string better now

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