- Timestamp:
- Sep 4, 2010, 11:33:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/doc/src/libraries/core/command/ArgumentCompleter.h
r7284 r7352 27 27 */ 28 28 29 /** 30 @defgroup ArgumentCompletion Argument completion 31 @ingroup Command 32 */ 33 34 /** 35 @file 36 @ingroup Command ArgumentCompletion 37 @brief Definition of the orxonox::ArgumentCompleter class that is used to execute @ref ArgumentCompletionFunctions.h "argument completion functions". 38 39 An ArgumentCompleter can be assigned to an orxonox::ConsoleCommand using 40 @ref orxonox::ConsoleCommand::argumentCompleter "argumentCompleter()". 41 The ArgumentCompleter calls an argument completion function that is defined 42 in ArgumentCompletionFunctions.h. This can be used to list possible arguments 43 for console commands and to allow auto-completion. 44 45 Instances of ArgumentCompleter are usually not created manually but rather 46 by the macros defined in ArgumentCompletionFunctions.h. There you'll also 47 find some examples. 48 49 @see See the @ref ArgumentCompletionExample "examples". 50 */ 51 29 52 #ifndef _ArgumentCompleter_H__ 30 53 #define _ArgumentCompleter_H__ … … 35 58 namespace orxonox 36 59 { 60 /** 61 @brief This class executes an argument completion function and returns a list of the possible arguments. 62 63 ArgumentCompleter is used to wrap argument completion functions as defined 64 in ArgumentCompletionFunctions.h and can be assigned to a ConsoleCommand to 65 create a list of possible arguments. 66 67 @see See ArgumentCompleter.h for more information. 68 @see See @ref ArgumentCompletionExample "ArgumentCompletionFunctions.h" for an example. 69 */ 37 70 class _CoreExport ArgumentCompleter 38 71 { 39 72 public: 40 ArgumentCompleter(ArgumentCompletionList (*function) (void), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(0), function_0_(function) {} 41 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(1), function_1_(function) {} 42 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(2), function_2_(function) {} 43 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(3), function_3_(function) {} 44 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(4), function_4_(function) {} 45 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(5), function_5_(function) {} 73 ArgumentCompleter(ArgumentCompletionList (*function) (void), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(0), function_0_(function) {} ///< Constructor, assigns a function-pointer with no arguments. 74 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(1), function_1_(function) {} ///< Constructor, assigns a function-pointer with one argument. 75 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(2), function_2_(function) {} ///< Constructor, assigns a function-pointer with two arguments. 76 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(3), function_3_(function) {} ///< Constructor, assigns a function-pointer with three arguments. 77 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(4), function_4_(function) {} ///< Constructor, assigns a function-pointer with four arguments. 78 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5), bool bUseMultipleWords) : bUseMultipleWords_(bUseMultipleWords), paramCount_(5), function_5_(function) {} ///< Constructor, assigns a function-pointer with five arguments. 46 79 80 /** 81 @brief Calls the argument completion function with a maximum of five parameters. 82 @return Returns the list of possible arguments, created by the argument completion function 83 */ 47 84 ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "") 48 85 { … … 66 103 } 67 104 105 /// Returns true if the argument completion list supports multiple words. 68 106 inline bool useMultipleWords() const 69 107 { return this->bUseMultipleWords_; } 70 108 71 109 private: 72 bool bUseMultipleWords_; 73 unsigned char paramCount_; 74 ArgumentCompletionList (*function_0_) (void); 75 ArgumentCompletionList (*function_1_) (const std::string& param1); 76 ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2); 77 ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3); 78 ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4); 79 ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5); 110 bool bUseMultipleWords_; ///< If true, the argument completion list supports multiple words 111 unsigned char paramCount_; ///< The number of parameters of the argument completion function 112 ArgumentCompletionList (*function_0_) (void); ///< Function-pointer for an argument completion function with no arguments 113 ArgumentCompletionList (*function_1_) (const std::string& param1); ///< Function-pointer for an argument completion function with one argument 114 ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2); ///< Function-pointer for an argument completion function with two arguments 115 ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3); ///< Function-pointer for an argument completion function with three arguments 116 ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4); ///< Function-pointer for an argument completion function with four arguments 117 ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5); ///< Function-pointer for an argument completion function with five arguments 80 118 }; 81 119 }
Note: See TracChangeset
for help on using the changeset viewer.