Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.7 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;
[9869]18class ObjectListBase;
[3543]19
[7374]20namespace OrxShell
[7373]21{
[7413]22  class ShellCommand;
23
[7374]24  //! A class for Completing the an InputString.
25  class ShellCompletion
26  {
[7403]27      //! an enumerator for different types the Shell can complete.
28      typedef enum {
29        NullCompletion         = 0,
30        ClassCompletion        = 1,
31        ObjectCompletion       = 2,
32        FunctionCompletion     = 4,
33        AliasCompletion        = 8,
[7412]34        ParamCompletion        = 16,
[7374]35    } CompletionType;
[1853]36
[7403]37      //! A struct for ShellElements (these are used as containers to identify an Input for what it is)
38      struct CompletionElement
39      {
[7412]40        CompletionElement(std::string name, CompletionType type) : name(name), type(type) {}
[7403]41        std::string     name;     //!< the Name of the Element to be completed.
42        CompletionType  type;     //!< the type of the Element
43      };
[7371]44
[7403]45    public:
46      ShellCompletion();
47      virtual ~ShellCompletion();
[7371]48
[1853]49
[7403]50      // Functions to produce the Complete Lists.
51      bool autoComplete(std::string& input);
[7373]52
[9869]53      static const std::string& typeToString(ShellCompletion::CompletionType type);
[3245]54
[7403]55    private:
[9869]56      bool objectComplete(const std::string& objectBegin, const ObjectListBase* const objectList);
[7403]57      bool commandComplete(const std::string& commandBegin, const std::string& className);
58      bool aliasComplete(const std::string& aliasBegin);
[7415]59      bool paramComplete(const std::string& paramBegin, const ShellCommand* command, unsigned int paramNumber);
[5178]60
[7403]61      // Generally Completes.
62      bool generalComplete(std::string& input,
63                           const std::string& begin, const std::string& displayAs = "%s",
64                           const std::string& addBack = "", const std::string& addFront = "");
[7388]65
[5178]66
[7403]67      bool addToCompleteList(const std::list<std::string>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
68      bool addToCompleteList(const std::list<BaseObject*>& inputList, const std::string& completionBegin, ShellCompletion::CompletionType type);
[7373]69
[7403]70      // Helpers.
71      void clearCompletionList();
[5245]72
[7403]73    private:
74      std::vector<CompletionElement>  completionList;          //!< A list of completions, that are io.
75
76      static const std::string        typeNames[];             //!< A list of Completion-Type-Names.
[7374]77  };
[7372]78
[7374]79}
[1853]80
[5170]81#endif /* _SHELL_COMPLETION_H */
Note: See TracBrowser for help on using the repository browser.