src/cx/properties.h

changeset 1417
b97faf8b7ab7
parent 1318
12fa1d37fe48
equal deleted inserted replaced
1416:e67caa21d5a7 1417:b97faf8b7ab7
401 CxProperties *prop, 401 CxProperties *prop,
402 const char *buf, 402 const char *buf,
403 size_t len 403 size_t len
404 ); 404 );
405 405
406 #ifdef __cplusplus 406 /**
407 } // extern "C" 407 * Internal function, do not use.
408 cx_attr_nonnull 408 *
409 static inline int cxPropertiesFill( 409 * @param prop the properties interface
410 * @param str the text to fill in
411 * @retval zero success
412 * @retval non-zero a memory allocation was necessary but failed
413 */
414 cx_attr_nonnull
415 static inline int cx_properties_fill(
410 CxProperties *prop, 416 CxProperties *prop,
411 cxstring str 417 cxstring str
412 ) { 418 ) {
413 return cxPropertiesFilln(prop, str.ptr, str.length); 419 return cxPropertiesFilln(prop, str.ptr, str.length);
414 } 420 }
415 421
416 cx_attr_nonnull
417 static inline int cxPropertiesFill(
418 CxProperties *prop,
419 cxmutstr str
420 ) {
421 return cxPropertiesFilln(prop, str.ptr, str.length);
422 }
423
424 cx_attr_nonnull
425 cx_attr_cstr_arg(2)
426 static inline int cxPropertiesFill(
427 CxProperties *prop,
428 const char *str
429 ) {
430 return cxPropertiesFilln(prop, str, strlen(str));
431 }
432
433 extern "C" {
434 #else // __cplusplus
435 /** 422 /**
436 * Fills the input buffer with data. 423 * Fills the input buffer with data.
437 * 424 *
438 * After calling this function, you can parse the data by calling 425 * After calling this function, you can parse the data by calling
439 * cxPropertiesNext(). 426 * cxPropertiesNext().
450 * @param str the text to fill in 437 * @param str the text to fill in
451 * @retval zero success 438 * @retval zero success
452 * @retval non-zero a memory allocation was necessary but failed 439 * @retval non-zero a memory allocation was necessary but failed
453 * @see cxPropertiesFilln() 440 * @see cxPropertiesFilln()
454 */ 441 */
455 #define cxPropertiesFill(prop, str) _Generic((str), \ 442 #define cxPropertiesFill(prop, str) cx_properties_fill(prop, cx_strcast(str))
456 cxstring: cx_properties_fill_cxstr, \
457 cxmutstr: cx_properties_fill_mutstr, \
458 char*: cx_properties_fill_str, \
459 const char*: cx_properties_fill_str) \
460 (prop, str)
461
462 /**
463 * @copydoc cxPropertiesFill()
464 */
465 cx_attr_nonnull
466 static inline int cx_properties_fill_cxstr(
467 CxProperties *prop,
468 cxstring str
469 ) {
470 return cxPropertiesFilln(prop, str.ptr, str.length);
471 }
472
473 /**
474 * @copydoc cxPropertiesFill()
475 */
476 cx_attr_nonnull
477 static inline int cx_properties_fill_mutstr(
478 CxProperties *prop,
479 cxmutstr str
480 ) {
481 return cxPropertiesFilln(prop, str.ptr, str.length);
482 }
483
484 /**
485 * @copydoc cxPropertiesFill()
486 */
487 cx_attr_nonnull
488 cx_attr_cstr_arg(2)
489 static inline int cx_properties_fill_str(
490 CxProperties *prop,
491 const char *str
492 ) {
493 return cxPropertiesFilln(prop, str, strlen(str));
494 }
495 #endif
496 443
497 /** 444 /**
498 * Specifies stack memory that shall be used as internal buffer. 445 * Specifies stack memory that shall be used as internal buffer.
499 * 446 *
500 * @param prop the properties interface 447 * @param prop the properties interface

mercurial