Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/cd/src/lib/shell/shell_completion.h @ 7568

Last change on this file since 7568 was 7343, checked in by bensch, 19 years ago

oroxnox/trunk: ShellInput and ShellCompletion more c++-like

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//! an enumerator for different types the Shell can complete.
23typedef enum {
24  SHELLC_NONE        = 0,
25  SHELLC_CLASS       = 1,
26  SHELLC_OBJECT      = 2,
27  SHELLC_FUNCTION    = 4,
28  SHELLC_ALIAS       = 8,
29} SHELLC_TYPE;
30
31//! A struct for ShellElements (these are used as containers to identify an Input for what it is)
32struct ShellC_Element{
33  std::string     name;     //!< the Name of the Element to be completed.
34  SHELLC_TYPE     type;     //!< the type of the Element
35};
36
37//! A class for ...
38class ShellCompletion {
39
40 public:
41  ShellCompletion();
42  virtual ~ShellCompletion();
43
44  bool autoComplete(std::string& input);
45  bool classComplete(const std::string& classBegin);
46//  long classMatch(const char* input, unsigned int* length);
47  bool objectComplete(const std::string& objectBegin, long classID);
48//  bool objectMatch(const char* objectBegin, long classID, unsigned int* length);
49  bool functionComplete(const std::string& functionBegin, const std::string& className);
50//  bool functionMatch(const char* functionBegin, long classID, unsigned int* length);
51  bool aliasComplete(const std::string& aliasBegin);
52
53  bool generalComplete(std::string& input,
54                       const std::string& begin, const std::string& displayAs = "%s",
55                       const std::string& addBack = "", const std::string& addFront = "");
56
57  bool addToCompleteList(const std::list<std::string>* inputList, const std::string& completionBegin, SHELLC_TYPE type);
58  bool addToCompleteList(const std::list<BaseObject*>* inputList, const std::string& completionBegin, SHELLC_TYPE type);
59  void emptyCompletionList();
60
61  static const char* ShellCompletion::typeToString(SHELLC_TYPE type);
62
63 private:
64   std::list<ShellC_Element>    completionList;          //!< A list of completions, that are io.
65};
66
67#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.