| 338 |
338 |
| 339 /** |
339 /** |
| 340 * Internal function - use cxPropertiesLoad() instead. |
340 * Internal function - use cxPropertiesLoad() instead. |
| 341 * |
341 * |
| 342 * @param config the parser config |
342 * @param config the parser config |
| |
343 * @param allocator the allocator for the values |
| 343 * @param filename the file name |
344 * @param filename the file name |
| 344 * @param target the target map |
345 * @param target the target map |
| 345 * @return status code |
346 * @return status code |
| 346 */ |
347 */ |
| 347 cx_attr_nonnull |
348 cx_attr_nonnull_arg(4) |
| 348 CX_EXPORT CxPropertiesStatus cx_properties_load(CxPropertiesConfig config, |
349 CX_EXPORT CxPropertiesStatus cx_properties_load(CxPropertiesConfig config, |
| 349 cxstring filename, CxMap *target); |
350 const CxAllocator *allocator, cxstring filename, CxMap *target); |
| 350 |
351 |
| 351 /** |
352 /** |
| 352 * Loads properties from a file and inserts them into a map. |
353 * Loads properties from a file and inserts them into a map. |
| 353 * |
354 * |
| 354 * Entries are added to the map, possibly overwriting existing entries. |
355 * Entries are added to the map, possibly overwriting existing entries. |
| 355 * |
356 * |
| 356 * The map must either store pointers of type @c char*, or elements of type cxmutstr. |
357 * The map must either store pointers of type @c char*, or elements of type cxmutstr. |
| 357 * Any other configuration is not supported. |
358 * Any other configuration is not supported. |
| 358 * |
359 * |
| 359 * @param config the parser config |
360 * @param config the parser config |
| |
361 * @param allocator the allocator for the values that will be stored in the map |
| 360 * @param filename (any string) the absolute or relative path to the file |
362 * @param filename (any string) the absolute or relative path to the file |
| 361 * @param target (@c CxMap*) the map where the properties shall be added |
363 * @param target (@c CxMap*) the map where the properties shall be added |
| 362 * @retval CX_PROPERTIES_NO_ERROR (zero) at least one key/value pair was found |
364 * @retval CX_PROPERTIES_NO_ERROR (zero) at least one key/value pair was found |
| 363 * @retval CX_PROPERTIES_NO_DATA the file is syntactically OK, but does not contain properties |
365 * @retval CX_PROPERTIES_NO_DATA the file is syntactically OK, but does not contain properties |
| 364 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file |
366 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file |
| 367 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
369 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
| 368 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set |
370 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set |
| 369 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed |
371 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed |
| 370 * @see cxPropertiesLoadDefault() |
372 * @see cxPropertiesLoadDefault() |
| 371 */ |
373 */ |
| 372 #define cxPropertiesLoad(config, filename, target) cx_properties_load(config, cx_strcast(filename), target) |
374 #define cxPropertiesLoad(config, allocator, filename, target) \ |
| |
375 cx_properties_load(config, allocator, cx_strcast(filename), target) |
| 373 |
376 |
| 374 /** |
377 /** |
| 375 * Loads properties from a file and inserts them into a map with a default config. |
378 * Loads properties from a file and inserts them into a map with a default config. |
| 376 * |
379 * |
| 377 * Entries are added to the map, possibly overwriting existing entries. |
380 * Entries are added to the map, possibly overwriting existing entries. |
| 378 * |
381 * |
| 379 * The map must either store pointers of type @c char*, or elements of type cxmutstr. |
382 * The map must either store pointers of type @c char*, or elements of type cxmutstr. |
| 380 * Any other configuration is not supported. |
383 * Any other configuration is not supported. |
| 381 * |
384 * |
| |
385 * @param allocator the allocator for the values that will be stored in the map |
| 382 * @param filename (any string) the absolute or relative path to the file |
386 * @param filename (any string) the absolute or relative path to the file |
| 383 * @param target (@c CxMap*) the map where the properties shall be added |
387 * @param target (@c CxMap*) the map where the properties shall be added |
| 384 * @retval CX_PROPERTIES_NO_ERROR (zero) at least one key/value pair was found |
388 * @retval CX_PROPERTIES_NO_ERROR (zero) at least one key/value pair was found |
| 385 * @retval CX_PROPERTIES_NO_DATA the file is syntactically OK, but does not contain properties |
389 * @retval CX_PROPERTIES_NO_DATA the file is syntactically OK, but does not contain properties |
| 386 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file |
390 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file |
| 389 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
393 * @retval CX_PROPERTIES_BUFFER_ALLOC_FAILED an internal allocation was necessary but failed |
| 390 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set |
394 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set |
| 391 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed |
395 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed |
| 392 * @see cxPropertiesLoad() |
396 * @see cxPropertiesLoad() |
| 393 */ |
397 */ |
| 394 #define cxPropertiesLoadDefault(filename, target) cx_properties_load(cx_properties_config_default, cx_strcast(filename), target) |
398 #define cxPropertiesLoadDefault(allocator, filename, target) \ |
| |
399 cx_properties_load(cx_properties_config_default, allocator, cx_strcast(filename), target) |
| 395 |
400 |
| 396 |
401 |
| 397 #ifdef __cplusplus |
402 #ifdef __cplusplus |
| 398 } // extern "C" |
403 } // extern "C" |
| 399 #endif |
404 #endif |