| 368 * Fills the input buffer with data. |
368 * Fills the input buffer with data. |
| 369 * |
369 * |
| 370 * After calling this function, you can parse the data by calling |
370 * After calling this function, you can parse the data by calling |
| 371 * cxPropertiesNext(). |
371 * cxPropertiesNext(). |
| 372 * |
372 * |
| |
373 * @remark The properties interface tries to avoid allocations. |
| |
374 * When you use this function and cxPropertiesNext() interleaving, |
| |
375 * no allocations are performed. However, you must not free the |
| |
376 * pointer to the data in that case. When you invoke the fill |
| |
377 * function more than once before calling cxPropertiesNext(), |
| |
378 * the additional data is appended - inevitably leading to |
| |
379 * an allocation of a new buffer and copying the previous contents. |
| |
380 * |
| |
381 * @param prop the properties interface |
| |
382 * @param buf a pointer to the data |
| |
383 * @param len the length of the data |
| |
384 * @return non-zero when a memory allocation was necessary but failed |
| |
385 */ |
| |
386 cx_attr_nonnull |
| |
387 cx_attr_access_r(2, 3) |
| |
388 int cxPropertiesFilln( |
| |
389 CxProperties *prop, |
| |
390 const char *buf, |
| |
391 size_t len |
| |
392 ); |
| |
393 |
| |
394 #ifdef __cplusplus |
| |
395 } // extern "C" |
| |
396 cx_attr_nonnull |
| |
397 static inline int cxPropertiesFill( |
| |
398 CxProperties *prop, |
| |
399 cxstring str |
| |
400 ) { |
| |
401 return cxPropertiesFilln(prop, str.ptr, str.length); |
| |
402 } |
| |
403 |
| |
404 cx_attr_nonnull |
| |
405 static inline int cxPropertiesFill( |
| |
406 CxProperties *prop, |
| |
407 cxmutstr str |
| |
408 ) { |
| |
409 return cxPropertiesFilln(prop, str.ptr, str.length); |
| |
410 } |
| |
411 |
| |
412 cx_attr_nonnull |
| |
413 cx_attr_cstr_arg(2) |
| |
414 static inline int cxPropertiesFill( |
| |
415 CxProperties *prop, |
| |
416 const char *str |
| |
417 ) { |
| |
418 return cxPropertiesFilln(prop, str, strlen(str)); |
| |
419 } |
| |
420 |
| |
421 extern "C" { |
| |
422 #else // __cplusplus |
| |
423 /** |
| |
424 * Fills the input buffer with data. |
| |
425 * |
| |
426 * After calling this function, you can parse the data by calling |
| |
427 * cxPropertiesNext(). |
| |
428 * |
| 373 * @attention The properties interface tries to avoid allocations. |
429 * @attention The properties interface tries to avoid allocations. |
| 374 * When you use this function and cxPropertiesNext() interleaving, |
430 * When you use this function and cxPropertiesNext() interleaving, |
| 375 * no allocations are performed. However, you must not free the |
431 * no allocations are performed. However, you must not free the |
| 376 * pointer to the data in that case. When you invoke the fill |
432 * pointer to the data in that case. When you invoke the fill |
| 377 * function more than once before calling cxPropertiesNext(), |
433 * function more than once before calling cxPropertiesNext(), |
| 378 * the additional data is appended - inevitably leading to |
434 * the additional data is appended - inevitably leading to |
| 379 * an allocation of a new buffer and copying the previous contents. |
435 * an allocation of a new buffer and copying the previous contents. |
| 380 * |
436 * |
| 381 * @param prop the properties interface |
437 * @param prop the properties interface |
| 382 * @param buf a pointer to the data |
|
| 383 * @param len the length of the data |
|
| 384 * @return non-zero when a memory allocation was necessary but failed |
|
| 385 */ |
|
| 386 cx_attr_nonnull |
|
| 387 cx_attr_access_r(2, 3) |
|
| 388 int cxPropertiesFilln( |
|
| 389 CxProperties *prop, |
|
| 390 const char *buf, |
|
| 391 size_t len |
|
| 392 ); |
|
| 393 |
|
| 394 #ifdef __cplusplus |
|
| 395 } // extern "C" |
|
| 396 cx_attr_nonnull |
|
| 397 static inline int cxPropertiesFill( |
|
| 398 CxProperties *prop, |
|
| 399 cxstring str |
|
| 400 ) { |
|
| 401 return cxPropertiesFilln(prop, str.ptr, str.length); |
|
| 402 } |
|
| 403 |
|
| 404 cx_attr_nonnull |
|
| 405 static inline int cxPropertiesFill( |
|
| 406 CxProperties *prop, |
|
| 407 cxmutstr str |
|
| 408 ) { |
|
| 409 return cxPropertiesFilln(prop, str.ptr, str.length); |
|
| 410 } |
|
| 411 |
|
| 412 cx_attr_nonnull |
|
| 413 cx_attr_cstr_arg(2) |
|
| 414 static inline int cxPropertiesFill( |
|
| 415 CxProperties *prop, |
|
| 416 const char *str |
|
| 417 ) { |
|
| 418 return cxPropertiesFilln(prop, str, strlen(str)); |
|
| 419 } |
|
| 420 |
|
| 421 extern "C" { |
|
| 422 #else // __cplusplus |
|
| 423 /** |
|
| 424 * Fills the input buffer with data. |
|
| 425 * |
|
| 426 * After calling this function, you can parse the data by calling |
|
| 427 * cxPropertiesNext(). |
|
| 428 * |
|
| 429 * @attention The properties interface tries to avoid allocations. |
|
| 430 * When you use this function and cxPropertiesNext() interleaving, |
|
| 431 * no allocations are performed. However, you must not free the |
|
| 432 * pointer to the data in that case. When you invoke the fill |
|
| 433 * function more than once before calling cxPropertiesNext(), |
|
| 434 * the additional data is appended - inevitably leading to |
|
| 435 * an allocation of a new buffer and copying the previous contents. |
|
| 436 * |
|
| 437 * @param prop the properties interface |
|
| 438 * @param str the text to fill in |
438 * @param str the text to fill in |
| 439 * @return non-zero when a memory allocation was necessary but failed |
439 * @return non-zero when a memory allocation was necessary but failed |
| 440 */ |
440 */ |
| 441 #define cxPropertiesFill(prop, str) _Generic((str), \ |
441 #define cxPropertiesFill(prop, str) _Generic((str), \ |
| 442 cxstring: cx_properties_fill_cxstr, \ |
442 cxstring: cx_properties_fill_cxstr, \ |