# HG changeset patch # User Mike Becker # Date 1526129409 -7200 # Node ID fffe3a16a3de5a933dfcaf104e83f1124c94c24f # Parent ba760f2195c3568f20ee4a095c424ea329b21861 adds a code sample for UcxMap diff -r ba760f2195c3 -r fffe3a16a3de docs/src/modules.md --- a/docs/src/modules.md Sat May 12 14:13:53 2018 +0200 +++ b/docs/src/modules.md Sat May 12 14:50:09 2018 +0200 @@ -279,6 +279,70 @@ chaining with linked lists. Similarly to the list module, we provide a `UCX_MAP_FOREACH` macro to conveniently iterate through the key/value pairs. +### Parsing command line options + +Assume you want to parse command line options and record them within a map. +One way to do this is shown by the following code sample: +```C + UcxMap* options = ucx_map_new(16); + const char *NOARG = ""; + + char *option = NULL; + char optchar = 0; + for(int i=1;i 1 && arg[0] == '-') { + if(option) { + fprintf(stderr, + "Missing argument for option -%c\n", optchar); + return 1; + } + for(int c=1;c