Changeset 7374 in orxonox.OLD for trunk/src/lib/shell/shell_completion_plugin.h
- Timestamp:
- Apr 26, 2006, 3:28:55 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/shell/shell_completion_plugin.h
r7373 r7374 1 1 /*! 2 * @file shell_completion.h 3 * @brief The Shell Completion Tasks 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 7 */ 2 * @file shell_completion_plugin.h 3 * @brief The Shell Completion Plugin 4 */ 8 5 9 #ifndef _SHELL_COMPLETION_ H10 #define _SHELL_COMPLETION_ H6 #ifndef _SHELL_COMPLETION_PLUGIN_H 7 #define _SHELL_COMPLETION_PLUGIN_H 11 8 9 #include <list> 12 10 #include <vector> 13 #include <list>14 11 #include <string> 15 12 16 // FORWARD DECLARATION 17 class BaseObject; 18 class ShellInput; 19 #ifndef NULL 20 #define NULL 0 //!< a pointer to NULL 21 #endif 13 namespace OrxShell 14 { 15 class ShellCompletor 16 { 17 public: 18 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) = 0; 19 virtual ~ShellCompletor() { }; 20 21 protected: 22 ShellCompletor(); 23 }; 24 25 class ShellCompletorStringArray : public ShellCompletor 26 { 27 public: 28 ShellCompletorStringArray(const std::string* stringArray, unsigned int size) 29 : _stringArray(stringArray), _size(size) {}; 30 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin); 31 32 private: 33 const std::string* _stringArray; 34 unsigned int _size; 35 }; 22 36 23 37 24 //! A class for Completing the an InputString. 25 class ShellCompletion 26 { 27 28 //! an enumerator for different types the Shell can complete. 29 typedef enum { 30 NullCompletion = 0, 31 ClassCompletion = 1, 32 ObjectCompletion = 2, 33 FunctionCompletion = 4, 34 AliasCompletion = 8, 35 } CompletionType; 36 37 //! A struct for ShellElements (these are used as containers to identify an Input for what it is) 38 struct CompletionElement 38 //! A Templated Completor 39 template<typename CLASS> class ShellCompletorTList : public ShellCompletor 39 40 { 40 std::string name; //!< the Name of the Element to be completed. 41 CompletionType type; //!< the type of the Element 41 public: 42 ShellCompletorTList(const std::list<CLASS*>& completionList); 43 virtual void addToCompleteList(std::vector<std::string>& completionList, const std::string& completionBegin) 44 {}; 42 45 }; 43 46 44 public: 45 ShellCompletion(); 46 virtual ~ShellCompletion(); 47 48 //! A class for Completing the an InputString. 49 class ShellCompletionPlugin 50 { 51 public: 52 ShellCompletionPlugin(); 47 53 48 54 49 // Functions to produce the Complete Lists. 50 bool autoComplete(std::string& input); 51 bool classComplete(const std::string& classBegin); 52 // long classMatch(const char* input, unsigned int* length); 53 bool objectComplete(const std::string& objectBegin, long classID); 54 // bool objectMatch(const char* objectBegin, long classID, unsigned int* length); 55 bool functionComplete(const std::string& functionBegin, const std::string& className); 56 // bool functionMatch(const char* functionBegin, long classID, unsigned int* length); 57 bool aliasComplete(const std::string& aliasBegin); 55 }; 58 56 59 bool generalComplete(std::string& input, 60 const std::string& begin, const std::string& displayAs = "%s", 61 const std::string& addBack = "", const std::string& addFront = ""); 62 63 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); 66 void clearCompletionList(); 67 68 69 // Helpers. 70 static const std::string& ShellCompletion::typeToString(ShellCompletion::CompletionType type); 71 72 private: 73 std::vector<CompletionElement> completionList; //!< A list of completions, that are io. 74 75 static const std::string typeNames[]; //!< A list of Completion-Type-Names. 76 }; 77 78 #endif /* _SHELL_COMPLETION_H */ 57 } 58 #endif /* _SHELL_COMPLETION_PLUGIN_H */
Note: See TracChangeset
for help on using the changeset viewer.