1.1 --- a/docs/src/modules.md Tue Jan 23 19:23:34 2018 +0100 1.2 +++ b/docs/src/modules.md Wed May 02 16:14:40 2018 +0200 1.3 @@ -131,6 +131,38 @@ 1.4 This module provides load and store function for `*.properties` files. 1.5 The key/value pairs are stored within an UCX Map. 1.6 1.7 +### Example: Loading properties from a file 1.8 + 1.9 +```C 1.10 +// Open the file as usual 1.11 +FILE* file = fopen("myprops.properties", "r"); 1.12 +if (!file) { 1.13 + // error handling 1.14 + return 1; 1.15 +} 1.16 + 1.17 +// Load the properties from the file 1.18 +UcxMap* myprops = ucx_map_new(16); 1.19 +if (ucx_properties_load(myprops, file)) { 1.20 + // error handling 1.21 + fclose(file); 1.22 + ucx_map_free(myprops); 1.23 + return 1; 1.24 +} 1.25 + 1.26 +// Print out the key/value pairs 1.27 +char* propval; 1.28 +UcxMapIterator propiter = ucx_map_iterator(myprops); 1.29 +UCX_MAP_FOREACH(key, propval, propiter) { 1.30 + printf("%s = %s\n", (char*)key.data, propval); 1.31 +} 1.32 + 1.33 +// Don't forget to free the values before freeing the map 1.34 +ucx_map_free_content(myprops, NULL); 1.35 +ucx_map_free(myprops); 1.36 +fclose(file); 1.37 +``` 1.38 + 1.39 <a name="stack"></a> 1.40 1.41 ## Stack