Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| arguments [05.01.2006 13:27 (vor 21 Jahren)] – cwacha | arguments [16.11.2016 23:18 (vor 10 Jahren)] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
|---|---|---|---|
| Zeile 14: | Zeile 14: | ||
| * flags | * flags | ||
| * internal storage realised as STL vector | * internal storage realised as STL vector | ||
| + | * %%-flag --long-option-flag%% | ||
| + | * %%-option 5 --long-option-text 5%% | ||
| + | |||
| + | == Remarks == | ||
| + | * you cannot unset a flag with something like -flag 0. You will have to test for another flag i.e. -notflag. | ||
| + | * -option=5 will not be recognized. There is no internal splitter. | ||
| + | * every option takes exactly 1 argument. | ||
| + | |||
| === Download === | === Download === | ||
| + | * {{projects: | ||
| * {{projects: | * {{projects: | ||
| * {{projects: | * {{projects: | ||
| Zeile 41: | Zeile 50: | ||
| // !! argument list !! | // !! argument list !! | ||
| - | // Format: | + | // Format: |
| - | // | + | // |
| - | int my_int = a.getInt(" | + | int my_int = a.get(" |
| - | int my_int2 = a.getInt(" | + | double |
| + | string test = a.get< | ||
| bool show_help = a.getFlag(" | bool show_help = a.getFlag(" | ||
| - | // if you are interested | + | // if you are interested a supplied filename you can use front() |
| // or back() to pop the first or last element | // or back() to pop the first or last element | ||
| string filename = a.back(); | string filename = a.back(); | ||
| Zeile 63: | Zeile 73: | ||
| //now do your stuff | //now do your stuff | ||
| - | cout << " | + | cout << " |
| - | + | ||
| return 0; | return 0; | ||
| } | } | ||
| + | |||
| </ | </ | ||
| Zeile 84: | Zeile 95: | ||
| // returns true if flag is found, false else | // returns true if flag is found, false else | ||
| bool getFlag(const std:: | bool getFlag(const std:: | ||
| - | // returns | + | // returns |
| - | int getInt(const std:: | + | // Remark: does NOT work with char*. Use string |
| - | // returns double if found, supplied default_value | + | template< |
| - | double getDouble(const std:: | + | |
| - | // returns string if found, supplied default_value else | + | |
| - | std:: | + | |
| - | // returns char* to a C string if found, | + | |
| - | // Remark that you will have to free() the returned string once you don't need it anymore! | + | |
| - | char* getCString(const std:: | + | |
| - | + | ||
| // return first element | // return first element | ||
| std:: | std:: | ||
| Zeile 105: | Zeile 110: | ||
| </ | </ | ||
| + | |||
| + | === License === | ||
| + | |||
| + | < | ||
| + | |||
| + | <!-- Creative Commons License --> | ||
| + | <a href=" | ||
| + | <img alt=" | ||
| + | / | ||
| + | This software is licensed under the <a href=" | ||
| + | <!-- /Creative Commons License --> | ||
| + | |||
| + | <!-- | ||
| + | |||
| + | <rdf:RDF xmlns=" | ||
| + | xmlns: | ||
| + | xmlns: | ||
| + | <Work rdf: | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <License rdf: | ||
| + | <permits rdf: | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | --> | ||
| + | |||
| + | </ | ||