Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: better completion-algos

File size: 2.2 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    SHELLC_NONE        = 0,
29    SHELLC_CLASS       = 1,
30    SHELLC_OBJECT      = 2,
31    SHELLC_FUNCTION    = 4,
32    SHELLC_ALIAS       = 8,
33  } SHELLC_TYPE;
34
35//! A struct for ShellElements (these are used as containers to identify an Input for what it is)
36  struct ShellC_Element{
37    std::string     name;     //!< the Name of the Element to be completed.
38    SHELLC_TYPE     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, SHELLC_TYPE type);
60  bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, SHELLC_TYPE type);
61  void clearCompletionList();
62
63  static const char* ShellCompletion::typeToString(SHELLC_TYPE type);
64
65 private:
66   std::list<ShellC_Element>    completionList;          //!< A list of completions, that are io.
67};
68
69#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.