diff options
Diffstat (limited to 'meowpp/Usage.h')
-rw-r--r-- | meowpp/Usage.h | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/meowpp/Usage.h b/meowpp/Usage.h index b98a7ac..22f7329 100644 --- a/meowpp/Usage.h +++ b/meowpp/Usage.h @@ -52,7 +52,6 @@ namespace meow{ }; typedef std::map<unsigned char, Option> Options; typedef Options::const_iterator OptionsIterator; - //typedef std::map<unsigned char, Option>::const_iterator OptionsIterator; public: Usage(); Usage(String const& _name); @@ -89,6 +88,68 @@ namespace meow{ Strings usage_end ; Strings proc_arguments; }; + /******************************************************************* + @asciidoc + === meow:: *Usage* (C++ Class) + .Description + `Usage` 是用來分析argc, argv和輸出usage document的class. + argc, argv的部份, 有以下規則 + + * `-c` 其中 `c` 可以代換成正常的一個字元的字符, + 這種選像要嘛就是 *有設置* , 不然就是 *沒設置* + * `-c <value>` 附加一個value, 這種選項可以是選擇性 ,即要設定與否都可以, + 反之則一定要設定. 另外可以給定value的預設值以及哪些value是可接受的 + * `<value>` 其他, 一律視為process arguments + + .Methods + * `Usage(String const& _name)` + + 建構子, 所有說明文字中 *<name>* 都會被代換成 `_name` + * `Usage()` + + 建構子, `_name` 自動取為 " *nobody* " + * `import(Usage const& usage)` + + 將另一個usage的設定匯入, 回傳成功與否 *(bool)* + * `update(Usage const& usage)` + + 將另一個usage分析argc,argv出來的資料拿來用, 回傳成功與否 *(bool)* + * `addOption(unsigned char option, String const& description)` + + 新增一個不接額外選項的參數, 並附上說明文字, 回傳成功與否 *(bool)* + * `addOption(unsigned char option, String const& description, + String const& value_type, String const& value_default, bool must)` + + 新增一個有額外選項的參數, 並附上說明文字, 額外選項的型別跟預設值. + 說明文字中所有的" *<types>* "將會被取代指定的型別, 其中 `must` 代表 + " *是否一定要設定此參數* " , 回傳表成功與否 *(bool)* + * `addOptionValueAccept(unsigned char option, + String const& value, String const& description)` + + 針對某個option, 新增一個可接受的額外選項 (如果某個option從頭到尾都沒有 + 新增可接受的選項, 則視為不限制), 回傳成功與否 *(bool)* + * `hasOptionSetup(unsigned char option)` + + 回傳是否有此選項 *(bool)* + * `getOptionValuesCount(unsigned char option)` + + 回傳此參數被設置了幾次 *(size_t)* , 只對有接額外參數的有效 + * `getOptionValue(unsigned char option, size_t index)` + + 回傳第`index`個額外選項 *(String)* + * `getProcArgsCount()` + + 回傳有多少個Process Arguments *(size_t)* + * `getProcArg(size_t index)` + + 取得第`index`個Process Argument *(String)* + * `getProcArgs()` + + 回傳一個陣列, 包含所有Process Arguments *(Strings)* + * `addUsageBegin(String const& des)` + + 新增一段usage document於每個選項逐條說明之前 + * `addUsageEnd (String const& des)` + + 新增一段usage document於每個選項逐條說明之後 + * `String getUsage()` + + 回傳usage document *(String)* + * `setArguments(int argc, char** argv, String* errmsg)` + + 輸入argv, argc, 回傳是否沒有錯誤發生 *(bool)* , 其中如果有錯誤發生, + 且 `errmsg != NULL` 則會將錯誤訊息寫入之 + +NOTE: `String` 是 `std::string` . + +`Strings` 是 `std::vector< std::string> >`. + +如果沒有寫回傳什麼, 就是回傳 `void` + +''' +@asciidoc- + ******************************************************************/ } #include "Usage.hpp" |