396 * |
396 * |
397 * A "good" status means, that you can refill data and continue parsing. |
397 * A "good" status means, that you can refill data and continue parsing. |
398 */ |
398 */ |
399 CX_JSON_OK, |
399 CX_JSON_OK, |
400 /** |
400 /** |
|
401 * The input buffer has never been filled. |
|
402 */ |
|
403 CX_JSON_NULL_DATA, |
|
404 /** |
401 * Allocating memory for the internal buffer failed. |
405 * Allocating memory for the internal buffer failed. |
402 */ |
406 */ |
403 CX_JSON_BUFFER_ALLOC_FAILED, |
407 CX_JSON_BUFFER_ALLOC_FAILED, |
404 /** |
408 /** |
405 * Allocating memory for a json value failed. |
409 * Allocating memory for a json value failed. |
453 cxJsonDestroy(json); |
457 cxJsonDestroy(json); |
454 cxJsonInit(json, allocator); |
458 cxJsonInit(json, allocator); |
455 } |
459 } |
456 |
460 |
457 /** |
461 /** |
458 * Adds more data to the input buffer. |
462 * Fills the input buffer. |
459 * |
463 * |
460 * The data will be copied. |
464 * @remark The JSON interface tries to avoid copying the input data. |
|
465 * When you use this function and cxJsonNext() interleaving, |
|
466 * no copies are performed. However, you must not free the |
|
467 * pointer to the data in that case. When you invoke the fill |
|
468 * function more than once before calling cxJsonNext(), |
|
469 * the additional data is appended - inevitably leading to |
|
470 * an allocation of a new buffer and copying the previous contents. |
461 * |
471 * |
462 * @param json the json interface |
472 * @param json the json interface |
463 * @param buf the source buffer |
473 * @param buf the source buffer |
464 * @param len the length of the source buffer |
474 * @param len the length of the source buffer |
465 * @return zero on success, non-zero on internal allocation error |
475 * @return zero on success, non-zero on internal allocation error |
498 } |
508 } |
499 |
509 |
500 extern "C" { |
510 extern "C" { |
501 #else // __cplusplus |
511 #else // __cplusplus |
502 /** |
512 /** |
503 * Adds more data to the input buffer. |
513 * Fills the input buffer. |
504 * |
514 * |
505 * The data will be copied. |
515 * @remark The JSON interface tries to avoid copying the input data. |
|
516 * When you use this function and cxJsonNext() interleaving, |
|
517 * no copies are performed. However, you must not free the |
|
518 * pointer to the data in that case. When you invoke the fill |
|
519 * function more than once before calling cxJsonNext(), |
|
520 * the additional data is appended - inevitably leading to |
|
521 * an allocation of a new buffer and copying the previous contents. |
506 * |
522 * |
507 * @param json the json interface |
523 * @param json the json interface |
508 * @param str the string to add to the buffer |
524 * @param buf the source string |
509 * @return zero on success, non-zero on internal allocation error |
525 * @return zero on success, non-zero on internal allocation error |
510 * @see cxJsonFilln() |
526 * @see cxJsonFilln() |
511 */ |
527 */ |
512 #define cxJsonFill(json, str) _Generic((str), \ |
528 #define cxJsonFill(json, str) _Generic((str), \ |
513 cxstring: cx_json_fill_cxstr, \ |
529 cxstring: cx_json_fill_cxstr, \ |