[4838] | 1 | /*! |
---|
[7374] | 2 | * @file shell_completion_plugin.h |
---|
| 3 | * @brief The Shell Completion Plugin |
---|
| 4 | */ |
---|
[1853] | 5 | |
---|
[7374] | 6 | #ifndef _SHELL_COMPLETION_PLUGIN_H |
---|
| 7 | #define _SHELL_COMPLETION_PLUGIN_H |
---|
[1853] | 8 | |
---|
[7374] | 9 | #include <list> |
---|
[7373] | 10 | #include <vector> |
---|
[7225] | 11 | #include <string> |
---|
[5779] | 12 | |
---|
[7374] | 13 | namespace OrxShell |
---|
[7373] | 14 | { |
---|
[7377] | 15 | //! The Base of All Completors |
---|
| 16 | class Completor |
---|
[7374] | 17 | { |
---|
[7377] | 18 | public: |
---|
| 19 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) = 0; |
---|
| 20 | virtual ~Completor() { }; |
---|
[1853] | 21 | |
---|
[7377] | 22 | protected: |
---|
| 23 | Completor(); |
---|
[7374] | 24 | }; |
---|
[7371] | 25 | |
---|
[7377] | 26 | //! Completor that completes static Arrays of Strings. |
---|
| 27 | class CompletorStringArray : public Completor |
---|
[7373] | 28 | { |
---|
[7377] | 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); |
---|
[7374] | 33 | |
---|
[7377] | 34 | private: |
---|
| 35 | const std::string* _stringArray; |
---|
| 36 | unsigned int _size; |
---|
[7371] | 37 | }; |
---|
| 38 | |
---|
[7377] | 39 | //! Completor that completes FileSystem Entries. |
---|
| 40 | class CompletorFileSystem : public Completor |
---|
| 41 | { |
---|
[1853] | 42 | |
---|
[7377] | 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 | |
---|
[7374] | 65 | //! A Templated Completor |
---|
[7377] | 66 | template<typename CLASS> class CompletorTList : public Completor |
---|
[7374] | 67 | { |
---|
[7377] | 68 | public: |
---|
| 69 | CompletorTList(const std::list<CLASS*>& completionList); |
---|
| 70 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) |
---|
| 71 | {}; |
---|
[7374] | 72 | }; |
---|
[7373] | 73 | |
---|
[3245] | 74 | |
---|
[7377] | 75 | |
---|
| 76 | |
---|
| 77 | |
---|
[7374] | 78 | //! A class for Completing the an InputString. |
---|
[7377] | 79 | class CompletionPlugin |
---|
[7374] | 80 | { |
---|
[7377] | 81 | private: |
---|
[5178] | 82 | |
---|
[7377] | 83 | public: |
---|
| 84 | CompletionPlugin(); |
---|
[5178] | 85 | |
---|
[7377] | 86 | |
---|
[7374] | 87 | }; |
---|
[7371] | 88 | |
---|
[7374] | 89 | } |
---|
| 90 | #endif /* _SHELL_COMPLETION_PLUGIN_H */ |
---|