src/cx/json.h

changeset 1054
fb1076ead56f
parent 1042
c17f11830a2d
equal deleted inserted replaced
1053:2e86cf779135 1054:fb1076ead56f
293 CxJsonLiteral literal; 293 CxJsonLiteral literal;
294 } value; 294 } value;
295 }; 295 };
296 296
297 /** 297 /**
298 * Structure for a parsed token. 298 * Internally used structure for a parsed token.
299 *
300 * You should never need to use this in your code.
299 */ 301 */
300 struct cx_json_token_s { 302 struct cx_json_token_s {
301 /** 303 /**
302 * The token type. 304 * The token type.
303 */ 305 */
547 ) { 549 ) {
548 return cxJsonFilln(json, str, strlen(str)); 550 return cxJsonFilln(json, str, strlen(str));
549 } 551 }
550 #endif 552 #endif
551 553
554 cx_attr_nodiscard
555 CxJsonValue* cxJsonCreateObj(const CxAllocator* allocator);
556
557 cx_attr_nodiscard
558 CxJsonValue* cxJsonCreateArr(const CxAllocator* allocator);
559
560 cx_attr_nodiscard
561 CxJsonValue* cxJsonCreateNumber(const CxAllocator* allocator, double num);
562
563 cx_attr_nodiscard
564 CxJsonValue* cxJsonCreateInteger(const CxAllocator* allocator, int64_t num);
565
566 cx_attr_nodiscard
567 cx_attr_nonnull_arg(2)
568 cx_attr_cstr_arg(2)
569 CxJsonValue* cxJsonCreateString(const CxAllocator* allocator, const char *str);
570
571 cx_attr_nodiscard
572 CxJsonValue* cxJsonCreateCxString(const CxAllocator* allocator, cxstring str);
573
574 cx_attr_nodiscard
575 CxJsonValue* cxJsonCreateLiteral(const CxAllocator* allocator, CxJsonLiteral lit);
576
577 cx_attr_nonnull
578 cx_attr_access_r(2, 3)
579 int cxJsonArrAddNumbers(CxJsonValue* arr, const double* num, size_t count);
580
581 cx_attr_nonnull
582 cx_attr_access_r(2, 3)
583 int cxJsonArrAddIntegers(CxJsonValue* arr, const int64_t* num, size_t count);
584
585 cx_attr_nonnull
586 cx_attr_access_r(2, 3)
587 int cxJsonArrAddStrings(CxJsonValue* arr, const char* const* str, size_t count);
588
589 cx_attr_nonnull
590 cx_attr_access_r(2, 3)
591 int cxJsonArrAddCxStrings(CxJsonValue* arr, const cxstring* str, size_t count);
592
593 cx_attr_nonnull
594 cx_attr_access_r(2, 3)
595 int cxJsonArrAddLiterals(CxJsonValue* arr, const CxJsonLiteral* lit, size_t count);
596
597 cx_attr_nonnull
598 cx_attr_access_r(2, 3)
599 int cxJsonArrAddValues(CxJsonValue* arr, CxJsonValue* const* val, size_t count);
600
601 cx_attr_nonnull
602 int cxJsonObjPut(CxJsonValue* obj, cxstring name, CxJsonValue* child);
603
604 cx_attr_nonnull
605 CxJsonValue* cxJsonObjPutObj(CxJsonValue* obj, cxstring name);
606
607 cx_attr_nonnull
608 CxJsonValue* cxJsonObjPutArr(CxJsonValue* obj, cxstring name);
609
610 cx_attr_nonnull
611 CxJsonValue* cxJsonObjPutNumber(CxJsonValue* obj, cxstring name, double num);
612
613 cx_attr_nonnull
614 CxJsonValue* cxJsonObjPutInteger(CxJsonValue* obj, cxstring name, int64_t num);
615
616 cx_attr_nonnull
617 cx_attr_cstr_arg(3)
618 CxJsonValue* cxJsonObjPutString(CxJsonValue* obj, cxstring name, const char* str);
619
620 cx_attr_nonnull
621 CxJsonValue* cxJsonObjPutCxString(CxJsonValue* obj, cxstring name, cxstring str);
622
623 cx_attr_nonnull
624 CxJsonValue* cxJsonObjPutLiteral(CxJsonValue* obj, cxstring name, CxJsonLiteral lit);
625
552 /** 626 /**
553 * Recursively deallocates the memory of a JSON value. 627 * Recursively deallocates the memory of a JSON value.
554 * 628 *
555 * \remark The type of each deallocated value will be changed 629 * \remark The type of each deallocated value will be changed
556 * to #CX_JSON_NOTHING and values of such type will be skipped 630 * to #CX_JSON_NOTHING and values of such type will be skipped

mercurial