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