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 | protected: |
---|
22 | Completor(); |
---|
23 | }; |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | |
---|
28 | //! Completor that completes static Arrays of Strings. |
---|
29 | class CompletorStringArray : public Completor |
---|
30 | { |
---|
31 | public: |
---|
32 | CompletorStringArray(const std::string* stringArray, unsigned int size) |
---|
33 | : _stringArray(stringArray), _size(size) {}; |
---|
34 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); |
---|
35 | |
---|
36 | private: |
---|
37 | const std::string* _stringArray; |
---|
38 | unsigned int _size; |
---|
39 | }; |
---|
40 | |
---|
41 | |
---|
42 | class CompletorList : public Completor |
---|
43 | { |
---|
44 | public: |
---|
45 | CompletorList(const std::list<std::string>* list); |
---|
46 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); |
---|
47 | private: |
---|
48 | const std::list<std::string>* _list; |
---|
49 | }; |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | //! Completor that completes FileSystem Entries. |
---|
54 | class CompletorFileSystem : public Completor |
---|
55 | { |
---|
56 | |
---|
57 | public: |
---|
58 | // Where to search if the completionString is empty. |
---|
59 | typedef enum |
---|
60 | { |
---|
61 | StartAtRoot, |
---|
62 | StartAtHome, |
---|
63 | StartAtDataDir, |
---|
64 | } StartDirectory; |
---|
65 | |
---|
66 | CompletorFileSystem(const std::string& fileExtension = "", |
---|
67 | StartDirectory startDir = StartAtDataDir, |
---|
68 | const std::string& subDir = ""); |
---|
69 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); |
---|
70 | |
---|
71 | private: |
---|
72 | std::string _fileExtension; |
---|
73 | std::string _subDir; |
---|
74 | StartDirectory _startDir; |
---|
75 | }; |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | //! A Templated Completor |
---|
81 | template<typename CLASS> class CompletorTList : public Completor |
---|
82 | { |
---|
83 | public: |
---|
84 | CompletorTList(const std::list<CLASS*>& completionList); |
---|
85 | virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) |
---|
86 | {}; |
---|
87 | }; |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | //! A class for Completing the an InputString. |
---|
94 | class CompletionPlugin |
---|
95 | { |
---|
96 | private: |
---|
97 | |
---|
98 | public: |
---|
99 | CompletionPlugin(); |
---|
100 | |
---|
101 | |
---|
102 | }; |
---|
103 | |
---|
104 | } |
---|
105 | #endif /* _SHELL_COMPLETION_PLUGIN_H */ |
---|