docs/src/modules.md

changeset 277
f819fe5e20f5
parent 267
f4789572c9d6
child 279
ee37b179e597
equal deleted inserted replaced
274:0923c036b913 277:f819fe5e20f5
129 *Required modules:* [Map](#map) 129 *Required modules:* [Map](#map)
130 130
131 This module provides load and store function for `*.properties` files. 131 This module provides load and store function for `*.properties` files.
132 The key/value pairs are stored within an UCX Map. 132 The key/value pairs are stored within an UCX Map.
133 133
134 ### Example: Loading properties from a file
135
136 ```C
137 // Open the file as usual
138 FILE* file = fopen("myprops.properties", "r");
139 if (!file) {
140 // error handling
141 return 1;
142 }
143
144 // Load the properties from the file
145 UcxMap* myprops = ucx_map_new(16);
146 if (ucx_properties_load(myprops, file)) {
147 // error handling
148 fclose(file);
149 ucx_map_free(myprops);
150 return 1;
151 }
152
153 // Print out the key/value pairs
154 char* propval;
155 UcxMapIterator propiter = ucx_map_iterator(myprops);
156 UCX_MAP_FOREACH(key, propval, propiter) {
157 printf("%s = %s\n", (char*)key.data, propval);
158 }
159
160 // Don't forget to free the values before freeing the map
161 ucx_map_free_content(myprops, NULL);
162 ucx_map_free(myprops);
163 fclose(file);
164 ```
165
134 <a name="stack"></a> 166 <a name="stack"></a>
135 167
136 ## Stack 168 ## Stack
137 169
138 *Header file:* [stack.h](api/stack_8h.html) 170 *Header file:* [stack.h](api/stack_8h.html)

mercurial