ucx/cx/properties.h

changeset 1016
ccde46662db7
parent 992
f421aef8f865
equal deleted inserted replaced
1015:b459361d98ad 1016:ccde46662db7
71 * The third comment character. 71 * The third comment character.
72 * This is not set by default. 72 * This is not set by default.
73 */ 73 */
74 char comment3; 74 char comment3;
75 75
76 /* 76 /**
77 * The character, when appearing at the end of a line, continues that line. 77 * The character, when appearing at the end of a line, continues that line.
78 * This is '\' by default. 78 * This is '\' by default.
79 */ 79 */
80 char continuation; 80 char continuation;
81 }; 81 };
334 CX_EXPORT extern const unsigned cx_properties_load_fill_size; 334 CX_EXPORT extern const unsigned cx_properties_load_fill_size;
335 335
336 /** 336 /**
337 * Internal function - use cxPropertiesLoad() instead. 337 * Internal function - use cxPropertiesLoad() instead.
338 * 338 *
339 * @param config the parser config
340 * @param allocator the allocator for the values 339 * @param allocator the allocator for the values
341 * @param filename the file name 340 * @param filename the file name
342 * @param target the target map 341 * @param target the target map
342 * @param config the parser config
343 * @return status code 343 * @return status code
344 */ 344 */
345 cx_attr_nonnull_arg(4) 345 cx_attr_nonnull_arg(3)
346 CX_EXPORT CxPropertiesStatus cx_properties_load(CxPropertiesConfig config, 346 CX_EXPORT CxPropertiesStatus cx_properties_load(const CxAllocator *allocator,
347 const CxAllocator *allocator, cxstring filename, CxMap *target); 347 cxstring filename, CxMap *target, CxPropertiesConfig config);
348 348
349 /** 349 /**
350 * Loads properties from a file and inserts them into a map. 350 * Loads properties from a file and inserts them into a map.
351 * 351 *
352 * Entries are added to the map, possibly overwriting existing entries. 352 * Entries are added to the map, possibly overwriting existing entries.
355 * Any other configuration is not supported. 355 * Any other configuration is not supported.
356 * 356 *
357 * @note When the parser finds an error, all successfully parsed keys before the error 357 * @note When the parser finds an error, all successfully parsed keys before the error
358 * are added to the map nonetheless. 358 * are added to the map nonetheless.
359 * 359 *
360 * @param config the parser config
361 * @param allocator the allocator for the values that will be stored in the map 360 * @param allocator the allocator for the values that will be stored in the map
362 * @param filename (any string) the absolute or relative path to the file 361 * @param filename (any string) the absolute or relative path to the file
363 * @param target (@c CxMap*) the map where the properties shall be added 362 * @param target (@c CxMap*) the map where the properties shall be added
363 * @param config the parser config
364 * @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
365 * @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
366 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file 366 * @retval CX_PROPERTIES_INCOMPLETE_DATA unexpected end of file
367 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key 367 * @retval CX_PROPERTIES_INVALID_EMPTY_KEY the properties data contains an illegal empty key
368 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter 368 * @retval CX_PROPERTIES_INVALID_MISSING_DELIMITER the properties data contains a line without delimiter
369 * @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
370 * @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
371 * @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
372 * @see cxPropertiesLoadDefault() 372 * @see cxPropertiesLoadDefault()
373 */ 373 */
374 #define cxPropertiesLoad(config, allocator, filename, target) \ 374 #define cxPropertiesLoad(allocator, filename, target, config) \
375 cx_properties_load(config, allocator, cx_strcast(filename), target) 375 cx_properties_load(allocator, cx_strcast(filename), target, config)
376 376
377 /** 377 /**
378 * 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.
379 * 379 *
380 * Entries are added to the map, possibly overwriting existing entries. 380 * Entries are added to the map, possibly overwriting existing entries.
397 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set 397 * @retval CX_PROPERTIES_FILE_ERROR a file operation failed; depending on the system @c errno might be set
398 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed 398 * @retval CX_PROPERTIES_MAP_ERROR storing a key/value pair in the map failed
399 * @see cxPropertiesLoad() 399 * @see cxPropertiesLoad()
400 */ 400 */
401 #define cxPropertiesLoadDefault(allocator, filename, target) \ 401 #define cxPropertiesLoadDefault(allocator, filename, target) \
402 cx_properties_load(cx_properties_config_default, allocator, cx_strcast(filename), target) 402 cx_properties_load(allocator, cx_strcast(filename), target, cx_properties_config_default)
403 403
404 404
405 #ifdef __cplusplus 405 #ifdef __cplusplus
406 } // extern "C" 406 } // extern "C"
407 #endif 407 #endif

mercurial