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, 20 years ago

orxonox/trunk: list to vector

File size: 2.6 KB
RevLine 
[4838]1/*!
[5170]2 * @file shell_completion.h
3 * @brief The Shell Completion Tasks
[5371]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
[3245]7*/
[1853]8
[5170]9#ifndef _SHELL_COMPLETION_H
10#define _SHELL_COMPLETION_H
[1853]11
[7373]12#include <vector>
[5779]13#include <list>
[7225]14#include <string>
[5779]15
[4838]16// FORWARD DECLARATION
[5178]17class BaseObject;
[5181]18class ShellInput;
[5178]19#ifndef NULL
20#define NULL 0            //!< a pointer to NULL
21#endif
[3543]22
[5187]23
[7373]24//! A class for Completing the an InputString.
25class ShellCompletion
26{
[1853]27
[7371]28  //! an enumerator for different types the Shell can complete.
29  typedef enum {
[7372]30    NullCompletion         = 0,
31    ClassCompletion        = 1,
32    ObjectCompletion       = 2,
33    FunctionCompletion     = 4,
34    AliasCompletion        = 8,
35  } CompletionType;
[7371]36
[7373]37  //! A struct for ShellElements (these are used as containers to identify an Input for what it is)
38  struct CompletionElement
39  {
[7371]40    std::string     name;     //!< the Name of the Element to be completed.
[7372]41    CompletionType type;     //!< the type of the Element
[7371]42  };
43
[7373]44public:
[7343]45  ShellCompletion();
[5170]46  virtual ~ShellCompletion();
[1853]47
[7373]48
49  // Functions to produce the Complete Lists.
[7343]50  bool autoComplete(std::string& input);
[7225]51  bool classComplete(const std::string& classBegin);
[7373]52  //  long classMatch(const char* input, unsigned int* length);
[7225]53  bool objectComplete(const std::string& objectBegin, long classID);
[7373]54  //  bool objectMatch(const char* objectBegin, long classID, unsigned int* length);
[7225]55  bool functionComplete(const std::string& functionBegin, const std::string& className);
[7373]56  //  bool functionMatch(const char* functionBegin, long classID, unsigned int* length);
[7225]57  bool aliasComplete(const std::string& aliasBegin);
[3245]58
[7343]59  bool generalComplete(std::string& input,
60                       const std::string& begin, const std::string& displayAs = "%s",
[7225]61                       const std::string& addBack = "", const std::string& addFront = "");
[5178]62
63
[7372]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);
[7371]66  void clearCompletionList();
67
[7373]68
69  // Helpers.
[7372]70  static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type);
[5245]71
[7373]72private:
73  std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
[7372]74
[7373]75  static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
[1853]76};
77
[5170]78#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.