diff -r 0923c036b913 -r f819fe5e20f5 docs/src/modules.md --- a/docs/src/modules.md Tue Jan 23 19:23:34 2018 +0100 +++ b/docs/src/modules.md Wed May 02 16:14:40 2018 +0200 @@ -131,6 +131,38 @@ This module provides load and store function for `*.properties` files. The key/value pairs are stored within an UCX Map. +### Example: Loading properties from a file + +```C +// Open the file as usual +FILE* file = fopen("myprops.properties", "r"); +if (!file) { + // error handling + return 1; +} + +// Load the properties from the file +UcxMap* myprops = ucx_map_new(16); +if (ucx_properties_load(myprops, file)) { + // error handling + fclose(file); + ucx_map_free(myprops); + return 1; +} + +// Print out the key/value pairs +char* propval; +UcxMapIterator propiter = ucx_map_iterator(myprops); +UCX_MAP_FOREACH(key, propval, propiter) { + printf("%s = %s\n", (char*)key.data, propval); +} + +// Don't forget to free the values before freeing the map +ucx_map_free_content(myprops, NULL); +ucx_map_free(myprops); +fclose(file); +``` + ## Stack