ucx/cx/json.h

changeset 471
063a9f29098c
parent 440
7c4b9cba09ca
equal deleted inserted replaced
470:118e2386d5b4 471:063a9f29098c
307 /** 307 /**
308 * The token type. 308 * The token type.
309 */ 309 */
310 CxJsonTokenType tokentype; 310 CxJsonTokenType tokentype;
311 /** 311 /**
312 * True, iff the @c content must be passed to cx_strfree(). 312 * True, if the @c content must be passed to cx_strfree().
313 */ 313 */
314 bool allocated; 314 bool allocated;
315 /** 315 /**
316 * The token text, if any. 316 * The token text, if any.
317 * 317 *
372 372
373 /** 373 /**
374 * Internally reserved memory for the value buffer stack. 374 * Internally reserved memory for the value buffer stack.
375 */ 375 */
376 CxJsonValue* vbuf_internal[8]; 376 CxJsonValue* vbuf_internal[8];
377
378 /**
379 * Used internally.
380 */
381 bool tokenizer_escape; // TODO: check if it can be replaced with look-behind
382 }; 377 };
383 378
384 /** 379 /**
385 * Status codes for the json interface. 380 * Status codes for the json interface.
386 */ 381 */
447 * Set false to output the members in the order in which they were added. 442 * Set false to output the members in the order in which they were added.
448 */ 443 */
449 bool sort_members; 444 bool sort_members;
450 /** 445 /**
451 * The maximum number of fractional digits in a number value. 446 * The maximum number of fractional digits in a number value.
447 * The default value is 6 and values larger than 15 are reduced to 15.
448 * Note, that the actual number of digits may be lower, depending on the concrete number.
452 */ 449 */
453 uint8_t frac_max_digits; 450 uint8_t frac_max_digits;
454 /** 451 /**
455 * Set true to use spaces instead of tab characters. 452 * Set true to use spaces instead of tab characters.
456 * Indentation is only used in pretty output. 453 * Indentation is only used in pretty output.
459 /** 456 /**
460 * If @c indent_space is true, this is the number of spaces per tab. 457 * If @c indent_space is true, this is the number of spaces per tab.
461 * Indentation is only used in pretty output. 458 * Indentation is only used in pretty output.
462 */ 459 */
463 uint8_t indent; 460 uint8_t indent;
461 /**
462 * Set true to enable escaping of the slash character (solidus).
463 */
464 bool escape_slash;
464 }; 465 };
465 466
466 /** 467 /**
467 * Typedef for the json writer. 468 * Typedef for the json writer.
468 */ 469 */
472 * Creates a default writer configuration for compact output. 473 * Creates a default writer configuration for compact output.
473 * 474 *
474 * @return new JSON writer settings 475 * @return new JSON writer settings
475 */ 476 */
476 cx_attr_nodiscard 477 cx_attr_nodiscard
478 cx_attr_export
477 CxJsonWriter cxJsonWriterCompact(void); 479 CxJsonWriter cxJsonWriterCompact(void);
478 480
479 /** 481 /**
480 * Creates a default writer configuration for pretty output. 482 * Creates a default writer configuration for pretty output.
481 * 483 *
482 * @param use_spaces false if you want tabs, true if you want four spaces instead 484 * @param use_spaces false if you want tabs, true if you want four spaces instead
483 * @return new JSON writer settings 485 * @return new JSON writer settings
484 */ 486 */
485 cx_attr_nodiscard 487 cx_attr_nodiscard
488 cx_attr_export
486 CxJsonWriter cxJsonWriterPretty(bool use_spaces); 489 CxJsonWriter cxJsonWriterPretty(bool use_spaces);
487 490
488 /** 491 /**
489 * Writes a JSON value to a buffer or stream. 492 * Writes a JSON value to a buffer or stream.
490 * 493 *
491 * This function blocks until all data is written or an error when trying 494 * This function blocks until either all data is written, or an error occurs.
492 * to write data occurs.
493 * The write operation is not atomic in the sense that it might happen 495 * The write operation is not atomic in the sense that it might happen
494 * that the data is only partially written when an error occurs with no 496 * that the data is only partially written when an error occurs with no
495 * way to indicate how much data was written. 497 * way to indicate how much data was written.
496 * To avoid this problem, you can use a CxBuffer as @p target which is 498 * To avoid this problem, you can use a CxBuffer as @p target which is
497 * unlikely to fail a write operation and either use the buffer's flush 499 * unlikely to fail a write operation and either use the buffer's flush
504 * @param settings formatting settings (or @c NULL to use a compact default) 506 * @param settings formatting settings (or @c NULL to use a compact default)
505 * @retval zero success 507 * @retval zero success
506 * @retval non-zero when no or not all data could be written 508 * @retval non-zero when no or not all data could be written
507 */ 509 */
508 cx_attr_nonnull_arg(1, 2, 3) 510 cx_attr_nonnull_arg(1, 2, 3)
511 cx_attr_export
509 int cxJsonWrite( 512 int cxJsonWrite(
510 void* target, 513 void* target,
511 const CxJsonValue* value, 514 const CxJsonValue* value,
512 cx_write_func wfunc, 515 cx_write_func wfunc,
513 const CxJsonWriter* settings 516 const CxJsonWriter* settings
519 * @param json the json interface 522 * @param json the json interface
520 * @param allocator the allocator that shall be used for the produced values 523 * @param allocator the allocator that shall be used for the produced values
521 * @see cxJsonDestroy() 524 * @see cxJsonDestroy()
522 */ 525 */
523 cx_attr_nonnull_arg(1) 526 cx_attr_nonnull_arg(1)
527 cx_attr_export
524 void cxJsonInit(CxJson *json, const CxAllocator *allocator); 528 void cxJsonInit(CxJson *json, const CxAllocator *allocator);
525 529
526 /** 530 /**
527 * Destroys the json interface. 531 * Destroys the json interface.
528 * 532 *
529 * @param json the json interface 533 * @param json the json interface
530 * @see cxJsonInit() 534 * @see cxJsonInit()
531 */ 535 */
532 cx_attr_nonnull 536 cx_attr_nonnull
537 cx_attr_export
533 void cxJsonDestroy(CxJson *json); 538 void cxJsonDestroy(CxJson *json);
534 539
535 /** 540 /**
536 * Destroys and re-initializes the json interface. 541 * Destroys and re-initializes the json interface.
537 * 542 *
565 * @retval non-zero internal allocation error 570 * @retval non-zero internal allocation error
566 * @see cxJsonFill() 571 * @see cxJsonFill()
567 */ 572 */
568 cx_attr_nonnull 573 cx_attr_nonnull
569 cx_attr_access_r(2, 3) 574 cx_attr_access_r(2, 3)
575 cx_attr_export
570 int cxJsonFilln(CxJson *json, const char *buf, size_t len); 576 int cxJsonFilln(CxJson *json, const char *buf, size_t len);
571 577
572 #ifdef __cplusplus 578 #ifdef __cplusplus
573 } // extern "C" 579 } // extern "C"
574 580
665 * @return the new JSON object or @c NULL if allocation fails 671 * @return the new JSON object or @c NULL if allocation fails
666 * @see cxJsonObjPutObj() 672 * @see cxJsonObjPutObj()
667 * @see cxJsonArrAddValues() 673 * @see cxJsonArrAddValues()
668 */ 674 */
669 cx_attr_nodiscard 675 cx_attr_nodiscard
676 cx_attr_export
670 CxJsonValue* cxJsonCreateObj(const CxAllocator* allocator); 677 CxJsonValue* cxJsonCreateObj(const CxAllocator* allocator);
671 678
672 /** 679 /**
673 * Creates a new (empty) JSON array. 680 * Creates a new (empty) JSON array.
674 * 681 *
676 * @return the new JSON array or @c NULL if allocation fails 683 * @return the new JSON array or @c NULL if allocation fails
677 * @see cxJsonObjPutArr() 684 * @see cxJsonObjPutArr()
678 * @see cxJsonArrAddValues() 685 * @see cxJsonArrAddValues()
679 */ 686 */
680 cx_attr_nodiscard 687 cx_attr_nodiscard
688 cx_attr_export
681 CxJsonValue* cxJsonCreateArr(const CxAllocator* allocator); 689 CxJsonValue* cxJsonCreateArr(const CxAllocator* allocator);
682 690
683 /** 691 /**
684 * Creates a new JSON number value. 692 * Creates a new JSON number value.
685 * 693 *
688 * @return the new JSON value or @c NULL if allocation fails 696 * @return the new JSON value or @c NULL if allocation fails
689 * @see cxJsonObjPutNumber() 697 * @see cxJsonObjPutNumber()
690 * @see cxJsonArrAddNumbers() 698 * @see cxJsonArrAddNumbers()
691 */ 699 */
692 cx_attr_nodiscard 700 cx_attr_nodiscard
701 cx_attr_export
693 CxJsonValue* cxJsonCreateNumber(const CxAllocator* allocator, double num); 702 CxJsonValue* cxJsonCreateNumber(const CxAllocator* allocator, double num);
694 703
695 /** 704 /**
696 * Creates a new JSON number value based on an integer. 705 * Creates a new JSON number value based on an integer.
697 * 706 *
700 * @return the new JSON value or @c NULL if allocation fails 709 * @return the new JSON value or @c NULL if allocation fails
701 * @see cxJsonObjPutInteger() 710 * @see cxJsonObjPutInteger()
702 * @see cxJsonArrAddIntegers() 711 * @see cxJsonArrAddIntegers()
703 */ 712 */
704 cx_attr_nodiscard 713 cx_attr_nodiscard
714 cx_attr_export
705 CxJsonValue* cxJsonCreateInteger(const CxAllocator* allocator, int64_t num); 715 CxJsonValue* cxJsonCreateInteger(const CxAllocator* allocator, int64_t num);
706 716
707 /** 717 /**
708 * Creates a new JSON string. 718 * Creates a new JSON string.
709 * 719 *
715 * @see cxJsonArrAddStrings() 725 * @see cxJsonArrAddStrings()
716 */ 726 */
717 cx_attr_nodiscard 727 cx_attr_nodiscard
718 cx_attr_nonnull_arg(2) 728 cx_attr_nonnull_arg(2)
719 cx_attr_cstr_arg(2) 729 cx_attr_cstr_arg(2)
730 cx_attr_export
720 CxJsonValue* cxJsonCreateString(const CxAllocator* allocator, const char *str); 731 CxJsonValue* cxJsonCreateString(const CxAllocator* allocator, const char *str);
721 732
722 /** 733 /**
723 * Creates a new JSON string. 734 * Creates a new JSON string.
724 * 735 *
728 * @see cxJsonCreateCxString() 739 * @see cxJsonCreateCxString()
729 * @see cxJsonObjPutCxString() 740 * @see cxJsonObjPutCxString()
730 * @see cxJsonArrAddCxStrings() 741 * @see cxJsonArrAddCxStrings()
731 */ 742 */
732 cx_attr_nodiscard 743 cx_attr_nodiscard
744 cx_attr_export
733 CxJsonValue* cxJsonCreateCxString(const CxAllocator* allocator, cxstring str); 745 CxJsonValue* cxJsonCreateCxString(const CxAllocator* allocator, cxstring str);
734 746
735 /** 747 /**
736 * Creates a new JSON literal. 748 * Creates a new JSON literal.
737 * 749 *
740 * @return the new JSON value or @c NULL if allocation fails 752 * @return the new JSON value or @c NULL if allocation fails
741 * @see cxJsonObjPutLiteral() 753 * @see cxJsonObjPutLiteral()
742 * @see cxJsonArrAddLiterals() 754 * @see cxJsonArrAddLiterals()
743 */ 755 */
744 cx_attr_nodiscard 756 cx_attr_nodiscard
757 cx_attr_export
745 CxJsonValue* cxJsonCreateLiteral(const CxAllocator* allocator, CxJsonLiteral lit); 758 CxJsonValue* cxJsonCreateLiteral(const CxAllocator* allocator, CxJsonLiteral lit);
746 759
747 /** 760 /**
748 * Adds number values to a JSON array. 761 * Adds number values to a JSON array.
749 * 762 *
753 * @retval zero success 766 * @retval zero success
754 * @retval non-zero allocation failure 767 * @retval non-zero allocation failure
755 */ 768 */
756 cx_attr_nonnull 769 cx_attr_nonnull
757 cx_attr_access_r(2, 3) 770 cx_attr_access_r(2, 3)
771 cx_attr_export
758 int cxJsonArrAddNumbers(CxJsonValue* arr, const double* num, size_t count); 772 int cxJsonArrAddNumbers(CxJsonValue* arr, const double* num, size_t count);
759 773
760 /** 774 /**
761 * Adds number values, of which all are integers, to a JSON array. 775 * Adds number values, of which all are integers, to a JSON array.
762 * 776 *
766 * @retval zero success 780 * @retval zero success
767 * @retval non-zero allocation failure 781 * @retval non-zero allocation failure
768 */ 782 */
769 cx_attr_nonnull 783 cx_attr_nonnull
770 cx_attr_access_r(2, 3) 784 cx_attr_access_r(2, 3)
785 cx_attr_export
771 int cxJsonArrAddIntegers(CxJsonValue* arr, const int64_t* num, size_t count); 786 int cxJsonArrAddIntegers(CxJsonValue* arr, const int64_t* num, size_t count);
772 787
773 /** 788 /**
774 * Adds strings to a JSON array. 789 * Adds strings to a JSON array.
775 * 790 *
782 * @retval non-zero allocation failure 797 * @retval non-zero allocation failure
783 * @see cxJsonArrAddCxStrings() 798 * @see cxJsonArrAddCxStrings()
784 */ 799 */
785 cx_attr_nonnull 800 cx_attr_nonnull
786 cx_attr_access_r(2, 3) 801 cx_attr_access_r(2, 3)
802 cx_attr_export
787 int cxJsonArrAddStrings(CxJsonValue* arr, const char* const* str, size_t count); 803 int cxJsonArrAddStrings(CxJsonValue* arr, const char* const* str, size_t count);
788 804
789 /** 805 /**
790 * Adds strings to a JSON array. 806 * Adds strings to a JSON array.
791 * 807 *
798 * @retval non-zero allocation failure 814 * @retval non-zero allocation failure
799 * @see cxJsonArrAddStrings() 815 * @see cxJsonArrAddStrings()
800 */ 816 */
801 cx_attr_nonnull 817 cx_attr_nonnull
802 cx_attr_access_r(2, 3) 818 cx_attr_access_r(2, 3)
819 cx_attr_export
803 int cxJsonArrAddCxStrings(CxJsonValue* arr, const cxstring* str, size_t count); 820 int cxJsonArrAddCxStrings(CxJsonValue* arr, const cxstring* str, size_t count);
804 821
805 /** 822 /**
806 * Adds literals to a JSON array. 823 * Adds literals to a JSON array.
807 * 824 *
811 * @retval zero success 828 * @retval zero success
812 * @retval non-zero allocation failure 829 * @retval non-zero allocation failure
813 */ 830 */
814 cx_attr_nonnull 831 cx_attr_nonnull
815 cx_attr_access_r(2, 3) 832 cx_attr_access_r(2, 3)
833 cx_attr_export
816 int cxJsonArrAddLiterals(CxJsonValue* arr, const CxJsonLiteral* lit, size_t count); 834 int cxJsonArrAddLiterals(CxJsonValue* arr, const CxJsonLiteral* lit, size_t count);
817 835
818 /** 836 /**
819 * Add arbitrary values to a JSON array. 837 * Add arbitrary values to a JSON array.
820 * 838 *
827 * @retval zero success 845 * @retval zero success
828 * @retval non-zero allocation failure 846 * @retval non-zero allocation failure
829 */ 847 */
830 cx_attr_nonnull 848 cx_attr_nonnull
831 cx_attr_access_r(2, 3) 849 cx_attr_access_r(2, 3)
850 cx_attr_export
832 int cxJsonArrAddValues(CxJsonValue* arr, CxJsonValue* const* val, size_t count); 851 int cxJsonArrAddValues(CxJsonValue* arr, CxJsonValue* const* val, size_t count);
833 852
834 /** 853 /**
835 * Adds or replaces a value within a JSON object. 854 * Adds or replaces a value within a JSON object.
836 * 855 *
844 * @param child the value 863 * @param child the value
845 * @retval zero success 864 * @retval zero success
846 * @retval non-zero allocation failure 865 * @retval non-zero allocation failure
847 */ 866 */
848 cx_attr_nonnull 867 cx_attr_nonnull
868 cx_attr_export
849 int cxJsonObjPut(CxJsonValue* obj, cxstring name, CxJsonValue* child); 869 int cxJsonObjPut(CxJsonValue* obj, cxstring name, CxJsonValue* child);
850 870
851 /** 871 /**
852 * Creates a new JSON object and adds it to an existing object. 872 * Creates a new JSON object and adds it to an existing object.
853 * 873 *
856 * @return the new value or @c NULL if allocation fails 876 * @return the new value or @c NULL if allocation fails
857 * @see cxJsonObjPut() 877 * @see cxJsonObjPut()
858 * @see cxJsonCreateObj() 878 * @see cxJsonCreateObj()
859 */ 879 */
860 cx_attr_nonnull 880 cx_attr_nonnull
881 cx_attr_export
861 CxJsonValue* cxJsonObjPutObj(CxJsonValue* obj, cxstring name); 882 CxJsonValue* cxJsonObjPutObj(CxJsonValue* obj, cxstring name);
862 883
863 /** 884 /**
864 * Creates a new JSON array and adds it to an object. 885 * Creates a new JSON array and adds it to an object.
865 * 886 *
868 * @return the new value or @c NULL if allocation fails 889 * @return the new value or @c NULL if allocation fails
869 * @see cxJsonObjPut() 890 * @see cxJsonObjPut()
870 * @see cxJsonCreateArr() 891 * @see cxJsonCreateArr()
871 */ 892 */
872 cx_attr_nonnull 893 cx_attr_nonnull
894 cx_attr_export
873 CxJsonValue* cxJsonObjPutArr(CxJsonValue* obj, cxstring name); 895 CxJsonValue* cxJsonObjPutArr(CxJsonValue* obj, cxstring name);
874 896
875 /** 897 /**
876 * Creates a new JSON number and adds it to an object. 898 * Creates a new JSON number and adds it to an object.
877 * 899 *
881 * @return the new value or @c NULL if allocation fails 903 * @return the new value or @c NULL if allocation fails
882 * @see cxJsonObjPut() 904 * @see cxJsonObjPut()
883 * @see cxJsonCreateNumber() 905 * @see cxJsonCreateNumber()
884 */ 906 */
885 cx_attr_nonnull 907 cx_attr_nonnull
908 cx_attr_export
886 CxJsonValue* cxJsonObjPutNumber(CxJsonValue* obj, cxstring name, double num); 909 CxJsonValue* cxJsonObjPutNumber(CxJsonValue* obj, cxstring name, double num);
887 910
888 /** 911 /**
889 * Creates a new JSON number, based on an integer, and adds it to an object. 912 * Creates a new JSON number, based on an integer, and adds it to an object.
890 * 913 *
894 * @return the new value or @c NULL if allocation fails 917 * @return the new value or @c NULL if allocation fails
895 * @see cxJsonObjPut() 918 * @see cxJsonObjPut()
896 * @see cxJsonCreateInteger() 919 * @see cxJsonCreateInteger()
897 */ 920 */
898 cx_attr_nonnull 921 cx_attr_nonnull
922 cx_attr_export
899 CxJsonValue* cxJsonObjPutInteger(CxJsonValue* obj, cxstring name, int64_t num); 923 CxJsonValue* cxJsonObjPutInteger(CxJsonValue* obj, cxstring name, int64_t num);
900 924
901 /** 925 /**
902 * Creates a new JSON string and adds it to an object. 926 * Creates a new JSON string and adds it to an object.
903 * 927 *
910 * @see cxJsonObjPut() 934 * @see cxJsonObjPut()
911 * @see cxJsonCreateString() 935 * @see cxJsonCreateString()
912 */ 936 */
913 cx_attr_nonnull 937 cx_attr_nonnull
914 cx_attr_cstr_arg(3) 938 cx_attr_cstr_arg(3)
939 cx_attr_export
915 CxJsonValue* cxJsonObjPutString(CxJsonValue* obj, cxstring name, const char* str); 940 CxJsonValue* cxJsonObjPutString(CxJsonValue* obj, cxstring name, const char* str);
916 941
917 /** 942 /**
918 * Creates a new JSON string and adds it to an object. 943 * Creates a new JSON string and adds it to an object.
919 * 944 *
925 * @return the new value or @c NULL if allocation fails 950 * @return the new value or @c NULL if allocation fails
926 * @see cxJsonObjPut() 951 * @see cxJsonObjPut()
927 * @see cxJsonCreateCxString() 952 * @see cxJsonCreateCxString()
928 */ 953 */
929 cx_attr_nonnull 954 cx_attr_nonnull
955 cx_attr_export
930 CxJsonValue* cxJsonObjPutCxString(CxJsonValue* obj, cxstring name, cxstring str); 956 CxJsonValue* cxJsonObjPutCxString(CxJsonValue* obj, cxstring name, cxstring str);
931 957
932 /** 958 /**
933 * Creates a new JSON literal and adds it to an object. 959 * Creates a new JSON literal and adds it to an object.
934 * 960 *
938 * @return the new value or @c NULL if allocation fails 964 * @return the new value or @c NULL if allocation fails
939 * @see cxJsonObjPut() 965 * @see cxJsonObjPut()
940 * @see cxJsonCreateLiteral() 966 * @see cxJsonCreateLiteral()
941 */ 967 */
942 cx_attr_nonnull 968 cx_attr_nonnull
969 cx_attr_export
943 CxJsonValue* cxJsonObjPutLiteral(CxJsonValue* obj, cxstring name, CxJsonLiteral lit); 970 CxJsonValue* cxJsonObjPutLiteral(CxJsonValue* obj, cxstring name, CxJsonLiteral lit);
944 971
945 /** 972 /**
946 * Recursively deallocates the memory of a JSON value. 973 * Recursively deallocates the memory of a JSON value.
947 * 974 *
951 * you from double-frees when you are accidentally freeing 978 * you from double-frees when you are accidentally freeing
952 * a nested value and then the parent value (or vice versa). 979 * a nested value and then the parent value (or vice versa).
953 * 980 *
954 * @param value the value 981 * @param value the value
955 */ 982 */
983 cx_attr_export
956 void cxJsonValueFree(CxJsonValue *value); 984 void cxJsonValueFree(CxJsonValue *value);
957 985
958 /** 986 /**
959 * Tries to obtain the next JSON value. 987 * Tries to obtain the next JSON value.
960 * 988 *
977 * @retval CX_JSON_FORMAT_ERROR_NUMBER the JSON text contains an illegally formatted number 1005 * @retval CX_JSON_FORMAT_ERROR_NUMBER the JSON text contains an illegally formatted number
978 * @retval CX_JSON_FORMAT_ERROR_UNEXPECTED_TOKEN JSON syntax error 1006 * @retval CX_JSON_FORMAT_ERROR_UNEXPECTED_TOKEN JSON syntax error
979 */ 1007 */
980 cx_attr_nonnull 1008 cx_attr_nonnull
981 cx_attr_access_w(2) 1009 cx_attr_access_w(2)
1010 cx_attr_export
982 CxJsonStatus cxJsonNext(CxJson *json, CxJsonValue **value); 1011 CxJsonStatus cxJsonNext(CxJson *json, CxJsonValue **value);
983 1012
984 /** 1013 /**
985 * Checks if the specified value is a JSON object. 1014 * Checks if the specified value is a JSON object.
986 * 1015 *
1249 * @return the value at the specified index 1278 * @return the value at the specified index
1250 * @see cxJsonIsArray() 1279 * @see cxJsonIsArray()
1251 */ 1280 */
1252 cx_attr_nonnull 1281 cx_attr_nonnull
1253 cx_attr_returns_nonnull 1282 cx_attr_returns_nonnull
1283 cx_attr_export
1254 CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index); 1284 CxJsonValue *cxJsonArrGet(const CxJsonValue *value, size_t index);
1255 1285
1256 /** 1286 /**
1257 * Returns an iterator over the JSON array elements. 1287 * Returns an iterator over the JSON array elements.
1258 * 1288 *
1264 * @return an iterator over the array elements 1294 * @return an iterator over the array elements
1265 * @see cxJsonIsArray() 1295 * @see cxJsonIsArray()
1266 */ 1296 */
1267 cx_attr_nonnull 1297 cx_attr_nonnull
1268 cx_attr_nodiscard 1298 cx_attr_nodiscard
1299 cx_attr_export
1269 CxIterator cxJsonArrIter(const CxJsonValue *value); 1300 CxIterator cxJsonArrIter(const CxJsonValue *value);
1270 1301
1271 /** 1302 /**
1272 * Returns an iterator over the JSON object members. 1303 * Returns an iterator over the JSON object members.
1273 * 1304 *
1280 * @return an iterator over the object members 1311 * @return an iterator over the object members
1281 * @see cxJsonIsObject() 1312 * @see cxJsonIsObject()
1282 */ 1313 */
1283 cx_attr_nonnull 1314 cx_attr_nonnull
1284 cx_attr_nodiscard 1315 cx_attr_nodiscard
1316 cx_attr_export
1285 CxIterator cxJsonObjIter(const CxJsonValue *value); 1317 CxIterator cxJsonObjIter(const CxJsonValue *value);
1286 1318
1287 /** 1319 /**
1288 * @copydoc cxJsonObjGet() 1320 * @copydoc cxJsonObjGet()
1289 */ 1321 */
1290 cx_attr_nonnull 1322 cx_attr_nonnull
1291 cx_attr_returns_nonnull 1323 cx_attr_returns_nonnull
1324 cx_attr_export
1292 CxJsonValue *cx_json_obj_get_cxstr(const CxJsonValue *value, cxstring name); 1325 CxJsonValue *cx_json_obj_get_cxstr(const CxJsonValue *value, cxstring name);
1293 1326
1294 #ifdef __cplusplus 1327 #ifdef __cplusplus
1295 } // extern "C" 1328 } // extern "C"
1296 1329
1297 CxJsonValue *cxJsonObjGet(const CxJsonValue *value, cxstring name) { 1330 static inline CxJsonValue *cxJsonObjGet(const CxJsonValue *value, cxstring name) {
1298 return cx_json_obj_get_cxstr(value, name); 1331 return cx_json_obj_get_cxstr(value, name);
1299 } 1332 }
1300 1333
1301 CxJsonValue *cxJsonObjGet(const CxJsonValue *value, cxmutstr name) { 1334 static inline CxJsonValue *cxJsonObjGet(const CxJsonValue *value, cxmutstr name) {
1302 return cx_json_obj_get_cxstr(value, cx_strcast(name)); 1335 return cx_json_obj_get_cxstr(value, cx_strcast(name));
1303 } 1336 }
1304 1337
1305 CxJsonValue *cxJsonObjGet(const CxJsonValue *value, const char *name) { 1338 static inline CxJsonValue *cxJsonObjGet(const CxJsonValue *value, const char *name) {
1306 return cx_json_obj_get_cxstr(value, cx_str(name)); 1339 return cx_json_obj_get_cxstr(value, cx_str(name));
1307 } 1340 }
1308 1341
1309 extern "C" { 1342 extern "C" {
1310 #else 1343 #else

mercurial