| 1 | /*! |
|---|
| 2 | * @file shell_completion_plugin.h |
|---|
| 3 | * @brief The Shell Completion Plugin |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _SHELL_COMPLETION_PLUGIN_H |
|---|
| 7 | #define _SHELL_COMPLETION_PLUGIN_H |
|---|
| 8 | |
|---|
| 9 | #include <list> |
|---|
| 10 | #include <vector> |
|---|
| 11 | #include <string> |
|---|
| 12 | |
|---|
| 13 | namespace OrxShell |
|---|
| 14 | { |
|---|
| 15 | //! The Base of All Completors |
|---|
| 16 | class Completor |
|---|
| 17 | { |
|---|
| 18 | public: |
|---|
| 19 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) = 0; |
|---|
| 20 | virtual ~Completor() { }; |
|---|
| 21 | |
|---|
| 22 | protected: |
|---|
| 23 | Completor(); |
|---|
| 24 | }; |
|---|
| 25 | |
|---|
| 26 | //! Completor that completes static Arrays of Strings. |
|---|
| 27 | class CompletorStringArray : public Completor |
|---|
| 28 | { |
|---|
| 29 | public: |
|---|
| 30 | CompletorStringArray(const std::string* stringArray, unsigned int size) |
|---|
| 31 | : _stringArray(stringArray), _size(size) {}; |
|---|
| 32 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); |
|---|
| 33 | |
|---|
| 34 | private: |
|---|
| 35 | const std::string* _stringArray; |
|---|
| 36 | unsigned int _size; |
|---|
| 37 | }; |
|---|
| 38 | |
|---|
| 39 | //! Completor that completes FileSystem Entries. |
|---|
| 40 | class CompletorFileSystem : public Completor |
|---|
| 41 | { |
|---|
| 42 | |
|---|
| 43 | public: |
|---|
| 44 | // Where to search if the completionString is empty. |
|---|
| 45 | typedef enum |
|---|
| 46 | { |
|---|
| 47 | StartAtRoot, |
|---|
| 48 | StartAtHome, |
|---|
| 49 | StartAtDataDir, |
|---|
| 50 | } StartDirectory; |
|---|
| 51 | |
|---|
| 52 | CompletorFileSystem(const std::string& fileExtension = "", |
|---|
| 53 | StartDirectory startDir = StartAtDataDir, |
|---|
| 54 | const std::string& subDir = ""); |
|---|
| 55 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); |
|---|
| 56 | |
|---|
| 57 | private: |
|---|
| 58 | std::string _fileExtension; |
|---|
| 59 | std::string _subDir; |
|---|
| 60 | StartDirectory _startDir; |
|---|
| 61 | |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | //! A Templated Completor |
|---|
| 66 | template<typename CLASS> class CompletorTList : public Completor |
|---|
| 67 | { |
|---|
| 68 | public: |
|---|
| 69 | CompletorTList(const std::list<CLASS*>& completionList); |
|---|
| 70 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) |
|---|
| 71 | {}; |
|---|
| 72 | }; |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | //! A class for Completing the an InputString. |
|---|
| 79 | class CompletionPlugin |
|---|
| 80 | { |
|---|
| 81 | private: |
|---|
| 82 | |
|---|
| 83 | public: |
|---|
| 84 | CompletionPlugin(); |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | } |
|---|
| 90 | #endif /* _SHELL_COMPLETION_PLUGIN_H */ |
|---|