|
Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
|
#include "yyjson.h"Go to the source code of this file.
Data Structures | |
| struct | v16 |
| struct | v32 |
| struct | v64 |
| union | v16_uni |
| union | v32_uni |
| union | v64_uni |
| struct | pool_chunk |
| struct | pool_ctx |
| struct | dyn_chunk |
| struct | dyn_ctx |
| struct | yyjson_incr_state |
| struct | yyjson_write_ctx |
| struct | yyjson_mut_write_ctx |
Macros | |
| #define | MSC_HAS_BIT_SCAN_64 0 |
| #define | MSC_HAS_BIT_SCAN 0 |
| #define | MSC_HAS_UMUL128 0 |
| #define | GCC_HAS_CLZLL 0 |
| #define | GCC_HAS_CTZLL 0 |
| #define | YYJSON_HAS_INT128 0 |
| #define | YYJSON_HAS_IEEE_754 0 |
| #define | YYJSON_DISABLE_FAST_FP_CONV 1 |
| #define | INFINITY ((double)(1.0 / 0.0)) |
| #define | NAN ((double)(0.0 / 0.0)) |
| #define | YYJSON_DOUBLE_MATH_CORRECT 1 |
| #define | YYJSON_BIG_ENDIAN 4321 |
| #define | YYJSON_LITTLE_ENDIAN 1234 |
| #define | YYJSON_ENDIAN 0 /* unknown endian, detect at run-time */ |
| #define | YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS 0 |
| #define | YYJSON_READER_ESTIMATED_PRETTY_RATIO 16 |
| #define | YYJSON_READER_ESTIMATED_MINIFY_RATIO 6 |
| #define | YYJSON_WRITER_ESTIMATED_PRETTY_RATIO 32 |
| #define | YYJSON_WRITER_ESTIMATED_MINIFY_RATIO 18 |
| #define | YYJSON_MUT_DOC_STR_POOL_INIT_SIZE 0x100 |
| #define | YYJSON_MUT_DOC_STR_POOL_MAX_SIZE 0x10000000 |
| #define | YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE (0x10 * sizeof(yyjson_mut_val)) |
| #define | YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE (0x1000000 * sizeof(yyjson_mut_val)) |
| #define | YYJSON_ALC_DYN_MIN_SIZE 0x1000 |
| #define | repeat2(x) |
| #define | repeat4(x) |
| #define | repeat8(x) |
| #define | repeat16(x) |
| #define | repeat2_incr(x) |
| #define | repeat4_incr(x) |
| #define | repeat8_incr(x) |
| #define | repeat16_incr(x) |
| #define | repeat_in_1_18(x) |
| #define | likely(x) |
| #define | unlikely(x) |
| #define | static_inline static yyjson_inline |
| #define | static_noinline static yyjson_noinline |
| #define | yyjson_min(x, y) |
| #define | yyjson_max(x, y) |
| #define | U64(hi, lo) |
| #define | U32(hi) |
| #define | constcast yyjson_constcast |
| #define | gcc_load_barrier(val) |
| #define | gcc_store_barrier(val) |
| #define | gcc_full_barrier(val) |
| #define | MSG_FOPEN "failed to open file" |
| #define | MSG_FREAD "failed to read file" |
| #define | MSG_FWRITE "failed to write file" |
| #define | MSG_FCLOSE "failed to close file" |
| #define | MSG_MALLOC "failed to allocate memory" |
| #define | MSG_CHAR_T "invalid literal, expected 'true'" |
| #define | MSG_CHAR_F "invalid literal, expected 'false'" |
| #define | MSG_CHAR_N "invalid literal, expected 'null'" |
| #define | MSG_CHAR "unexpected character, expected a JSON value" |
| #define | MSG_ARR_END "unexpected character, expected ',' or ']'" |
| #define | MSG_OBJ_KEY "unexpected character, expected a string key" |
| #define | MSG_OBJ_SEP "unexpected character, expected ':' after key" |
| #define | MSG_OBJ_END "unexpected character, expected ',' or '}'" |
| #define | MSG_GARBAGE "unexpected content after document" |
| #define | MSG_NOT_END "unexpected end of data" |
| #define | MSG_COMMENT "unclosed multiline comment" |
| #define | MSG_COMMA "trailing comma is not allowed" |
| #define | MSG_NAN_INF "nan or inf number is not allowed" |
| #define | MSG_ERR_TYPE "invalid JSON value type" |
| #define | MSG_ERR_BOM "UTF-8 byte order mark (BOM) is not supported" |
| #define | MSG_ERR_UTF8 "invalid utf-8 encoding in string" |
| #define | MSG_ERR_UTF16 "UTF-16 encoding is not supported" |
| #define | MSG_ERR_UTF32 "UTF-32 encoding is not supported" |
| #define | MSG_DEPTH "depth limit exceeded" |
| #define | U64_MAX U64(0xFFFFFFFF, 0xFFFFFFFF) |
| #define | I64_MAX U64(0x7FFFFFFF, 0xFFFFFFFF) |
| #define | USIZE_MAX ((usize)(~(usize)0)) |
| #define | U32_SAFE_DIG 9 /* u32 max is 4294967295, 10 digits */ |
| #define | U64_SAFE_DIG 19 /* u64 max is 18446744073709551615, 20 digits */ |
| #define | USIZE_SAFE_DIG (sizeof(usize) == 8 ? U64_SAFE_DIG : U32_SAFE_DIG) |
| #define | F64_BITS_INF U64(0x7FF00000, 0x00000000) |
| #define | F64_BITS_NAN U64(0x7FF80000, 0x00000000) |
| #define | F64_MAX_DEC_DIG 768 |
| #define | F64_MAX_DEC_EXP 308 |
| #define | F64_MIN_DEC_EXP (-324) |
| #define | F64_MAX_BIN_EXP 1024 |
| #define | F64_MIN_BIN_EXP (-1021) |
| #define | F32_BITS 32 |
| #define | F64_BITS 64 |
| #define | F32_EXP_BITS 8 |
| #define | F64_EXP_BITS 11 |
| #define | F32_SIG_BITS 23 |
| #define | F64_SIG_BITS 52 |
| #define | F32_SIG_FULL_BITS 24 |
| #define | F64_SIG_FULL_BITS 53 |
| #define | F32_SIG_MASK U32(0x007FFFFF) |
| #define | F64_SIG_MASK U64(0x000FFFFF, 0xFFFFFFFF) |
| #define | F32_EXP_MASK U32(0x7F800000) |
| #define | F64_EXP_MASK U64(0x7FF00000, 0x00000000) |
| #define | F32_EXP_BIAS 127 |
| #define | F64_EXP_BIAS 1023 |
| #define | F32_DEC_DIG 9 |
| #define | F64_DEC_DIG 17 |
| #define | FP_BUF_LEN 40 |
| #define | INCR_NUM_MAX_LEN 1024 |
| #define | byte_move_idx(x) |
| #define | byte_move_src(x) |
| #define | byte_move_dst(x) |
| #define | CHAR_TYPE_ASCII (1 << 0) /* Except: ["\], [0x00-0x1F, 0x80-0xFF] */ |
| #define | CHAR_TYPE_ASCII_SQ (1 << 1) /* Except: ['\], [0x00-0x1F, 0x80-0xFF] */ |
| #define | CHAR_TYPE_SPACE (1 << 2) /* Whitespace: [ \t\n\r] */ |
| #define | CHAR_TYPE_SPACE_EXT (1 << 3) /* Whitespace: [ \t\n\r\v\f], JSON5 */ |
| #define | CHAR_TYPE_NUM (1 << 4) /* Number: [.-+0-9] */ |
| #define | CHAR_TYPE_COMMENT (1 << 5) /* Comment: [/] */ |
| #define | CHAR_TYPE_EOL (1 << 0) /* End of line: [\r\n] */ |
| #define | CHAR_TYPE_EOL_EXT (1 << 1) /* End of line: [\r\n], JSON5 */ |
| #define | CHAR_TYPE_ID_START (1 << 2) /* ID start: [_$A-Za-z\], U+0080+ */ |
| #define | CHAR_TYPE_ID_NEXT (1 << 3) /* ID next: [_$A-Za-z0-9\], U+0080+ */ |
| #define | CHAR_TYPE_ID_ASCII (1 << 4) /* ID next ASCII: [_$A-Za-z0-9] */ |
| #define | CHAR_TYPE_SIGN (1 << 0) /* [-+] */ |
| #define | CHAR_TYPE_DIGIT (1 << 1) /* [0-9] */ |
| #define | CHAR_TYPE_NONZERO (1 << 2) /* [1-9] */ |
| #define | CHAR_TYPE_EXP (1 << 3) /* [eE] */ |
| #define | CHAR_TYPE_DOT (1 << 4) /* [.] */ |
| #define | utf8_seq_def(name, a, b, c, d) |
| #define | utf8_seq(name) |
| #define | is_utf8_seq1(uni) |
| #define | is_utf8_seq2(uni) |
| #define | is_utf8_seq3(uni) |
| #define | is_utf8_seq4(uni) |
| #define | YYJSON_FOPEN_E |
| #define | has_flg(_flg) |
| #define | has_allow(_flg) |
| #define | YYJSON_READ_ALLOW_TRIVIA |
| #define | return_err(_pos, _msg) |
| #define | return_raw() |
| #define | return_err(_pos, _msg) |
| #define | return_0() |
| #define | return_i64(_v) |
| #define | return_f64(_v) |
| #define | return_f64_bin(_v) |
| #define | return_inf() |
| #define | return_raw() |
| #define | expr_intg(i) |
| #define | return_err(_end, _msg) |
| #define | return_err(_end, _msg) |
| #define | expr_jump(i) |
| #define | expr_stop(i) |
| #define | expr_jump(i) |
| #define | expr_stop(i) |
| #define | expr_jump(i) |
| #define | expr_jump(i) |
| #define | expr_jump(i) |
| #define | return_err(_end, _msg) |
| #define | return_suc(_str_end, _cur_end) |
| #define | expr_jump(i) |
| #define | expr_stop(i) |
| #define | expr_jump(i) |
| #define | expr_jump(i) |
| #define | return_err(_pos, _code, _msg) |
| #define | return_err(_pos, _code, _msg) |
| #define | val_incr() |
| #define | return_err(_pos, _code, _msg) |
| #define | val_incr() |
| #define | return_err(_pos, _code, _msg) |
| #define | return_err(_code, _msg) |
| #define | return_err(_code, _msg) |
| #define | return_err(_pos, _code, _msg) |
| #define | LABEL_doc_begin 0 |
| #define | LABEL_arr_val_begin 1 |
| #define | LABEL_arr_val_end 2 |
| #define | LABEL_obj_key_begin 3 |
| #define | LABEL_obj_key_end 4 |
| #define | LABEL_obj_val_begin 5 |
| #define | LABEL_obj_val_end 6 |
| #define | LABEL_doc_end 7 |
| #define | return_err_inv_param(_msg) |
| #define | return_err(_pos, _code, _msg) |
| #define | val_incr() |
| #define | save_incr_state(_label) |
| #define | check_maybe_truncated_number() |
| #define | has_flg(_flg) |
| #define | has_allow(_flg) |
| #define | snprintf_num(buf, len, fmt, dig, val) |
| #define | CHAR_ENC_CPY_1 0 /* 1-byte UTF-8, copy. */ |
| #define | CHAR_ENC_ERR_1 1 /* 1-byte UTF-8, error. */ |
| #define | CHAR_ENC_ESC_A 2 /* 1-byte ASCII, escaped as '\x'. */ |
| #define | CHAR_ENC_ESC_1 3 /* 1-byte UTF-8, escaped as '\uXXXX'. */ |
| #define | CHAR_ENC_CPY_2 4 /* 2-byte UTF-8, copy. */ |
| #define | CHAR_ENC_ESC_2 5 /* 2-byte UTF-8, escaped as '\uXXXX'. */ |
| #define | CHAR_ENC_CPY_3 6 /* 3-byte UTF-8, copy. */ |
| #define | CHAR_ENC_ESC_3 7 /* 3-byte UTF-8, escaped as '\uXXXX'. */ |
| #define | CHAR_ENC_CPY_4 8 /* 4-byte UTF-8, copy. */ |
| #define | CHAR_ENC_ESC_4 9 /* 4-byte UTF-8, escaped as '\uXXXX\uXXXX'. */ |
| #define | expr_jump(i) |
| #define | expr_stop(i) |
| #define | return_err(_code, _msg) |
| #define | return_err(_code, _msg) |
| #define | incr_len(_len) |
| #define | check_str_len(_len) |
| #define | return_err(_code, _msg) |
| #define | incr_len(_len) |
| #define | check_str_len(_len) |
| #define | return_err(_code, _msg) |
| #define | incr_len(_len) |
| #define | check_str_len(_len) |
| #define | return_err(_code, _msg) |
| #define | incr_len(_len) |
| #define | check_str_len(_len) |
| #define | return_err(_code, _msg) |
| #define | incr_len(_len) |
| #define | check_str_len(_len) |
| #define | return_err(_ret, _code, _pos, _msg) |
| #define | return_err_resolve(_ret, _pos) |
| #define | return_err_syntax(_ret, _pos) |
| #define | return_err_alloc(_ret) |
| #define | return_err(_code, _msg) |
| #define | return_err_copy() |
| #define | return_err_key(_key) |
| #define | return_err_val(_key) |
| #define | ptr_get(_ptr) |
| #define | ptr_add(_ptr, _val) |
| #define | ptr_remove(_ptr) |
| #define | ptr_replace(_ptr, _val) |
Typedefs | |
| typedef float | f32 |
| typedef double | f64 |
| typedef int8_t | i8 |
| typedef uint8_t | u8 |
| typedef int16_t | i16 |
| typedef uint16_t | u16 |
| typedef int32_t | i32 |
| typedef uint32_t | u32 |
| typedef int64_t | i64 |
| typedef uint64_t | u64 |
| typedef size_t | usize |
| typedef struct v16 | v16 |
| typedef struct v32 | v32 |
| typedef struct v64 | v64 |
| typedef union v16_uni | v16_uni |
| typedef union v32_uni | v32_uni |
| typedef union v64_uni | v64_uni |
| typedef struct pool_chunk | pool_chunk |
| typedef struct pool_ctx | pool_ctx |
| typedef struct dyn_chunk | dyn_chunk |
| typedef u8 | char_enc_type |
| typedef struct yyjson_write_ctx | yyjson_write_ctx |
| typedef struct yyjson_mut_write_ctx | yyjson_mut_write_ctx |
| typedef enum patch_op | patch_op |
Enumerations | |
| enum | patch_op { PATCH_OP_ADD , PATCH_OP_REMOVE , PATCH_OP_REPLACE , PATCH_OP_MOVE , PATCH_OP_COPY , PATCH_OP_TEST , PATCH_OP_NONE } |
Variables | |
| static const u8 | char_table1 [256] |
| static const u8 | char_table2 [256] |
| static const u8 | char_table3 [256] |
| static const u8 | hex_conv_table [256] |
| static const yyjson_alc | YYJSON_NULL_ALC |
| static const yyjson_alc | YYJSON_DEFAULT_ALC |
| static const char_enc_type | enc_table_cpy [256] |
| static const char_enc_type | enc_table_cpy_slash [256] |
| static const char_enc_type | enc_table_esc [256] |
| static const char_enc_type | enc_table_esc_slash [256] |
| #define byte_move_dst | ( | x | ) |
Definition at line 567 of file yyjson.c.
Referenced by byte_move_16(), byte_move_2(), byte_move_4(), and byte_move_8().
| #define byte_move_idx | ( | x | ) |
Definition at line 565 of file yyjson.c.
Referenced by byte_copy_16(), byte_copy_2(), byte_copy_4(), and byte_copy_8().
| #define byte_move_src | ( | x | ) |
Definition at line 566 of file yyjson.c.
Referenced by byte_move_16(), byte_move_2(), byte_move_4(), and byte_move_8().
| #define CHAR_ENC_CPY_1 0 /* 1-byte UTF-8, copy. */ |
Definition at line 8475 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_CPY_2 4 /* 2-byte UTF-8, copy. */ |
Definition at line 8479 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_CPY_3 6 /* 3-byte UTF-8, copy. */ |
Definition at line 8481 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_CPY_4 8 /* 4-byte UTF-8, copy. */ |
Definition at line 8483 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ERR_1 1 /* 1-byte UTF-8, error. */ |
Definition at line 8476 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ESC_1 3 /* 1-byte UTF-8, escaped as '\uXXXX'. */ |
Definition at line 8478 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ESC_2 5 /* 2-byte UTF-8, escaped as '\uXXXX'. */ |
Definition at line 8480 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ESC_3 7 /* 3-byte UTF-8, escaped as '\uXXXX'. */ |
Definition at line 8482 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ESC_4 9 /* 4-byte UTF-8, escaped as '\uXXXX\uXXXX'. */ |
Definition at line 8484 of file yyjson.c.
Referenced by write_str().
| #define CHAR_ENC_ESC_A 2 /* 1-byte ASCII, escaped as '\x'. */ |
Definition at line 8477 of file yyjson.c.
Referenced by write_str().
| #define CHAR_TYPE_ASCII (1 << 0) /* Except: ["\], [0x00-0x1F, 0x80-0xFF] */ |
Definition at line 749 of file yyjson.c.
Referenced by char_is_ascii_skip().
| #define CHAR_TYPE_ASCII_SQ (1 << 1) /* Except: ['\], [0x00-0x1F, 0x80-0xFF] */ |
Definition at line 750 of file yyjson.c.
Referenced by char_is_ascii_skip_sq().
| #define CHAR_TYPE_COMMENT (1 << 5) /* Comment: [/] */ |
Definition at line 754 of file yyjson.c.
Referenced by char_is_trivia().
| #define CHAR_TYPE_DIGIT (1 << 1) /* [0-9] */ |
Definition at line 765 of file yyjson.c.
Referenced by char_is_digit(), and char_is_digit_or_fp().
| #define CHAR_TYPE_DOT (1 << 4) /* [.] */ |
Definition at line 768 of file yyjson.c.
Referenced by char_is_digit_or_fp(), and char_is_fp().
| #define CHAR_TYPE_EOL (1 << 0) /* End of line: [\r\n] */ |
Definition at line 757 of file yyjson.c.
Referenced by char_is_eol().
| #define CHAR_TYPE_EOL_EXT (1 << 1) /* End of line: [\r\n], JSON5 */ |
Definition at line 758 of file yyjson.c.
Referenced by char_is_eol_ext().
| #define CHAR_TYPE_EXP (1 << 3) /* [eE] */ |
Definition at line 767 of file yyjson.c.
Referenced by char_is_digit_or_fp(), char_is_exp(), and char_is_fp().
| #define CHAR_TYPE_ID_ASCII (1 << 4) /* ID next ASCII: [_$A-Za-z0-9] */ |
Definition at line 761 of file yyjson.c.
Referenced by char_is_id_ascii().
| #define CHAR_TYPE_ID_NEXT (1 << 3) /* ID next: [_$A-Za-z0-9\], U+0080+ */ |
Definition at line 760 of file yyjson.c.
Referenced by char_is_id_next().
| #define CHAR_TYPE_ID_START (1 << 2) /* ID start: [_$A-Za-z\], U+0080+ */ |
Definition at line 759 of file yyjson.c.
Referenced by char_is_id_start().
| #define CHAR_TYPE_NONZERO (1 << 2) /* [1-9] */ |
Definition at line 766 of file yyjson.c.
Referenced by char_is_nonzero().
| #define CHAR_TYPE_NUM (1 << 4) /* Number: [.-+0-9] */ |
Definition at line 753 of file yyjson.c.
Referenced by char_is_num().
| #define CHAR_TYPE_SIGN (1 << 0) /* [-+] */ |
Definition at line 764 of file yyjson.c.
Referenced by char_is_sign().
| #define CHAR_TYPE_SPACE (1 << 2) /* Whitespace: [ \t\n\r] */ |
Definition at line 751 of file yyjson.c.
Referenced by char_is_space().
| #define CHAR_TYPE_SPACE_EXT (1 << 3) /* Whitespace: [ \t\n\r\v\f], JSON5 */ |
Definition at line 752 of file yyjson.c.
Referenced by char_is_space_ext(), and char_is_trivia().
| #define check_maybe_truncated_number | ( | ) |
Referenced by yyjson_incr_read().
| #define check_str_len | ( | _len | ) |
| #define check_str_len | ( | _len | ) |
| #define check_str_len | ( | _len | ) |
| #define check_str_len | ( | _len | ) |
| #define check_str_len | ( | _len | ) |
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define constcast yyjson_constcast |
Definition at line 390 of file yyjson.c.
Referenced by mut_write_root(), mut_write_root_minify(), mut_write_root_pretty(), unsafe_yyjson_mut_equals(), unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_ptr_getx(), write_root(), write_root_minify(), write_root_pretty(), yyjson_mut_patch(), yyjson_mut_val_write_file(), yyjson_mut_val_write_fp(), yyjson_read_number(), yyjson_val_mut_copy(), yyjson_val_write_file(), and yyjson_val_write_fp().
| #define expr_intg | ( | i | ) |
Referenced by read_num().
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
| #define expr_jump | ( | i | ) |
Referenced by read_str_id(), read_str_opt(), and write_str().
| #define expr_stop | ( | i | ) |
| #define expr_stop | ( | i | ) |
| #define expr_stop | ( | i | ) |
| #define expr_stop | ( | i | ) |
Referenced by read_str_id(), read_str_opt(), and write_str().
| #define F32_DEC_DIG 9 |
Definition at line 515 of file yyjson.c.
Referenced by write_f32_raw().
| #define F64_BITS_INF U64(0x7FF00000, 0x00000000) |
Definition at line 462 of file yyjson.c.
Referenced by f64_bits_inf(), and f64_is_inf().
| #define F64_BITS_NAN U64(0x7FF80000, 0x00000000) |
Definition at line 468 of file yyjson.c.
Referenced by f64_bits_nan().
| #define F64_DEC_DIG 17 |
Definition at line 516 of file yyjson.c.
Referenced by write_f64_raw().
| #define F64_EXP_MASK U64(0x7FF00000, 0x00000000) |
Definition at line 508 of file yyjson.c.
Referenced by f64_is_inf().
| #define FP_BUF_LEN 40 |
Definition at line 519 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define gcc_store_barrier | ( | val | ) |
Definition at line 409 of file yyjson.c.
Referenced by read_str_id(), and read_str_opt().
| #define has_allow | ( | _flg | ) |
| #define has_allow | ( | _flg | ) |
Definition at line 3120 of file yyjson.c.
Referenced by is_truncated_end(), mut_write_root_minify(), mut_write_root_pretty(), read_inf(), read_nan(), read_num(), read_num_raw(), read_root_minify(), read_root_pretty(), read_root_single(), read_str_id(), read_str_opt(), skip_trivia(), write_fp_reformat(), write_root_minify(), write_root_pretty(), write_root_single(), and yyjson_read_opts().
| #define has_flg | ( | _flg | ) |
| #define has_flg | ( | _flg | ) |
Definition at line 3119 of file yyjson.c.
Referenced by get_enc_table_with_flag(), get_hex_table_with_flag(), mut_write_root_minify(), mut_write_root_pretty(), read_inf(), read_nan(), read_num(), read_num_hex(), read_root_minify(), read_root_pretty(), read_root_single(), write_fp_reformat(), write_root_minify(), write_root_pretty(), write_root_single(), yyjson_incr_new(), yyjson_incr_read(), and yyjson_read_opts().
| #define incr_len | ( | _len | ) |
| #define incr_len | ( | _len | ) |
| #define incr_len | ( | _len | ) |
| #define incr_len | ( | _len | ) |
| #define incr_len | ( | _len | ) |
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define INFINITY ((double)(1.0 / 0.0)) |
Definition at line 148 of file yyjson.c.
Referenced by f64_bits_inf(), and f64_is_inf().
| #define is_utf8_seq1 | ( | uni | ) |
Referenced by read_str_opt().
| #define is_utf8_seq2 | ( | uni | ) |
Referenced by read_str_id(), read_str_opt(), and write_str().
| #define is_utf8_seq3 | ( | uni | ) |
Referenced by read_str_id(), read_str_opt(), and write_str().
| #define is_utf8_seq4 | ( | uni | ) |
Referenced by read_str_id(), read_str_opt(), and write_str().
| #define LABEL_arr_val_begin 1 |
Definition at line 6547 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_arr_val_end 2 |
Definition at line 6548 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_doc_begin 0 |
Definition at line 6546 of file yyjson.c.
Referenced by yyjson_incr_new(), and yyjson_incr_read().
| #define LABEL_doc_end 7 |
Definition at line 6553 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_obj_key_begin 3 |
Definition at line 6549 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_obj_key_end 4 |
Definition at line 6550 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_obj_val_begin 5 |
Definition at line 6551 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define LABEL_obj_val_end 6 |
Definition at line 6552 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define likely | ( | x | ) |
Definition at line 367 of file yyjson.c.
Referenced by dyn_realloc(), mut_write_root_minify(), mut_write_root_pretty(), ptr_new_key(), ptr_next_token(), ptr_token_eq(), read_false(), read_null(), read_root_minify(), read_root_pretty(), read_root_single(), read_str_id(), read_str_opt(), read_true(), read_uni_esc(), write_num(), write_root_minify(), write_root_pretty(), write_root_single(), write_str(), yyjson_incr_read(), yyjson_locate_pos(), yyjson_mut_write_opts(), yyjson_read_opts(), and yyjson_write_number().
| #define MSG_ARR_END "unexpected character, expected ',' or ']'" |
Definition at line 429 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define MSG_CHAR "unexpected character, expected a JSON value" |
Definition at line 428 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_CHAR_F "invalid literal, expected 'false'" |
Definition at line 426 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_CHAR_N "invalid literal, expected 'null'" |
Definition at line 427 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_CHAR_T "invalid literal, expected 'true'" |
Definition at line 425 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_COMMA "trailing comma is not allowed" |
Definition at line 436 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define MSG_COMMENT "unclosed multiline comment" |
Definition at line 435 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_read_opts().
| #define MSG_DEPTH "depth limit exceeded" |
Definition at line 443 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_ERR_BOM "UTF-8 byte order mark (BOM) is not supported" |
Definition at line 439 of file yyjson.c.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| #define MSG_ERR_TYPE "invalid JSON value type" |
Definition at line 438 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define MSG_ERR_UTF16 "UTF-16 encoding is not supported" |
Definition at line 441 of file yyjson.c.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| #define MSG_ERR_UTF32 "UTF-32 encoding is not supported" |
Definition at line 442 of file yyjson.c.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| #define MSG_ERR_UTF8 "invalid utf-8 encoding in string" |
Definition at line 440 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), read_str_id(), read_str_opt(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define MSG_FCLOSE "failed to close file" |
Definition at line 423 of file yyjson.c.
Referenced by write_dat_to_file().
| #define MSG_FOPEN "failed to open file" |
Definition at line 420 of file yyjson.c.
Referenced by write_dat_to_file().
| #define MSG_FREAD "failed to read file" |
Definition at line 421 of file yyjson.c.
Referenced by yyjson_read_file(), and yyjson_read_fp().
| #define MSG_FWRITE "failed to write file" |
Definition at line 422 of file yyjson.c.
Referenced by write_dat_to_file().
| #define MSG_GARBAGE "unexpected content after document" |
Definition at line 433 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| #define MSG_MALLOC "failed to allocate memory" |
Definition at line 424 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), read_root_minify(), read_root_pretty(), read_root_single(), write_root_minify(), write_root_pretty(), write_root_single(), yyjson_incr_read(), yyjson_read_fp(), yyjson_read_number(), and yyjson_read_opts().
| #define MSG_NAN_INF "nan or inf number is not allowed" |
Definition at line 437 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| #define MSG_NOT_END "unexpected end of data" |
Definition at line 434 of file yyjson.c.
Referenced by yyjson_incr_read().
| #define MSG_OBJ_END "unexpected character, expected ',' or '}'" |
Definition at line 432 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define MSG_OBJ_KEY "unexpected character, expected a string key" |
Definition at line 430 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define MSG_OBJ_SEP "unexpected character, expected ':' after key" |
Definition at line 431 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define NAN ((double)(0.0 / 0.0)) |
Definition at line 154 of file yyjson.c.
Referenced by f64_bits_nan().
| #define ptr_add | ( | _ptr, | |
| _val ) |
Definition at line 11019 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define ptr_get | ( | _ptr | ) |
Definition at line 11017 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define ptr_remove | ( | _ptr | ) |
Definition at line 11021 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define ptr_replace | ( | _ptr, | |
| _val ) |
Definition at line 11023 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define repeat16 | ( | x | ) |
Definition at line 354 of file yyjson.c.
Referenced by read_root_pretty().
| #define repeat16_incr | ( | x | ) |
Definition at line 359 of file yyjson.c.
Referenced by byte_copy_16(), byte_move_16(), read_str_id(), read_str_opt(), and write_str().
| #define repeat2_incr | ( | x | ) |
Definition at line 356 of file yyjson.c.
Referenced by byte_copy_2(), and byte_move_2().
| #define repeat4 | ( | x | ) |
| #define repeat4_incr | ( | x | ) |
Definition at line 357 of file yyjson.c.
Referenced by byte_copy_4(), byte_move_4(), and write_str().
| #define repeat8 | ( | x | ) |
| #define repeat8_incr | ( | x | ) |
Definition at line 358 of file yyjson.c.
Referenced by byte_copy_8(), and byte_move_8().
| #define repeat_in_1_18 | ( | x | ) |
Definition at line 361 of file yyjson.c.
Referenced by read_num().
| #define return_0 | ( | ) |
Referenced by read_num().
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _code, | |
| _msg ) |
| #define return_err | ( | _end, | |
| _msg ) |
| #define return_err | ( | _end, | |
| _msg ) |
| #define return_err | ( | _end, | |
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _code, | |||
| _msg ) |
| #define return_err | ( | _pos, | |
| _msg ) |
| #define return_err | ( | _pos, | |
| _msg ) |
Definition at line 10698 of file yyjson.c.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), read_num(), read_num_raw(), read_root_minify(), read_root_pretty(), read_root_single(), read_str_id(), read_str_opt(), read_uni_esc(), write_dat_to_file(), write_root_minify(), write_root_pretty(), write_root_single(), yyjson_incr_read(), yyjson_mut_patch(), yyjson_patch(), yyjson_read_file(), yyjson_read_fp(), yyjson_read_number(), and yyjson_read_opts().
| #define return_err | ( | _ret, | |
| _code, | |||
| _pos, | |||
| _msg ) |
| #define return_err_alloc | ( | _ret | ) |
Definition at line 10711 of file yyjson.c.
Referenced by unsafe_yyjson_mut_ptr_putx().
| #define return_err_copy | ( | ) |
Definition at line 11010 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define return_err_inv_param | ( | _msg | ) |
Referenced by yyjson_incr_read().
| #define return_err_key | ( | _key | ) |
Definition at line 11012 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define return_err_resolve | ( | _ret, | |
| _pos ) |
Definition at line 10707 of file yyjson.c.
Referenced by unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_mut_ptr_putx(), and unsafe_yyjson_ptr_getx().
| #define return_err_syntax | ( | _ret, | |
| _pos ) |
Definition at line 10709 of file yyjson.c.
Referenced by unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_mut_ptr_putx(), and unsafe_yyjson_ptr_getx().
| #define return_err_val | ( | _key | ) |
Definition at line 11014 of file yyjson.c.
Referenced by yyjson_mut_patch(), and yyjson_patch().
| #define return_f64 | ( | _v | ) |
Referenced by read_num().
| #define return_f64_bin | ( | _v | ) |
| #define return_i64 | ( | _v | ) |
Referenced by read_num().
| #define return_inf | ( | ) |
Referenced by read_num().
| #define return_raw | ( | ) |
| #define return_raw | ( | ) |
Referenced by read_num(), and read_num_raw().
| #define return_suc | ( | _str_end, | |
| _cur_end ) |
Referenced by read_str_id().
| #define save_incr_state | ( | _label | ) |
Referenced by yyjson_incr_read().
| #define snprintf_num | ( | buf, | |
| len, | |||
| fmt, | |||
| dig, | |||
| val ) |
Definition at line 8283 of file yyjson.c.
Referenced by write_f32_raw(), write_f64_raw(), and write_f64_raw_fixed().
| #define static_inline static yyjson_inline |
Definition at line 373 of file yyjson.c.
Referenced by byte_copy_16(), byte_copy_2(), byte_copy_4(), byte_copy_8(), byte_load_2(), byte_load_3(), byte_load_4(), byte_match_2(), byte_match_4(), byte_move_16(), byte_move_2(), byte_move_4(), byte_move_8(), byte_move_forward(), char_is_ascii_skip(), char_is_ascii_skip_sq(), char_is_ctn(), char_is_digit(), char_is_digit_or_fp(), char_is_eol(), char_is_eol_ext(), char_is_exp(), char_is_fp(), char_is_hex(), char_is_id_ascii(), char_is_id_next(), char_is_id_start(), char_is_nonzero(), char_is_num(), char_is_sign(), char_is_space(), char_is_space_ext(), char_is_trivia(), char_to_lower(), dyn_chunk_list_add(), dyn_chunk_list_remove(), dyn_size_align(), ext_eol_len(), ext_space_len(), f32_to_bits(), f64_bits_inf(), f64_bits_nan(), f64_is_inf(), f64_to_bits(), f64_to_f32(), fopen_readonly(), fopen_safe(), fopen_writeonly(), fread_safe(), get_enc_table_with_flag(), get_hex_table_with_flag(), has_rflag(), has_wflag(), hex_load_2(), hex_load_4(), is_utf16_bom(), is_utf32_bom(), is_utf8_bom(), mem_align_up(), mut_write_root_minify(), mut_write_root_pretty(), mut_write_root_single(), pool_size_align(), ptr_arr_get(), ptr_mut_arr_get(), ptr_mut_obj_get(), ptr_new_key(), ptr_next_token(), ptr_obj_get(), ptr_token_eq(), ptr_token_to_idx(), read_false(), read_inf(), read_inf_or_nan(), read_nan(), read_null(), read_num(), read_root_minify(), read_root_pretty(), read_str(), read_str_con(), read_str_opt(), read_true(), read_uni_esc(), size_add_is_overflow(), size_align_down(), size_align_up(), size_is_pow2(), u128_mul(), u128_mul_add(), u64_lz_bits(), u64_tz_bits(), unsafe_yyjson_num_equals(), unsafe_yyjson_str_equals(), unsafe_yyjson_str_pool_release(), unsafe_yyjson_val_pool_release(), write_bool(), write_indent(), write_null(), write_num(), write_raw(), write_root_minify(), write_root_pretty(), write_root_single(), write_str(), write_str_noesc(), write_u32_len_1_to_8(), write_u32_len_4(), write_u32_len_5_to_8(), write_u32_len_8(), write_u64(), yyjson_mut_doc_estimated_val_num(), yyjson_mut_write_ctx_get(), yyjson_mut_write_ctx_set(), yyjson_write_ctx_get(), and yyjson_write_ctx_set().
| #define static_noinline static yyjson_noinline |
Definition at line 375 of file yyjson.c.
Referenced by is_truncated_end(), read_num_hex(), read_num_raw(), read_root_single(), read_str_id(), read_str_sq(), skip_trivia(), write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), and write_fp_reformat().
| #define U32 | ( | hi | ) |
| #define U32_SAFE_DIG 9 /* u32 max is 4294967295, 10 digits */ |
| #define U64 | ( | hi, | |
| lo ) |
Definition at line 385 of file yyjson.c.
Referenced by u64_lz_bits(), and u64_tz_bits().
| #define U64_MAX U64(0xFFFFFFFF, 0xFFFFFFFF) |
Definition at line 447 of file yyjson.c.
Referenced by read_num().
| #define U64_SAFE_DIG 19 /* u64 max is 18446744073709551615, 20 digits */ |
| #define unlikely | ( | x | ) |
Definition at line 369 of file yyjson.c.
Referenced by dyn_malloc(), dyn_realloc(), dyn_size_align(), mut_write_root(), mut_write_root_minify(), mut_write_root_pretty(), pool_malloc(), pool_realloc(), ptr_arr_get(), ptr_mut_arr_get(), ptr_mut_obj_get(), ptr_new_key(), ptr_obj_get(), ptr_token_to_idx(), read_num(), read_num_hex(), read_num_raw(), read_root_minify(), read_root_pretty(), read_root_single(), read_str_opt(), read_uni_esc(), unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_mut_ptr_putx(), unsafe_yyjson_mut_val_mut_copy(), unsafe_yyjson_ptr_getx(), unsafe_yyjson_str_pool_grow(), unsafe_yyjson_val_pool_grow(), write_fp_reformat(), write_root(), write_root_minify(), write_root_pretty(), write_root_single(), write_str(), yyjson_alc_dyn_free(), yyjson_alc_dyn_new(), yyjson_alc_pool_init(), yyjson_incr_new(), yyjson_incr_read(), yyjson_merge_patch(), yyjson_mut_merge_patch(), yyjson_mut_patch(), yyjson_mut_val_write_buf(), yyjson_mut_val_write_file(), yyjson_mut_val_write_fp(), yyjson_patch(), yyjson_read_file(), yyjson_read_fp(), yyjson_read_number(), yyjson_read_opts(), yyjson_val_write_buf(), yyjson_val_write_file(), yyjson_val_write_fp(), and yyjson_write_number().
Definition at line 451 of file yyjson.c.
Referenced by mut_write_root_pretty(), ptr_mut_arr_get(), ptr_token_to_idx(), read_root_minify(), read_root_pretty(), unsafe_yyjson_str_pool_grow(), unsafe_yyjson_val_pool_grow(), write_root_pretty(), yyjson_incr_new(), yyjson_incr_read(), yyjson_mut_doc_set_str_pool_size(), yyjson_mut_doc_set_val_pool_size(), and yyjson_read_opts().
| #define USIZE_SAFE_DIG (sizeof(usize) == 8 ? U64_SAFE_DIG : U32_SAFE_DIG) |
Definition at line 459 of file yyjson.c.
Referenced by ptr_token_to_idx().
| #define utf8_seq | ( | name | ) |
| #define utf8_seq_def | ( | name, | |
| a, | |||
| b, | |||
| c, | |||
| d ) |
Definition at line 1106 of file yyjson.c.
Referenced by utf8_seq_def().
| #define val_incr | ( | ) |
| #define val_incr | ( | ) |
| #define val_incr | ( | ) |
Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().
| #define YYJSON_ALC_DYN_MIN_SIZE 0x1000 |
Definition at line 338 of file yyjson.c.
Referenced by dyn_size_align().
| #define YYJSON_ENDIAN 0 /* unknown endian, detect at run-time */ |
| #define YYJSON_FOPEN_E |
Definition at line 2102 of file yyjson.c.
Referenced by fopen_readonly(), and fopen_writeonly().
| #define yyjson_max | ( | x, | |
| y ) |
Definition at line 381 of file yyjson.c.
Referenced by unsafe_yyjson_str_pool_grow(), and unsafe_yyjson_val_pool_grow().
| #define yyjson_min | ( | x, | |
| y ) |
Definition at line 379 of file yyjson.c.
Referenced by read_root_minify(), read_root_pretty(), unsafe_yyjson_str_pool_grow(), unsafe_yyjson_val_pool_grow(), and yyjson_incr_read().
| #define YYJSON_MUT_DOC_STR_POOL_INIT_SIZE 0x100 |
Definition at line 332 of file yyjson.c.
Referenced by yyjson_mut_doc_new().
| #define YYJSON_MUT_DOC_STR_POOL_MAX_SIZE 0x10000000 |
Definition at line 333 of file yyjson.c.
Referenced by yyjson_mut_doc_new().
| #define YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE (0x10 * sizeof(yyjson_mut_val)) |
Definition at line 334 of file yyjson.c.
Referenced by yyjson_mut_doc_new().
| #define YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE (0x1000000 * sizeof(yyjson_mut_val)) |
Definition at line 335 of file yyjson.c.
Referenced by yyjson_mut_doc_new().
| #define YYJSON_READ_ALLOW_TRIVIA |
| #define YYJSON_READER_ESTIMATED_MINIFY_RATIO 6 |
Definition at line 327 of file yyjson.c.
Referenced by read_root_minify(), and yyjson_incr_read().
| #define YYJSON_READER_ESTIMATED_PRETTY_RATIO 16 |
Definition at line 326 of file yyjson.c.
Referenced by read_root_pretty().
| #define YYJSON_WRITER_ESTIMATED_MINIFY_RATIO 18 |
Definition at line 329 of file yyjson.c.
Referenced by mut_write_root_minify(), and write_root_minify().
| #define YYJSON_WRITER_ESTIMATED_PRETTY_RATIO 32 |
Definition at line 328 of file yyjson.c.
Referenced by mut_write_root_pretty(), and write_root_pretty().
| typedef u8 char_enc_type |
| typedef struct dyn_chunk dyn_chunk |
memory chunk header
| typedef struct pool_chunk pool_chunk |
memory chunk header
| typedef struct pool_ctx pool_ctx |
allocator ctx header
| typedef struct v16 v16 |
128-bit integer, used by floating-point number reader and writer. 16/32/64-bit vector
| typedef union v16_uni v16_uni |
16/32/64-bit vector union
| typedef struct v32 v32 |
| typedef union v32_uni v32_uni |
| typedef struct v64 v64 |
| typedef union v64_uni v64_uni |
| typedef struct yyjson_mut_write_ctx yyjson_mut_write_ctx |
| typedef struct yyjson_write_ctx yyjson_write_ctx |
| enum patch_op |
| static_inline void byte_copy_16 | ( | void * | dst, |
| const void * | src ) |
Same as memcpy(dst, src, 16), no overlap.
Definition at line 597 of file yyjson.c.
References byte_move_idx, repeat16_incr, and static_inline.
Referenced by write_str(), and write_str_noesc().
| static_inline void byte_copy_2 | ( | void * | dst, |
| const void * | src ) |
Same as memcpy(dst, src, 2), no overlap.
Definition at line 570 of file yyjson.c.
References byte_move_idx, repeat2_incr, and static_inline.
Referenced by read_str_id(), read_str_opt(), write_fp_reformat(), write_root_single(), write_str(), write_u32_len_1_to_8(), write_u32_len_4(), write_u32_len_5_to_8(), and write_u32_len_8().
| static_inline void byte_copy_4 | ( | void * | dst, |
| const void * | src ) |
Same as memcpy(dst, src, 4), no overlap.
Definition at line 579 of file yyjson.c.
References byte_move_idx, repeat4_incr, and static_inline.
Referenced by read_str_id(), read_str_opt(), write_fp_reformat(), write_indent(), write_str(), and write_str_noesc().
| static_inline void byte_copy_8 | ( | void * | dst, |
| const void * | src ) |
Same as memcpy(dst, src, 8), no overlap.
Definition at line 588 of file yyjson.c.
References byte_move_idx, repeat8_incr, and static_inline.
Referenced by write_bool(), write_fp_reformat(), and write_null().
| static_inline u16 byte_load_2 | ( | const void * | src | ) |
Loads 2 bytes from src as a u16 (native-endian).
Definition at line 700 of file yyjson.c.
References v16::c, static_inline, v16_uni::u, and v16_uni::v.
Referenced by ext_space_len(), is_utf16_bom(), and write_str().
| static_inline u32 byte_load_3 | ( | const void * | src | ) |
Loads 3 bytes from src as a u32 (native-endian).
Definition at line 712 of file yyjson.c.
References v32::c, static_inline, v32_uni::u, and v32_uni::v.
Referenced by ext_space_len(), is_utf8_bom(), and write_str().
| static_inline u32 byte_load_4 | ( | const void * | src | ) |
Loads 4 bytes from src as a u32 (native-endian).
Definition at line 728 of file yyjson.c.
References v32::c, static_inline, v32_uni::u, and v32_uni::v.
Referenced by is_utf32_bom(), read_str_id(), read_str_opt(), and write_str().
| static_inline bool byte_match_2 | ( | void * | buf, |
| const char * | pat ) |
Same as memcmp(buf, pat, 2) == 0.
Definition at line 672 of file yyjson.c.
References static_inline, and v16_uni::u.
Referenced by read_root_pretty(), read_str_id(), read_uni_esc(), and skip_trivia().
| static_inline bool byte_match_4 | ( | void * | buf, |
| const char * | pat ) |
Same as memcmp(buf, pat, 4) == 0.
Definition at line 685 of file yyjson.c.
References static_inline, and v32_uni::u.
Referenced by read_false(), read_null(), and read_true().
| static_inline void byte_move_16 | ( | void * | dst, |
| const void * | src ) |
Same as memmove(dst, src, 16), allows overlap.
Definition at line 645 of file yyjson.c.
References byte_move_dst, byte_move_src, repeat16_incr, and static_inline.
Referenced by byte_move_forward(), read_str_id(), and read_str_opt().
| static_inline void byte_move_2 | ( | void * | dst, |
| const void * | src ) |
Same as memmove(dst, src, 2), allows overlap.
Definition at line 606 of file yyjson.c.
References byte_move_dst, byte_move_src, repeat2_incr, and static_inline.
Referenced by byte_move_forward().
| static_inline void byte_move_4 | ( | void * | dst, |
| const void * | src ) |
Same as memmove(dst, src, 4), allows overlap.
Definition at line 619 of file yyjson.c.
References byte_move_dst, byte_move_src, repeat4_incr, and static_inline.
Referenced by byte_move_forward().
| static_inline void byte_move_8 | ( | void * | dst, |
| const void * | src ) |
Same as memmove(dst, src, 8), allows overlap.
Definition at line 632 of file yyjson.c.
References byte_move_dst, byte_move_src, repeat8_incr, and static_inline.
Referenced by byte_move_forward().
| static_inline void byte_move_forward | ( | void * | dst, |
| void * | src, | ||
| usize | n ) |
Same as memmove(dst, src, n), but only dst <= src and n <= 16.
Definition at line 662 of file yyjson.c.
References byte_move_16(), byte_move_2(), byte_move_4(), byte_move_8(), and static_inline.
| static_inline bool char_is_ascii_skip | ( | u8 | c | ) |
Match an ASCII character in string: ["], [0x00-0x1F, 0x80-0xFF].
Definition at line 891 of file yyjson.c.
References char_table1, CHAR_TYPE_ASCII, and static_inline.
| static_inline bool char_is_ascii_skip_sq | ( | u8 | c | ) |
Match an ASCII character single-quoted: ['], [0x00-0x1F, 0x80-0xFF].
Definition at line 896 of file yyjson.c.
References char_table1, CHAR_TYPE_ASCII_SQ, and static_inline.
| static_inline bool char_is_ctn | ( | u8 | c | ) |
Match a JSON container: { or [.
Definition at line 962 of file yyjson.c.
References static_inline.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| static_inline bool char_is_digit | ( | u8 | d | ) |
Match a digit: [0-9]
Definition at line 941 of file yyjson.c.
References char_table3, CHAR_TYPE_DIGIT, and static_inline.
Referenced by read_num(), read_num_raw(), read_str_opt(), and write_fp_reformat().
| static_inline bool char_is_digit_or_fp | ( | u8 | d | ) |
Match a digit or floating point indicator: [0-9.eE].
Definition at line 956 of file yyjson.c.
References char_table3, CHAR_TYPE_DIGIT, CHAR_TYPE_DOT, CHAR_TYPE_EXP, and static_inline.
Referenced by read_num().
| static_inline bool char_is_eol | ( | u8 | c | ) |
Match a line end character: [\r
].
Definition at line 906 of file yyjson.c.
References char_table2, CHAR_TYPE_EOL, and static_inline.
Referenced by skip_trivia().
| static_inline bool char_is_eol_ext | ( | u8 | c | ) |
Match an extended line end character: [\r
], JSON5 line terminator.
Definition at line 911 of file yyjson.c.
References char_table2, CHAR_TYPE_EOL_EXT, and static_inline.
Referenced by skip_trivia().
| static_inline bool char_is_exp | ( | u8 | d | ) |
Match an exponent character: [eE].
Definition at line 946 of file yyjson.c.
References char_table3, CHAR_TYPE_EXP, and static_inline.
Referenced by read_num(), and read_num_raw().
| static_inline bool char_is_fp | ( | u8 | d | ) |
Match a floating point indicator: [.eE].
Definition at line 951 of file yyjson.c.
References char_table3, CHAR_TYPE_DOT, CHAR_TYPE_EXP, and static_inline.
Referenced by read_num(), and read_num_raw().
| static_inline bool char_is_hex | ( | u8 | c | ) |
Match a hexadecimal numeric character: [0-9a-fA-F].
Definition at line 1083 of file yyjson.c.
References hex_conv_table, and static_inline.
Referenced by is_truncated_end(), read_num_hex(), and read_num_raw().
| static_inline bool char_is_id_ascii | ( | u8 | c | ) |
Match an identifier name ASCII: [_$A-Za-z0-9].
Definition at line 926 of file yyjson.c.
References char_table2, CHAR_TYPE_ID_ASCII, and static_inline.
Referenced by read_str_id().
| static_inline bool char_is_id_next | ( | u8 | c | ) |
Match an identifier name next: [_$A-Za-z0-9], U+0080+.
Definition at line 921 of file yyjson.c.
References char_table2, CHAR_TYPE_ID_NEXT, and static_inline.
Referenced by read_str_id().
| static_inline bool char_is_id_start | ( | u8 | c | ) |
Match an identifier name start: [_$A-Za-z], U+0080+.
Definition at line 916 of file yyjson.c.
References char_table2, CHAR_TYPE_ID_START, and static_inline.
Referenced by read_root_minify(), and read_root_pretty().
| static_inline bool char_is_nonzero | ( | u8 | d | ) |
Match a non-zero digit: [1-9]
Definition at line 936 of file yyjson.c.
References char_table3, CHAR_TYPE_NONZERO, and static_inline.
| static_inline bool char_is_num | ( | u8 | c | ) |
Match a JSON number: [.-+0-9].
Definition at line 886 of file yyjson.c.
References char_table1, CHAR_TYPE_NUM, and static_inline.
Referenced by read_num(), read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| static_inline bool char_is_sign | ( | u8 | d | ) |
Match a sign: [+-]
Definition at line 931 of file yyjson.c.
References char_table3, CHAR_TYPE_SIGN, and static_inline.
Referenced by read_inf(), read_nan(), read_num(), and read_num_raw().
| static_inline bool char_is_space | ( | u8 | c | ) |
Match a whitespace: [ \t
\r].
Definition at line 876 of file yyjson.c.
References char_table1, CHAR_TYPE_SPACE, and static_inline.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), skip_trivia(), yyjson_incr_read(), and yyjson_read_opts().
| static_inline bool char_is_space_ext | ( | u8 | c | ) |
Match an extended whitespace: [ \t
\r\v\f], JSON5 whitespace.
Definition at line 881 of file yyjson.c.
References char_table1, CHAR_TYPE_SPACE_EXT, and static_inline.
Referenced by read_str_id(), and skip_trivia().
| static_inline bool char_is_trivia | ( | u8 | c | ) |
Match a trivia character: extended whitespace or comment.
Definition at line 901 of file yyjson.c.
References char_table1, CHAR_TYPE_COMMENT, CHAR_TYPE_SPACE_EXT, and static_inline.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_read_opts().
| static_inline u8 char_to_lower | ( | u8 | c | ) |
Convert ASCII letter to lowercase; valid only for [A-Za-z].
Definition at line 967 of file yyjson.c.
References static_inline.
Referenced by is_truncated_str(), read_inf(), read_nan(), and read_num_raw().
|
static |
| static_inline void dyn_chunk_list_add | ( | dyn_chunk * | list, |
| dyn_chunk * | chunk ) |
add a chunk to list header (the chunk must not be in the list)
Definition at line 2447 of file yyjson.c.
References dyn_chunk::next, and static_inline.
Referenced by dyn_malloc(), and dyn_realloc().
| static_inline void dyn_chunk_list_remove | ( | dyn_chunk * | list, |
| dyn_chunk * | chunk ) |
remove a chunk from list (the chunk must already be in the list)
Definition at line 2434 of file yyjson.c.
References dyn_chunk::next, and static_inline.
Referenced by dyn_free(), and dyn_realloc().
|
static |
Definition at line 2509 of file yyjson.c.
References dyn_chunk_list_remove(), dyn_ctx::free_list, dyn_chunk::next, ptr, dyn_chunk::size, and dyn_ctx::used_list.
Referenced by yyjson_alc_dyn_new().
|
static |
Definition at line 2452 of file yyjson.c.
References yyjson_alc::ctx, dyn_chunk_list_add(), dyn_size_align(), dyn_ctx::free_list, yyjson_alc::malloc, dyn_chunk::next, yyjson_alc::realloc, dyn_chunk::size, unlikely, dyn_ctx::used_list, and YYJSON_DEFAULT_ALC.
Referenced by yyjson_alc_dyn_new().
Definition at line 2490 of file yyjson.c.
References yyjson_alc::ctx, dyn_chunk_list_add(), dyn_chunk_list_remove(), dyn_size_align(), likely, ptr, yyjson_alc::realloc, dyn_chunk::size, unlikely, dyn_ctx::used_list, and YYJSON_DEFAULT_ALC.
Referenced by yyjson_alc_dyn_new().
| static_inline bool dyn_size_align | ( | usize * | size | ) |
align up the input size to chunk size
Definition at line 2425 of file yyjson.c.
References size_align_up(), static_inline, unlikely, and YYJSON_ALC_DYN_MIN_SIZE.
Referenced by dyn_malloc(), and dyn_realloc().
| static_inline usize ext_eol_len | ( | const u8 * | cur | ) |
Get the extended line end length. Used with char_is_eol_ext.
Definition at line 989 of file yyjson.c.
References static_inline.
Referenced by skip_trivia().
| static_inline usize ext_space_len | ( | const u8 * | cur | ) |
Get the extended whitespace length. Used with char_is_space_ext.
Definition at line 996 of file yyjson.c.
References byte_load_2(), byte_load_3(), and static_inline.
Referenced by read_str_id(), and skip_trivia().
| static_inline u32 f32_to_bits | ( | f32 | f | ) |
| static_inline u64 f64_bits_inf | ( | bool | sign | ) |
Get 'infinity' bits with sign.
Definition at line 1957 of file yyjson.c.
References F64_BITS_INF, f64_to_bits(), INFINITY, and static_inline.
Referenced by read_inf().
| static_inline u64 f64_bits_nan | ( | bool | sign | ) |
Get 'nan' bits with sign.
Definition at line 1975 of file yyjson.c.
References F64_BITS_NAN, f64_to_bits(), NAN, and static_inline.
Referenced by read_nan().
| static_inline bool f64_is_inf | ( | f64 | val | ) |
Returns whether the double value is infinity (not NaN).
Definition at line 1966 of file yyjson.c.
References F64_BITS_INF, F64_EXP_MASK, f64_to_bits(), INFINITY, and static_inline.
Referenced by read_num().
| static_inline u64 f64_to_bits | ( | f64 | f | ) |
Convert double to bits.
Definition at line 1943 of file yyjson.c.
References static_inline.
Referenced by f64_bits_inf(), f64_bits_nan(), and f64_is_inf().
| static_inline f32 f64_to_f32 | ( | f64 | val | ) |
Casting double to float, allow overflow.
Definition at line 1989 of file yyjson.c.
References static_inline.
Referenced by write_f32_raw().
| static_inline FILE * fopen_readonly | ( | const char * | path | ) |
Definition at line 2120 of file yyjson.c.
References fopen_safe(), static_inline, and YYJSON_FOPEN_E.
Referenced by yyjson_read_file().
| static_inline FILE * fopen_safe | ( | const char * | path, |
| const char * | mode ) |
Definition at line 2110 of file yyjson.c.
References static_inline.
Referenced by fopen_readonly(), and fopen_writeonly().
| static_inline FILE * fopen_writeonly | ( | const char * | path | ) |
Definition at line 2124 of file yyjson.c.
References fopen_safe(), static_inline, and YYJSON_FOPEN_E.
Referenced by write_dat_to_file().
| static_inline usize fread_safe | ( | void * | buf, |
| usize | size, | ||
| FILE * | file ) |
| static_inline const char_enc_type * get_enc_table_with_flag | ( | yyjson_write_flag | flg | ) |
Returns the encode table with options.
Definition at line 8786 of file yyjson.c.
References enc_table_cpy, enc_table_cpy_slash, enc_table_esc, enc_table_esc_slash, has_flg, and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline const u8 * get_hex_table_with_flag | ( | yyjson_write_flag | flg | ) |
Returns the hex digit table to use for \uXXXX escapes.
Definition at line 8779 of file yyjson.c.
References has_flg, and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline bool has_rflag | ( | yyjson_read_flag | flg, |
| yyjson_read_flag | chk, | ||
| bool | non_standard ) |
Definition at line 3123 of file yyjson.c.
References static_inline.
| static_inline bool has_wflag | ( | yyjson_write_flag | flg, |
| yyjson_write_flag | chk, | ||
| bool | non_standard ) |
Definition at line 7175 of file yyjson.c.
References static_inline.
| static_inline bool hex_load_2 | ( | const u8 * | src, |
| u8 * | dst ) |
Load 2 hex characters to u8, return true on valid input.
Definition at line 1075 of file yyjson.c.
References hex_conv_table, and static_inline.
Referenced by read_str_opt().
| static_inline bool hex_load_4 | ( | const u8 * | src, |
| u16 * | dst ) |
Load 4 hex characters to u16, return true on valid input.
Definition at line 1063 of file yyjson.c.
References hex_conv_table, and static_inline.
Referenced by is_truncated_end(), and read_uni_esc().
| static_noinline bool is_truncated_end | ( | u8 * | hdr, |
| u8 * | cur, | ||
| u8 * | eof, | ||
| yyjson_read_code | code, | ||
| yyjson_read_flag | flg ) |
Check truncated JSON on parsing errors. Returns true if the input is valid but truncated.
Definition at line 3501 of file yyjson.c.
References char_is_hex(), has_allow, hex_load_4(), is_truncated_str(), is_truncated_utf8(), len, static_noinline, YYJSON_READ_ERROR_INVALID_COMMENT, YYJSON_READ_ERROR_INVALID_NUMBER, YYJSON_READ_ERROR_INVALID_STRING, YYJSON_READ_ERROR_LITERAL, YYJSON_READ_ERROR_UNEXPECTED_CHARACTER, and YYJSON_READ_ERROR_UNEXPECTED_CONTENT.
Check truncated string. Returns true if cur match str but is truncated. The str should be lowercase ASCII letters.
Definition at line 3484 of file yyjson.c.
References char_to_lower(), and len.
Referenced by is_truncated_end().
Check truncated UTF-8 character. Return true if cur starts a valid UTF-8 sequence that is truncated.
Definition at line 3444 of file yyjson.c.
References len.
Referenced by is_truncated_end().
| static_inline bool is_utf16_bom | ( | const u8 * | cur | ) |
Match UTF-16 byte order mask.
Definition at line 977 of file yyjson.c.
References byte_load_2(), and static_inline.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| static_inline bool is_utf32_bom | ( | const u8 * | cur | ) |
Match UTF-32 byte order mask, need length check to avoid zero padding.
Definition at line 983 of file yyjson.c.
References byte_load_4(), and static_inline.
Referenced by yyjson_incr_read(), and yyjson_read_opts().
| static_inline bool is_utf8_bom | ( | const u8 * | cur | ) |
Match UTF-8 byte order mask.
Definition at line 972 of file yyjson.c.
References byte_load_3(), and static_inline.
Referenced by yyjson_incr_read(), yyjson_locate_pos(), and yyjson_read_opts().
| static_inline void * mem_align_up | ( | void * | mem, |
| usize | align ) |
Align address upwards (may overflow).
Definition at line 2174 of file yyjson.c.
References size_align_up(), and static_inline.
Referenced by yyjson_alc_pool_init().
|
static |
Definition at line 10301 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_write_err::msg, mut_write_root_minify(), mut_write_root_pretty(), mut_write_root_single(), unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_ctn(), YYJSON_DEFAULT_ALC, YYJSON_WRITE_ERROR_INVALID_PARAMETER, YYJSON_WRITE_PRETTY, and YYJSON_WRITE_PRETTY_TWO_SPACES.
Referenced by yyjson_mut_val_write_buf(), yyjson_mut_val_write_opts(), and yyjson_mut_write_opts().
| static_inline u8 * mut_write_root_minify | ( | const yyjson_mut_val * | root, |
| usize | estimated_val_num, | ||
| yyjson_write_flag | flg, | ||
| yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write JSON document minify. The root of this document should be a non-empty container.
Definition at line 9882 of file yyjson.c.
References check_str_len, yyjson_write_err::code, constcast, yyjson_alc::ctx, enc_table_cpy, FP_BUF_LEN, get_enc_table_with_flag(), get_hex_table_with_flag(), has_allow, has_flg, incr_len, likely, yyjson_alc::malloc, yyjson_write_err::msg, MSG_ERR_TYPE, MSG_ERR_UTF8, MSG_MALLOC, MSG_NAN_INF, yyjson_mut_val::next, yyjson_val_uni::ptr, return_err, size_align_down(), size_align_up(), static_inline, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_bool(), unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_get_subtype(), unsafe_yyjson_get_type(), write_bool(), write_null(), write_num(), write_raw(), write_str(), write_str_noesc(), yyjson_mut_write_ctx_get(), yyjson_mut_write_ctx_set(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, YYJSON_TYPE_STR, YYJSON_WRITE_SUCCESS, and YYJSON_WRITER_ESTIMATED_MINIFY_RATIO.
Referenced by mut_write_root().
| static_inline u8 * mut_write_root_pretty | ( | const yyjson_mut_val * | root, |
| usize | estimated_val_num, | ||
| yyjson_write_flag | flg, | ||
| yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write JSON document pretty. The root of this document should be a non-empty container.
Definition at line 10079 of file yyjson.c.
References bool, check_str_len, yyjson_write_err::code, constcast, yyjson_alc::ctx, enc_table_cpy, FP_BUF_LEN, get_enc_table_with_flag(), get_hex_table_with_flag(), has_allow, has_flg, incr_len, likely, yyjson_alc::malloc, yyjson_write_err::msg, MSG_ERR_TYPE, MSG_ERR_UTF8, MSG_MALLOC, MSG_NAN_INF, yyjson_mut_val::next, yyjson_val_uni::ptr, return_err, size_align_down(), size_align_up(), static_inline, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_bool(), unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_get_subtype(), unsafe_yyjson_get_type(), USIZE_MAX, write_bool(), write_indent(), write_null(), write_num(), write_raw(), write_str(), write_str_noesc(), yyjson_mut_write_ctx_get(), yyjson_mut_write_ctx_set(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, YYJSON_TYPE_STR, YYJSON_WRITE_SUCCESS, and YYJSON_WRITER_ESTIMATED_PRETTY_RATIO.
Referenced by mut_write_root().
| static_inline u8 * mut_write_root_single | ( | yyjson_mut_val * | val, |
| yyjson_write_flag | flg, | ||
| yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write single JSON value.
Definition at line 9872 of file yyjson.c.
References static_inline, and write_root_single().
Referenced by mut_write_root().
|
static |
|
static |
Definition at line 10974 of file yyjson.c.
References PATCH_OP_ADD, PATCH_OP_COPY, PATCH_OP_MOVE, PATCH_OP_NONE, PATCH_OP_REMOVE, PATCH_OP_REPLACE, PATCH_OP_TEST, yyjson_val_uni::str, yyjson_val::uni, and unsafe_yyjson_get_len().
Referenced by yyjson_mut_patch(), and yyjson_patch().
|
static |
Definition at line 2303 of file yyjson.c.
References pool_ctx::free_list, pool_chunk::next, ptr, and pool_chunk::size.
Referenced by pool_realloc(), and yyjson_alc_pool_init().
|
static |
Definition at line 2271 of file yyjson.c.
References pool_ctx::free_list, pool_chunk::next, pool_size_align(), pool_chunk::size, pool_ctx::size, and unlikely.
Referenced by pool_realloc(), and yyjson_alc_pool_init().
Definition at line 2329 of file yyjson.c.
References pool_ctx::free_list, pool_chunk::next, pool_free(), pool_malloc(), pool_size_align(), ptr, pool_chunk::size, pool_ctx::size, and unlikely.
Referenced by yyjson_alc_pool_init().
| static_inline void pool_size_align | ( | usize * | size | ) |
align up the input size to chunk size
Definition at line 2267 of file yyjson.c.
References size_align_up(), and static_inline.
Referenced by pool_malloc(), and pool_realloc().
| static_inline yyjson_val * ptr_arr_get | ( | const yyjson_val * | arr, |
| const char * | token, | ||
| usize | len, | ||
| usize | esc ) |
Get a value from array by token.
| arr | an array, should not be NULL or non-array type |
| token | a JSON pointer token |
| len | unescaped token length |
| esc | number of escaped characters in this token |
Definition at line 10577 of file yyjson.c.
References len, ptr_token_to_idx(), static_inline, unlikely, unsafe_yyjson_arr_is_flat(), unsafe_yyjson_get_first(), unsafe_yyjson_get_len(), and unsafe_yyjson_get_next().
Referenced by unsafe_yyjson_ptr_getx().
| static_inline yyjson_mut_val * ptr_mut_arr_get | ( | const yyjson_mut_val * | arr, |
| const char * | token, | ||
| usize | len, | ||
| usize | esc, | ||
| yyjson_mut_val ** | pre, | ||
| bool * | last ) |
Get a value from array by token.
| arr | [in] an array, should not be NULL or non-array type |
| token | [in] a JSON pointer token |
| len | [in] unescaped token length |
| esc | [in] number of escaped characters in this token |
| pre | [out] previous (sibling) value of the returned value |
| last | [out] whether index is last |
Definition at line 10621 of file yyjson.c.
References len, yyjson_mut_val::next, yyjson_val_uni::ptr, ptr_token_to_idx(), static_inline, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_len(), and USIZE_MAX.
Referenced by unsafe_yyjson_mut_ptr_getx(), and unsafe_yyjson_mut_ptr_putx().
| static_inline yyjson_mut_val * ptr_mut_obj_get | ( | const yyjson_mut_val * | obj, |
| const char * | token, | ||
| usize | len, | ||
| usize | esc, | ||
| yyjson_mut_val ** | pre ) |
Get a value from object by token.
| obj | [in] an object, should not be NULL or non-object type |
| token | [in] a JSON pointer token |
| len | [in] unescaped token length |
| esc | [in] number of escaped characters in this token |
| pre | [out] previous (sibling) key of the returned value's key |
Definition at line 10651 of file yyjson.c.
References len, yyjson_mut_val::next, yyjson_val_uni::ptr, ptr_token_eq(), static_inline, yyjson_mut_val::uni, unlikely, and unsafe_yyjson_get_len().
Referenced by unsafe_yyjson_mut_ptr_getx(), and unsafe_yyjson_mut_ptr_putx().
| static_inline yyjson_mut_val * ptr_new_key | ( | const char * | token, |
| usize | len, | ||
| usize | esc, | ||
| yyjson_mut_doc * | doc ) |
Create a string value with JSON pointer token.
| token | [in] a JSON pointer token |
| len | [in] unescaped token length |
| esc | [in] number of escaped characters in this token |
| doc | [in] used for memory allocation when creating value |
Definition at line 10677 of file yyjson.c.
References len, likely, static_inline, unlikely, unsafe_yyjson_mut_str_alc(), yyjson_mut_strn(), and yyjson_mut_strncpy().
Referenced by unsafe_yyjson_mut_ptr_putx().
| static_inline const char * ptr_next_token | ( | const char ** | ptr, |
| const char * | end, | ||
| usize * | len, | ||
| usize * | esc ) |
Get a token from JSON pointer string.
| ptr | [in] string that points to current token prefix / [out] string that points to next token prefix /, or string end |
| end | [in] end of the entire JSON Pointer string |
| len | [out] unescaped token length |
| esc | [out] number of escaped characters in this token |
Definition at line 10482 of file yyjson.c.
References len, likely, ptr, and static_inline.
Referenced by unsafe_yyjson_mut_ptr_getx(), unsafe_yyjson_mut_ptr_putx(), and unsafe_yyjson_ptr_getx().
| static_inline yyjson_val * ptr_obj_get | ( | const yyjson_val * | obj, |
| const char * | token, | ||
| usize | len, | ||
| usize | esc ) |
Get a value from object by token.
| obj | [in] an object, should not be NULL or non-object type |
| token | [in] a JSON pointer token |
| len | [in] unescaped token length |
| esc | [in] number of escaped characters in this token |
Definition at line 10600 of file yyjson.c.
References len, ptr_token_eq(), static_inline, unlikely, unsafe_yyjson_get_first(), unsafe_yyjson_get_len(), and unsafe_yyjson_get_next().
Referenced by unsafe_yyjson_ptr_getx().
| static_inline bool ptr_token_eq | ( | void * | key, |
| const char * | token, | ||
| usize | len, | ||
| usize | esc ) |
Compare JSON key with token.
| key | a string key (yyjson_val or yyjson_mut_val) |
| token | a JSON pointer token |
| len | unescaped token length |
| esc | number of escaped characters in this token |
Definition at line 10550 of file yyjson.c.
References len, likely, static_inline, yyjson_val_uni::str, yyjson_val::uni, and unsafe_yyjson_get_len().
Referenced by ptr_mut_obj_get(), and ptr_obj_get().
| static_inline bool ptr_token_to_idx | ( | const char * | cur, |
| usize | len, | ||
| usize * | idx ) |
Convert token string to index.
| cur | [in] token head |
| len | [in] token length |
| idx | [out] the index number, or USIZE_MAX if token is '-' |
Definition at line 10520 of file yyjson.c.
References len, static_inline, unlikely, USIZE_MAX, and USIZE_SAFE_DIG.
Referenced by ptr_arr_get(), and ptr_mut_arr_get().
| static_inline bool read_false | ( | u8 ** | ptr, |
| yyjson_val * | val ) |
Read false literal, *ptr[0] should be f.
Definition at line 3150 of file yyjson.c.
References byte_match_4(), likely, ptr, static_inline, yyjson_val::tag, YYJSON_SUBTYPE_FALSE, and YYJSON_TYPE_BOOL.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| static_inline bool read_inf | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val ) |
Read Inf or Infinity literal (ignoring case).
Definition at line 3172 of file yyjson.c.
References char_is_sign(), char_to_lower(), f64_bits_inf(), has_allow, has_flg, ptr, static_inline, yyjson_val_uni::str, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, YYJSON_SUBTYPE_REAL, YYJSON_TAG_BIT, YYJSON_TYPE_NUM, and YYJSON_TYPE_RAW.
Referenced by read_inf_or_nan().
| static_inline bool read_inf_or_nan | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val ) |
Read Inf, Infinity or NaN literal (ignoring case).
Definition at line 3239 of file yyjson.c.
References ptr, read_inf(), read_nan(), and static_inline.
Referenced by read_num(), read_num_raw(), read_root_minify(), read_root_pretty(), and read_root_single().
| static_inline bool read_nan | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val ) |
Read NaN literal (ignoring case).
Definition at line 3211 of file yyjson.c.
References char_is_sign(), char_to_lower(), f64_bits_nan(), has_allow, has_flg, ptr, static_inline, yyjson_val_uni::str, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, YYJSON_SUBTYPE_REAL, YYJSON_TAG_BIT, YYJSON_TYPE_NUM, and YYJSON_TYPE_RAW.
Referenced by read_inf_or_nan(), read_root_minify(), read_root_pretty(), and read_root_single().
| static_inline bool read_null | ( | u8 ** | ptr, |
| yyjson_val * | val ) |
Read null literal, *ptr[0] should be n.
Definition at line 3161 of file yyjson.c.
References byte_match_4(), likely, ptr, static_inline, yyjson_val::tag, and YYJSON_TYPE_NULL.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| static_inline bool read_num | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Read a JSON number. This is a fallback function if the custom number reader is disabled. This function use libc's strtod() to read floating-point number.
Definition at line 4486 of file yyjson.c.
References char_is_digit(), char_is_digit_or_fp(), char_is_exp(), char_is_fp(), char_is_num(), char_is_sign(), expr_intg, yyjson_val_uni::f64, f64_is_inf(), has_allow, has_flg, ptr, read_inf_or_nan(), read_num_hex(), read_num_raw(), repeat_in_1_18, return_0, return_err, return_f64, return_i64, return_inf, return_raw, static_inline, yyjson_val::tag, U64_MAX, yyjson_val::uni, unlikely, unsafe_yyjson_u64_to_f64(), YYJSON_SUBTYPE_REAL, and YYJSON_TYPE_NUM.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), yyjson_incr_read(), and yyjson_read_number().
| static_noinline bool read_num_hex | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Read a hex number.
Definition at line 3331 of file yyjson.c.
References char_is_hex(), has_flg, hex_conv_table, ptr, static_noinline, yyjson_val_uni::str, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, unlikely, YYJSON_TAG_BIT, YYJSON_TYPE_NUM, and YYJSON_TYPE_RAW.
Referenced by read_num().
| static_noinline bool read_num_raw | ( | u8 ** | ptr, |
| u8 ** | pre, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Read a JSON number as raw string.
Definition at line 3247 of file yyjson.c.
References char_is_digit(), char_is_exp(), char_is_fp(), char_is_hex(), char_is_sign(), char_to_lower(), has_allow, ptr, read_inf_or_nan(), return_err, return_raw, static_noinline, and unlikely.
Referenced by read_num().
| static_inline yyjson_doc * read_root_minify | ( | u8 * | hdr, |
| u8 * | cur, | ||
| u8 * | eof, | ||
| yyjson_alc | alc, | ||
| yyjson_read_flag | flg, | ||
| yyjson_read_err * | err ) |
Read JSON document (accept all style, but optimized for minify).
Definition at line 5349 of file yyjson.c.
References yyjson_doc::alc, char_is_id_start(), char_is_num(), char_is_space(), char_is_trivia(), yyjson_alc::ctx, yyjson_doc::dat_read, has_allow, has_flg, likely, yyjson_alc::malloc, MSG_ARR_END, MSG_CHAR, MSG_CHAR_F, MSG_CHAR_N, MSG_CHAR_T, MSG_COMMA, MSG_COMMENT, MSG_DEPTH, MSG_GARBAGE, MSG_MALLOC, MSG_OBJ_END, MSG_OBJ_KEY, MSG_OBJ_SEP, yyjson_val_uni::ofs, read_false(), read_inf_or_nan(), read_nan(), read_null(), read_num(), read_str(), read_str_id(), read_str_sq(), read_true(), return_err, yyjson_doc::root, skip_trivia(), static_inline, yyjson_doc::str_pool, yyjson_val::tag, yyjson_val::uni, unlikely, USIZE_MAX, val_incr, yyjson_doc::val_read, yyjson_min, YYJSON_READER_DEPTH_LIMIT, YYJSON_READER_ESTIMATED_MINIFY_RATIO, YYJSON_TAG_BIT, YYJSON_TAG_MASK, YYJSON_TYPE_ARR, YYJSON_TYPE_MASK, and YYJSON_TYPE_OBJ.
Referenced by yyjson_read_opts().
| static_inline yyjson_doc * read_root_pretty | ( | u8 * | hdr, |
| u8 * | cur, | ||
| u8 * | eof, | ||
| yyjson_alc | alc, | ||
| yyjson_read_flag | flg, | ||
| yyjson_read_err * | err ) |
Read JSON document (accept all style, but optimized for pretty).
Definition at line 5776 of file yyjson.c.
References yyjson_doc::alc, byte_match_2(), char_is_id_start(), char_is_num(), char_is_space(), char_is_trivia(), yyjson_alc::ctx, yyjson_doc::dat_read, has_allow, has_flg, likely, yyjson_alc::malloc, MSG_ARR_END, MSG_CHAR, MSG_CHAR_F, MSG_CHAR_N, MSG_CHAR_T, MSG_COMMA, MSG_COMMENT, MSG_DEPTH, MSG_GARBAGE, MSG_MALLOC, MSG_OBJ_END, MSG_OBJ_KEY, MSG_OBJ_SEP, yyjson_val_uni::ofs, read_false(), read_inf_or_nan(), read_nan(), read_null(), read_num(), read_str(), read_str_id(), read_str_sq(), read_true(), repeat16, return_err, yyjson_doc::root, skip_trivia(), static_inline, yyjson_doc::str_pool, yyjson_val::tag, yyjson_val::uni, unlikely, USIZE_MAX, val_incr, yyjson_doc::val_read, yyjson_min, YYJSON_READER_DEPTH_LIMIT, YYJSON_READER_ESTIMATED_PRETTY_RATIO, YYJSON_TAG_BIT, YYJSON_TAG_MASK, YYJSON_TYPE_ARR, YYJSON_TYPE_MASK, and YYJSON_TYPE_OBJ.
Referenced by yyjson_read_opts().
| static_noinline yyjson_doc * read_root_single | ( | u8 * | hdr, |
| u8 * | cur, | ||
| u8 * | eof, | ||
| yyjson_alc | alc, | ||
| yyjson_read_flag | flg, | ||
| yyjson_read_err * | err ) |
Read single value JSON document.
Definition at line 5244 of file yyjson.c.
References yyjson_doc::alc, char_is_num(), char_is_space(), char_is_trivia(), yyjson_alc::ctx, yyjson_doc::dat_read, has_allow, has_flg, likely, yyjson_alc::malloc, MSG_CHAR, MSG_CHAR_F, MSG_CHAR_N, MSG_CHAR_T, MSG_COMMENT, MSG_DEPTH, MSG_GARBAGE, MSG_MALLOC, read_false(), read_inf_or_nan(), read_nan(), read_null(), read_num(), read_str(), read_str_sq(), read_true(), return_err, yyjson_doc::root, skip_trivia(), static_noinline, yyjson_doc::str_pool, unlikely, and yyjson_doc::val_read.
Referenced by yyjson_read_opts().
| static_inline bool read_str | ( | u8 ** | ptr, |
| u8 * | eof, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Definition at line 5077 of file yyjson.c.
References ptr, read_str_opt(), and static_inline.
Referenced by read_root_minify(), read_root_pretty(), and read_root_single().
| static_inline bool read_str_con | ( | u8 ** | ptr, |
| u8 * | eof, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg, | ||
| u8 ** | con ) |
Definition at line 5082 of file yyjson.c.
References ptr, read_str_opt(), and static_inline.
Referenced by yyjson_incr_read().
| static_noinline bool read_str_id | ( | u8 ** | ptr, |
| u8 * | eof, | ||
| yyjson_read_flag | flg, | ||
| u8 ** | pre, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Read unquoted key (identifier name).
Definition at line 5093 of file yyjson.c.
References byte_copy_2(), byte_copy_4(), byte_load_4(), byte_match_2(), byte_move_16(), char_is_id_ascii(), char_is_id_next(), char_is_space_ext(), expr_jump, expr_stop, ext_space_len(), gcc_store_barrier, has_allow, is_utf8_seq2, is_utf8_seq3, is_utf8_seq4, likely, MSG_ERR_UTF8, ptr, read_uni_esc(), repeat16_incr, return_err, return_suc, and static_noinline.
Referenced by read_root_minify(), and read_root_pretty().
| static_inline bool read_str_opt | ( | u8 | quo, |
| u8 ** | ptr, | ||
| u8 * | eof, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg, | ||
| u8 * | con[2] ) |
Read a JSON string.
| quo | The quote character (single quote or double quote). |
| ptr | The head pointer of string before quote (inout). |
| eof | JSON end position. |
| flg | JSON read flag. |
| val | The string value to be written. |
| msg | The error message pointer. |
| con | Continuation for incremental parsing. |
Definition at line 4760 of file yyjson.c.
References byte_copy_2(), byte_copy_4(), byte_load_4(), byte_move_16(), char_is_digit(), expr_jump, expr_stop, gcc_store_barrier, has_allow, hex_load_2(), is_utf8_seq1, is_utf8_seq2, is_utf8_seq3, is_utf8_seq4, likely, MSG_ERR_UTF8, ptr, read_uni_esc(), repeat16_incr, repeat4, repeat8, return_err, static_inline, yyjson_val_uni::str, yyjson_val::tag, yyjson_val::uni, unlikely, utf8_seq, YYJSON_SUBTYPE_NOESC, YYJSON_TAG_BIT, and YYJSON_TYPE_STR.
Referenced by read_str(), read_str_con(), and read_str_sq().
| static_noinline bool read_str_sq | ( | u8 ** | ptr, |
| u8 * | eof, | ||
| yyjson_read_flag | flg, | ||
| yyjson_val * | val, | ||
| const char ** | msg ) |
Definition at line 5087 of file yyjson.c.
References ptr, read_str_opt(), and static_noinline.
Referenced by read_root_minify(), read_root_pretty(), and read_root_single().
| static_inline bool read_true | ( | u8 ** | ptr, |
| yyjson_val * | val ) |
Read true literal, *ptr[0] should be t.
Definition at line 3139 of file yyjson.c.
References byte_match_4(), likely, ptr, static_inline, yyjson_val::tag, YYJSON_SUBTYPE_TRUE, and YYJSON_TYPE_BOOL.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_incr_read().
| static_inline bool read_uni_esc | ( | u8 ** | src_ptr, |
| u8 ** | dst_ptr, | ||
| const char ** | msg ) |
Read unicode escape sequence.
Definition at line 4696 of file yyjson.c.
References byte_match_2(), hex_load_4(), likely, return_err, static_inline, and unlikely.
Referenced by read_str_id(), and read_str_opt().
| static_inline bool size_add_is_overflow | ( | usize | size, |
| usize | add ) |
Returns whether the size is overflow after increment.
Definition at line 2146 of file yyjson.c.
References static_inline.
| static_inline usize size_align_down | ( | usize | size, |
| usize | align ) |
Align size downwards.
Definition at line 2165 of file yyjson.c.
References size_is_pow2(), and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and yyjson_alc_pool_init().
| static_inline usize size_align_up | ( | usize | size, |
| usize | align ) |
Align size upwards (may overflow).
Definition at line 2156 of file yyjson.c.
References size_is_pow2(), and static_inline.
Referenced by dyn_size_align(), mem_align_up(), mut_write_root_minify(), mut_write_root_pretty(), pool_size_align(), write_root_minify(), write_root_pretty(), and yyjson_mut_val_imut_copy().
| static_inline bool size_is_pow2 | ( | usize | size | ) |
Returns whether the size is power of 2 (size should not be 0).
Definition at line 2151 of file yyjson.c.
References static_inline.
Referenced by size_align_down(), and size_align_up().
| static_noinline bool skip_trivia | ( | u8 ** | ptr, |
| u8 * | eof, | ||
| yyjson_read_flag | flg ) |
Skip trivia (whitespace and comments). This function should be used only when char_is_trivia() returns true.
| ptr | (inout) Input current position, output end position. |
| eof | JSON end position. |
| flg | JSON read flags. |
Definition at line 3391 of file yyjson.c.
References byte_match_2(), char_is_eol(), char_is_eol_ext(), char_is_space(), char_is_space_ext(), ext_eol_len(), ext_space_len(), has_allow, len, ptr, and static_noinline.
Referenced by read_root_minify(), read_root_pretty(), read_root_single(), and yyjson_read_opts().
| static_inline void u128_mul | ( | u64 | a, |
| u64 | b, | ||
| u64 * | hi, | ||
| u64 * | lo ) |
Multiplies two 64-bit unsigned integers (a * b), returns the 128-bit result as 'hi' and 'lo'.
Definition at line 2055 of file yyjson.c.
References static_inline.
Referenced by u128_mul_add().
Multiplies two 64-bit unsigned integers and add a value (a * b + c), returns the 128-bit result as 'hi' and 'lo'.
Definition at line 2078 of file yyjson.c.
References static_inline, and u128_mul().
| static_inline u32 u64_lz_bits | ( | u64 | v | ) |
Returns the number of leading 0-bits in value (input should not be 0).
Definition at line 1994 of file yyjson.c.
References static_inline, and U64.
| static_inline u32 u64_tz_bits | ( | u64 | v | ) |
Returns the number of trailing 0-bits in value (input should not be 0).
Definition at line 2027 of file yyjson.c.
References static_inline, and U64.
| bool unsafe_yyjson_equals | ( | const yyjson_val * | lhs, |
| const yyjson_val * | rhs ) |
Definition at line 2967 of file yyjson.c.
References len, yyjson_val_uni::str, yyjson_val::tag, yyjson_val::uni, unsafe_yyjson_equals(), unsafe_yyjson_get_first(), unsafe_yyjson_get_len(), unsafe_yyjson_get_next(), unsafe_yyjson_get_type(), unsafe_yyjson_num_equals(), unsafe_yyjson_str_equals(), yyjson_obj_iter_getn(), yyjson_obj_iter_init(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by unsafe_yyjson_equals().
| bool unsafe_yyjson_mut_equals | ( | const yyjson_mut_val * | lhs, |
| const yyjson_mut_val * | rhs ) |
Definition at line 3022 of file yyjson.c.
References constcast, len, yyjson_mut_val::next, yyjson_val_uni::ptr, yyjson_val_uni::str, yyjson_mut_val::tag, yyjson_mut_val::uni, unsafe_yyjson_get_len(), unsafe_yyjson_get_type(), unsafe_yyjson_mut_equals(), unsafe_yyjson_num_equals(), unsafe_yyjson_str_equals(), yyjson_mut_obj_iter_getn(), yyjson_mut_obj_iter_init(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by unsafe_yyjson_mut_equals().
| yyjson_mut_val * unsafe_yyjson_mut_ptr_getx | ( | const yyjson_mut_val * | val, |
| const char * | ptr, | ||
| size_t | ptr_len, | ||
| yyjson_ptr_ctx * | ctx, | ||
| yyjson_ptr_err * | err ) |
Definition at line 10738 of file yyjson.c.
References constcast, yyjson_ptr_ctx::ctn, len, yyjson_ptr_ctx::pre, ptr, ptr_mut_arr_get(), ptr_mut_obj_get(), ptr_next_token(), return_err_resolve, return_err_syntax, unlikely, unsafe_yyjson_get_type(), YYJSON_TYPE_ARR, and YYJSON_TYPE_OBJ.
Referenced by unsafe_yyjson_mut_ptr_removex(), and unsafe_yyjson_mut_ptr_replacex().
| bool unsafe_yyjson_mut_ptr_putx | ( | yyjson_mut_val * | val, |
| const char * | ptr, | ||
| size_t | ptr_len, | ||
| yyjson_mut_val * | new_val, | ||
| yyjson_mut_doc * | doc, | ||
| bool | create_parent, | ||
| bool | insert_new, | ||
| yyjson_ptr_ctx * | ctx, | ||
| yyjson_ptr_err * | err ) |
Definition at line 10772 of file yyjson.c.
References yyjson_ptr_ctx::ctn, yyjson_mut_val::next, yyjson_ptr_ctx::old, yyjson_ptr_ctx::pre, ptr, yyjson_val_uni::ptr, ptr_mut_arr_get(), ptr_mut_obj_get(), ptr_new_key(), ptr_next_token(), return_err_alloc, return_err_resolve, return_err_syntax, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_type(), unsafe_yyjson_mut_obj_add(), unsafe_yyjson_set_len(), yyjson_mut_arr_append(), yyjson_mut_obj(), yyjson_mut_obj_add(), yyjson_mut_obj_put(), YYJSON_TYPE_ARR, and YYJSON_TYPE_OBJ.
| yyjson_mut_val * unsafe_yyjson_mut_ptr_removex | ( | yyjson_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| yyjson_ptr_ctx * | ctx, | ||
| yyjson_ptr_err * | err ) |
Definition at line 10929 of file yyjson.c.
References yyjson_ptr_ctx::ctn, len, yyjson_mut_val::next, yyjson_ptr_ctx::old, yyjson_ptr_ctx::pre, ptr, unsafe_yyjson_mut_ptr_getx(), yyjson_mut_is_obj(), yyjson_mut_obj_put(), and yyjson_ptr_ctx_remove().
| yyjson_mut_val * unsafe_yyjson_mut_ptr_replacex | ( | yyjson_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| yyjson_mut_val * | new_val, | ||
| yyjson_ptr_ctx * | ctx, | ||
| yyjson_ptr_err * | err ) |
Definition at line 10908 of file yyjson.c.
References yyjson_ptr_ctx::ctn, len, yyjson_mut_val::next, yyjson_ptr_ctx::old, yyjson_ptr_ctx::pre, ptr, unsafe_yyjson_mut_ptr_getx(), yyjson_mut_is_obj(), yyjson_mut_obj_put(), and yyjson_ptr_ctx_replace().
|
static |
Definition at line 2780 of file yyjson.c.
References yyjson_mut_val::next, yyjson_val_uni::ptr, yyjson_val_uni::str, yyjson_mut_val::tag, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_type(), unsafe_yyjson_mut_strncpy(), unsafe_yyjson_mut_val(), unsafe_yyjson_mut_val_mut_copy(), YYJSON_TYPE_ARR, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by unsafe_yyjson_mut_val_mut_copy(), and yyjson_mut_val_mut_copy().
| static_inline bool unsafe_yyjson_num_equals | ( | const void * | lhs, |
| const void * | rhs ) |
Definition at line 2945 of file yyjson.c.
References yyjson_val_uni::i64, static_inline, yyjson_val_uni::u64, unsafe_yyjson_get_subtype(), YYJSON_SUBTYPE_SINT, and YYJSON_SUBTYPE_UINT.
Referenced by unsafe_yyjson_equals(), and unsafe_yyjson_mut_equals().
| yyjson_val * unsafe_yyjson_ptr_getx | ( | const yyjson_val * | val, |
| const char * | ptr, | ||
| size_t | ptr_len, | ||
| yyjson_ptr_err * | err ) |
Definition at line 10714 of file yyjson.c.
References constcast, len, ptr, ptr_arr_get(), ptr_next_token(), ptr_obj_get(), return_err_resolve, return_err_syntax, unlikely, unsafe_yyjson_get_type(), YYJSON_TYPE_ARR, and YYJSON_TYPE_OBJ.
| static_inline bool unsafe_yyjson_str_equals | ( | const void * | lhs, |
| const void * | rhs ) |
Definition at line 2960 of file yyjson.c.
References len, static_inline, unsafe_yyjson_get_len(), and unsafe_yyjson_get_str().
Referenced by unsafe_yyjson_equals(), and unsafe_yyjson_mut_equals().
| bool unsafe_yyjson_str_pool_grow | ( | yyjson_str_pool * | pool, |
| const yyjson_alc * | alc, | ||
| usize | len ) |
Definition at line 2585 of file yyjson.c.
References yyjson_str_chunk::chunk_size, yyjson_str_pool::chunk_size, yyjson_str_pool::chunk_size_max, yyjson_str_pool::chunks, yyjson_alc::ctx, yyjson_str_pool::cur, yyjson_str_pool::end, len, yyjson_alc::malloc, yyjson_str_chunk::next, unlikely, USIZE_MAX, yyjson_max, and yyjson_min.
| static_inline void unsafe_yyjson_str_pool_release | ( | yyjson_str_pool * | pool, |
| yyjson_alc * | alc ) |
Definition at line 2565 of file yyjson.c.
References yyjson_str_pool::chunks, yyjson_alc::ctx, yyjson_alc::free, yyjson_str_chunk::next, and static_inline.
Referenced by yyjson_mut_doc_free().
| bool unsafe_yyjson_val_pool_grow | ( | yyjson_val_pool * | pool, |
| const yyjson_alc * | alc, | ||
| usize | count ) |
Definition at line 2612 of file yyjson.c.
References yyjson_val_chunk::chunk_size, yyjson_val_pool::chunk_size, yyjson_val_pool::chunk_size_max, yyjson_val_pool::chunks, yyjson_alc::ctx, yyjson_val_pool::cur, yyjson_val_pool::end, yyjson_alc::malloc, yyjson_val_chunk::next, unlikely, USIZE_MAX, yyjson_max, and yyjson_min.
| static_inline void unsafe_yyjson_val_pool_release | ( | yyjson_val_pool * | pool, |
| yyjson_alc * | alc ) |
Definition at line 2575 of file yyjson.c.
References yyjson_val_pool::chunks, yyjson_alc::ctx, yyjson_alc::free, yyjson_val_chunk::next, and static_inline.
Referenced by yyjson_mut_doc_free().
| utf8_seq_def | ( | b1_mask | , |
| utf8_seq_def( | 80, | ||
| utf8_seq_def( | 00, | ||
| utf8_seq_def( | 00, | ||
| utf8_seq_def( | 00 ) |
| static_inline u8 * write_bool | ( | u8 * | cur, |
| bool | val ) |
Write bool (requires 8 bytes buffer).
Definition at line 9080 of file yyjson.c.
References byte_copy_8(), and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
|
static |
Write data to file.
Definition at line 9115 of file yyjson.c.
References fopen_writeonly(), len, MSG_FCLOSE, MSG_FOPEN, MSG_FWRITE, and return_err.
Referenced by yyjson_mut_val_write_file(), and yyjson_val_write_file().
|
static |
Write data to file pointer.
Definition at line 9104 of file yyjson.c.
References yyjson_write_err::code, len, yyjson_write_err::msg, and YYJSON_WRITE_ERROR_FILE_WRITE.
Referenced by yyjson_mut_val_write_fp(), and yyjson_val_write_fp().
| static_noinline u8 * write_f32_raw | ( | u8 * | buf, |
| u64 | raw, | ||
| yyjson_write_flag | flg ) |
Write a double number (requires 40 bytes buffer).
Definition at line 8368 of file yyjson.c.
References F32_DEC_DIG, f64_to_f32(), FP_BUF_LEN, len, snprintf_num, static_noinline, and write_fp_reformat().
Referenced by write_num(), and yyjson_write_number().
| static_noinline u8 * write_f64_raw | ( | u8 * | buf, |
| u64 | raw, | ||
| yyjson_write_flag | flg ) |
Write a double number (requires 40 bytes buffer).
Definition at line 8356 of file yyjson.c.
References F64_DEC_DIG, FP_BUF_LEN, len, snprintf_num, static_noinline, and write_fp_reformat().
Referenced by write_f64_raw_fixed(), write_num(), and yyjson_write_number().
| static_noinline u8 * write_f64_raw_fixed | ( | u8 * | buf, |
| u64 | raw, | ||
| yyjson_write_flag | flg, | ||
| u32 | prec ) |
Write a double number (requires 40 bytes buffer).
Definition at line 8380 of file yyjson.c.
References FP_BUF_LEN, len, snprintf_num, static_noinline, write_f64_raw(), and write_fp_reformat().
Referenced by write_num(), and yyjson_write_number().
| static_noinline u8 * write_fp_reformat | ( | u8 * | buf, |
| int | len, | ||
| yyjson_write_flag | flg, | ||
| bool | fixed ) |
Definition at line 8287 of file yyjson.c.
References byte_copy_2(), byte_copy_4(), byte_copy_8(), char_is_digit(), has_allow, has_flg, len, static_noinline, and unlikely.
Referenced by write_f32_raw(), write_f64_raw(), and write_f64_raw_fixed().
| static_inline u8 * write_indent | ( | u8 * | cur, |
| usize | level, | ||
| usize | spaces ) |
Write indent (requires level x 4 bytes buffer). Param spaces should not larger than 4.
Definition at line 9093 of file yyjson.c.
References byte_copy_4(), and static_inline.
Referenced by mut_write_root_pretty(), and write_root_pretty().
| static_inline u8 * write_null | ( | u8 * | cur | ) |
Write null (requires 8 bytes buffer).
Definition at line 9073 of file yyjson.c.
References byte_copy_8(), and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline u8 * write_num | ( | u8 * | cur, |
| yyjson_val * | val, | ||
| yyjson_write_flag | flg ) |
Write a JSON number (requires 40 bytes buffer).
Definition at line 8394 of file yyjson.c.
References likely, static_inline, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), write_u64(), YYJSON_SUBTYPE_REAL, YYJSON_SUBTYPE_SINT, YYJSON_WRITE_FP_FLAG_BITS, YYJSON_WRITE_FP_PREC_BITS, and YYJSON_WRITE_FP_TO_FLOAT.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline u8 * write_raw | ( | u8 * | cur, |
| const u8 * | raw, | ||
| usize | raw_len ) |
Write raw string.
Definition at line 8804 of file yyjson.c.
References static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
|
static |
Definition at line 9681 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_write_err::msg, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_ctn(), write_root_minify(), write_root_pretty(), write_root_single(), YYJSON_DEFAULT_ALC, YYJSON_READ_ERROR_INVALID_PARAMETER, YYJSON_WRITE_PRETTY, and YYJSON_WRITE_PRETTY_TWO_SPACES.
Referenced by yyjson_val_write_buf(), yyjson_val_write_file(), yyjson_val_write_fp(), yyjson_val_write_opts(), and yyjson_write_opts().
| static_inline u8 * write_root_minify | ( | const yyjson_val * | root, |
| const yyjson_write_flag | flg, | ||
| const yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write JSON document minify. The root of this document should be a non-empty container.
Definition at line 9274 of file yyjson.c.
References check_str_len, constcast, yyjson_alc::ctx, enc_table_cpy, FP_BUF_LEN, get_enc_table_with_flag(), get_hex_table_with_flag(), has_allow, has_flg, incr_len, likely, yyjson_alc::malloc, MSG_ERR_TYPE, MSG_ERR_UTF8, MSG_MALLOC, MSG_NAN_INF, yyjson_val_uni::ofs, return_err, size_align_down(), size_align_up(), static_inline, yyjson_val::uni, unlikely, unsafe_yyjson_get_bool(), unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_get_subtype(), unsafe_yyjson_get_type(), write_bool(), write_null(), write_num(), write_raw(), write_str(), write_str_noesc(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, YYJSON_TYPE_STR, yyjson_write_ctx_get(), yyjson_write_ctx_set(), and YYJSON_WRITER_ESTIMATED_MINIFY_RATIO.
Referenced by write_root().
| static_inline u8 * write_root_pretty | ( | const yyjson_val * | root, |
| const yyjson_write_flag | flg, | ||
| const yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write JSON document pretty. The root of this document should be a non-empty container.
Definition at line 9465 of file yyjson.c.
References bool, check_str_len, constcast, yyjson_alc::ctx, enc_table_cpy, FP_BUF_LEN, get_enc_table_with_flag(), get_hex_table_with_flag(), has_allow, has_flg, incr_len, likely, yyjson_alc::malloc, MSG_ERR_TYPE, MSG_ERR_UTF8, MSG_MALLOC, MSG_NAN_INF, yyjson_val_uni::ofs, return_err, size_align_down(), size_align_up(), static_inline, yyjson_val::uni, unlikely, unsafe_yyjson_get_bool(), unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_get_subtype(), unsafe_yyjson_get_type(), USIZE_MAX, write_bool(), write_indent(), write_null(), write_num(), write_raw(), write_str(), write_str_noesc(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, YYJSON_TYPE_STR, yyjson_write_ctx_get(), yyjson_write_ctx_set(), and YYJSON_WRITER_ESTIMATED_PRETTY_RATIO.
Referenced by write_root().
| static_inline u8 * write_root_single | ( | yyjson_val * | val, |
| yyjson_write_flag | flg, | ||
| yyjson_alc | alc, | ||
| char * | buf, | ||
| usize * | dat_len, | ||
| yyjson_write_err * | err ) |
Write single JSON value.
Definition at line 9165 of file yyjson.c.
References byte_copy_2(), check_str_len, enc_table_cpy, FP_BUF_LEN, get_enc_table_with_flag(), get_hex_table_with_flag(), has_allow, has_flg, incr_len, likely, MSG_ERR_TYPE, MSG_ERR_UTF8, MSG_MALLOC, MSG_NAN_INF, return_err, static_inline, unlikely, unsafe_yyjson_get_bool(), unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_get_subtype(), unsafe_yyjson_get_type(), write_bool(), write_null(), write_num(), write_raw(), write_str(), write_str_noesc(), YYJSON_TYPE_ARR, YYJSON_TYPE_BOOL, YYJSON_TYPE_NULL, YYJSON_TYPE_NUM, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by mut_write_root_single(), and write_root().
| static_inline u8 * write_str | ( | u8 * | cur, |
| bool | esc, | ||
| bool | inv, | ||
| const u8 * | str, | ||
| usize | str_len, | ||
| const char_enc_type * | enc_table, | ||
| const u8 * | hex_table ) |
Write UTF-8 string (requires len * 6 + 2 bytes buffer).
| cur | Buffer cursor. |
| esc | Escape unicode. |
| inv | Allow invalid unicode. |
| str | A UTF-8 string, null-terminator is not required. |
| str_len | Length of string in bytes. |
| enc_table | Encode type table for character. |
Definition at line 8848 of file yyjson.c.
References byte_copy_16(), byte_copy_2(), byte_copy_4(), byte_load_2(), byte_load_3(), byte_load_4(), CHAR_ENC_CPY_1, CHAR_ENC_CPY_2, CHAR_ENC_CPY_3, CHAR_ENC_CPY_4, CHAR_ENC_ERR_1, CHAR_ENC_ESC_1, CHAR_ENC_ESC_2, CHAR_ENC_ESC_3, CHAR_ENC_ESC_4, CHAR_ENC_ESC_A, expr_jump, expr_stop, is_utf8_seq2, is_utf8_seq3, is_utf8_seq4, likely, repeat16_incr, repeat4_incr, static_inline, and unlikely.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline u8 * write_str_noesc | ( | u8 * | cur, |
| const u8 * | str, | ||
| usize | str_len ) |
Write string no-escape.
| cur | Buffer cursor. |
| str | A UTF-8 string, null-terminator is not required. |
| str_len | Length of string in bytes. |
Definition at line 8816 of file yyjson.c.
References byte_copy_16(), byte_copy_4(), and static_inline.
Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
| static_inline u8 * write_u32_len_1_to_8 | ( | u32 | val, |
| u8 * | buf ) |
Definition at line 7249 of file yyjson.c.
References byte_copy_2(), and static_inline.
Referenced by write_u64().
| static_inline u8 * write_u32_len_4 | ( | u32 | val, |
| u8 * | buf ) |
Definition at line 7240 of file yyjson.c.
References byte_copy_2(), and static_inline.
Referenced by write_u64().
| static_inline u8 * write_u32_len_5_to_8 | ( | u32 | val, |
| u8 * | buf ) |
Definition at line 7296 of file yyjson.c.
References byte_copy_2(), and static_inline.
Referenced by write_u64().
| static_inline u8 * write_u32_len_8 | ( | u32 | val, |
| u8 * | buf ) |
Definition at line 7225 of file yyjson.c.
References byte_copy_2(), and static_inline.
Referenced by write_u64().
| static_inline u8 * write_u64 | ( | u64 | val, |
| u8 * | buf ) |
Definition at line 7328 of file yyjson.c.
References static_inline, write_u32_len_1_to_8(), write_u32_len_4(), write_u32_len_5_to_8(), and write_u32_len_8().
Referenced by write_num(), and yyjson_write_number().
| void yyjson_alc_dyn_free | ( | yyjson_alc * | alc | ) |
Free a dynamic allocator which is created by yyjson_alc_dyn_new().
| alc | The dynamic allocator to be destroyed. |
Definition at line 2540 of file yyjson.c.
References yyjson_alc::ctx, yyjson_alc::free, dyn_ctx::free_list, dyn_chunk::next, unlikely, dyn_ctx::used_list, and YYJSON_DEFAULT_ALC.
| yyjson_alc * yyjson_alc_dyn_new | ( | void | ) |
A dynamic allocator.
This allocator has a similar usage to the pool allocator above. However, when there is not enough memory, this allocator will dynamically request more memory using libc's malloc function, and frees it all at once when it is destroyed.
Definition at line 2524 of file yyjson.c.
References yyjson_alc::ctx, dyn_free(), dyn_malloc(), dyn_realloc(), yyjson_alc::free, yyjson_alc::malloc, yyjson_alc::realloc, unlikely, and YYJSON_DEFAULT_ALC.
| bool yyjson_alc_pool_init | ( | yyjson_alc * | alc, |
| void * | buf, | ||
| size_t | size ) |
A pool allocator uses fixed length pre-allocated memory.
This allocator may be used to avoid malloc/realloc calls. The pre-allocated memory should be held by the caller. The maximum amount of memory required to read a JSON can be calculated using the yyjson_read_max_memory_usage() function, but the amount of memory required to write a JSON cannot be directly calculated.
This is not a general-purpose allocator. It is designed to handle a single JSON document at a time. If it is used for overly complex memory tasks, such as parsing multiple JSON documents using the same allocator but releasing only a few of them, it may cause memory fragmentation, resulting in performance degradation and memory waste.
| alc | The allocator to be initialized. If alc is NULL, returns false. If buf or size is invalid, this will be set to an empty allocator. |
| buf | The buffer memory for this allocator. If buf is NULL, returns false. |
| size | The size of buf, in bytes. If size is less than 8 words (32/64 bytes on 32/64-bit OS), returns false. |
Example
Definition at line 2376 of file yyjson.c.
References yyjson_alc::ctx, yyjson_alc::free, pool_ctx::free_list, yyjson_alc::malloc, mem_align_up(), pool_chunk::next, pool_free(), pool_malloc(), pool_realloc(), yyjson_alc::realloc, pool_chunk::size, pool_ctx::size, size_align_down(), unlikely, and YYJSON_NULL_ALC.
| yyjson_align | ( | 2 | ) |
| yyjson_mut_doc * yyjson_doc_mut_copy | ( | const yyjson_doc * | doc, |
| const yyjson_alc * | alc ) |
Copies and returns a new mutable document from input, returns NULL on error. This makes a deep-copy on the immutable document. If allocator is NULL, the default allocator will be used.
Definition at line 2678 of file yyjson.c.
References yyjson_doc::root, yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), and yyjson_val_mut_copy().
Referenced by append_rate_limit_event_runtime_local(), append_validation_error_runtime(), build_artifact_local_app_manifest_json(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_normalize_ucal_state_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_mutate_command(), handle_generated_surface_validation_report_command(), handle_issue_business_invite_action_runtime(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_state_named_command(), issue_browser_session_runtime(), and revoke_session_by_cookie_runtime().
|
static |
Definition at line 2858 of file yyjson.c.
References len, yyjson_mut_val::next, yyjson_val_uni::ofs, yyjson_val_uni::ptr, yyjson_val_uni::str, yyjson_mut_val::tag, yyjson_val::tag, yyjson_mut_val::uni, yyjson_val::uni, unsafe_yyjson_get_len(), unsafe_yyjson_get_type(), yyjson_imut_copy(), YYJSON_TYPE_ARR, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by yyjson_imut_copy(), and yyjson_mut_val_imut_copy().
| void yyjson_incr_free | ( | yyjson_incr_state * | state | ) |
Release the incremental read state and free the memory.
Definition at line 6613 of file yyjson.c.
References yyjson_incr_state::alc, yyjson_alc::ctx, yyjson_incr_state::flg, yyjson_alc::free, yyjson_incr_state::hdr, yyjson_incr_state::val_hdr, and YYJSON_READ_INSITU.
| yyjson_incr_state * yyjson_incr_new | ( | char * | buf, |
| size_t | buf_len, | ||
| yyjson_read_flag | flg, | ||
| const yyjson_alc * | alc ) |
Initialize state for incremental read.
To read a large JSON document incrementally:
Note: The incremental JSON reader only supports standard JSON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.
| buf | The JSON data, null-terminator is not required. If buf is NULL, returns NULL. |
| buf_len | The length of the JSON data in buf. If using YYJSON_READ_INSITU, buf_len should not include the padding size. |
| flg | The JSON read options. Multiple options can be combined with | operator. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
Definition at line 6575 of file yyjson.c.
References yyjson_incr_state::alc, yyjson_incr_state::buf_len, yyjson_alc::ctx, yyjson_incr_state::cur, yyjson_incr_state::flg, yyjson_alc::free, has_flg, yyjson_incr_state::hdr, yyjson_incr_state::label, LABEL_doc_begin, yyjson_alc::malloc, yyjson_incr_state::raw_end, yyjson_incr_state::raw_ptr, unlikely, USIZE_MAX, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, YYJSON_READ_ALLOW_BOM, YYJSON_READ_ALLOW_INVALID_UNICODE, and YYJSON_READ_JSON5.
| yyjson_doc * yyjson_incr_read | ( | yyjson_incr_state * | state, |
| size_t | len, | ||
| yyjson_read_err * | err ) |
Performs incremental read of up to len bytes.
If NULL is returned and err->code is set to YYJSON_READ_ERROR_MORE, it indicates that more data is required to continue parsing. Then, call this function again with incremented len. Continue until a document is returned or an error other than YYJSON_READ_ERROR_MORE is returned.
Note: Parsing in very small increments is not efficient. An increment of several kilobytes or megabytes is recommended.
| state | The state for incremental reading, created using yyjson_incr_new(). |
| len | The number of bytes of JSON data available to parse. If len is 0, returns NULL. |
| err | A pointer to receive error information. |
Definition at line 6627 of file yyjson.c.
References yyjson_doc::alc, yyjson_incr_state::alc, yyjson_incr_state::alc_len, yyjson_incr_state::buf_len, char_is_ctn(), char_is_num(), char_is_space(), check_maybe_truncated_number, yyjson_read_err::code, yyjson_incr_state::ctn, yyjson_incr_state::ctn_len, yyjson_alc::ctx, yyjson_incr_state::cur, yyjson_doc::dat_read, yyjson_incr_state::flg, has_flg, yyjson_incr_state::hdr, yyjson_incr_state::hdr_len, is_utf16_bom(), is_utf32_bom(), is_utf8_bom(), yyjson_incr_state::label, LABEL_arr_val_begin, LABEL_arr_val_end, LABEL_doc_begin, LABEL_doc_end, LABEL_obj_key_begin, LABEL_obj_key_end, LABEL_obj_val_begin, LABEL_obj_val_end, len, likely, yyjson_alc::malloc, yyjson_read_err::msg, MSG_ARR_END, MSG_CHAR, MSG_CHAR_F, MSG_CHAR_N, MSG_CHAR_T, MSG_COMMA, MSG_DEPTH, MSG_ERR_BOM, MSG_ERR_UTF16, MSG_ERR_UTF32, MSG_GARBAGE, MSG_MALLOC, MSG_NOT_END, MSG_OBJ_END, MSG_OBJ_KEY, MSG_OBJ_SEP, yyjson_val_uni::ofs, yyjson_read_err::pos, yyjson_incr_state::raw_ptr, read_false(), read_null(), read_num(), read_str_con(), read_true(), return_err, return_err_inv_param, yyjson_doc::root, save_incr_state, yyjson_incr_state::str_con, yyjson_doc::str_pool, yyjson_val::tag, yyjson_val::uni, unlikely, USIZE_MAX, yyjson_incr_state::val, yyjson_incr_state::val_end, yyjson_incr_state::val_hdr, val_incr, yyjson_doc::val_read, yyjson_min, YYJSON_READ_ERROR_MORE, YYJSON_READ_ERROR_UNEXPECTED_END, YYJSON_READER_DEPTH_LIMIT, YYJSON_READER_ESTIMATED_MINIFY_RATIO, YYJSON_TAG_BIT, YYJSON_TAG_MASK, YYJSON_TYPE_ARR, YYJSON_TYPE_MASK, and YYJSON_TYPE_OBJ.
| bool yyjson_locate_pos | ( | const char * | str, |
| size_t | len, | ||
| size_t | pos, | ||
| size_t * | line, | ||
| size_t * | col, | ||
| size_t * | chr ) |
Locate the line and column number for a byte position in a string. This can be used to get better description for error position.
| str | The input string. |
| len | The byte length of the input string. |
| pos | The byte position within the input string. |
| line | A pointer to receive the line number, starting from 1. |
| col | A pointer to receive the column number, starting from 1. |
| chr | A pointer to receive the character index, starting from 0. |
Definition at line 3078 of file yyjson.c.
References is_utf8_bom(), len, and likely.
| yyjson_mut_val * yyjson_merge_patch | ( | yyjson_mut_doc * | doc, |
| const yyjson_val * | orig, | ||
| const yyjson_val * | patch ) |
Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
Definition at line 11284 of file yyjson.c.
References yyjson_mut_val::tag, yyjson_val::tag, yyjson_mut_val::uni, yyjson_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_is_null(), yyjson_is_obj(), yyjson_merge_patch(), yyjson_mut_obj(), yyjson_mut_obj_add(), yyjson_obj_foreach, yyjson_obj_getn(), and yyjson_val_mut_copy().
Referenced by yyjson_merge_patch().
| static_inline usize yyjson_mut_doc_estimated_val_num | ( | const yyjson_mut_doc * | doc | ) |
Get the estimated number of values for the mutable JSON document.
Definition at line 9857 of file yyjson.c.
References yyjson_val_chunk::chunk_size, yyjson_val_pool::chunks, yyjson_val_pool::cur, yyjson_val_pool::end, yyjson_val_chunk::next, static_inline, and yyjson_mut_doc::val_pool.
Referenced by yyjson_mut_write_opts().
| void yyjson_mut_doc_free | ( | yyjson_mut_doc * | doc | ) |
Release the JSON document and free the memory. After calling this function, the doc and all values from the doc are no longer available. This function will do nothing if the doc is NULL.
Definition at line 2653 of file yyjson.c.
References yyjson_mut_doc::alc, yyjson_alc::ctx, yyjson_alc::free, yyjson_mut_doc::str_pool, unsafe_yyjson_str_pool_release(), unsafe_yyjson_val_pool_release(), and yyjson_mut_doc::val_pool.
Referenced by append_rate_limit_event_runtime_local(), append_validation_error_runtime(), appointments_render_page_params_json_dup_runtime(), build_artifact_local_app_manifest_json(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_json_string_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_accept_invite_action_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_file_normalize_ucal_state_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_generated_surface_validation_report_command(), handle_issue_business_invite_action_runtime(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_password_reset_complete_action_runtime(), handle_password_reset_request_action_runtime(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), issue_browser_session_runtime(), login_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), password_reset_sent_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), revoke_session_by_cookie_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), and yyjson_mut_doc_mut_copy().
| yyjson_doc * yyjson_mut_doc_imut_copy | ( | const yyjson_mut_doc * | doc, |
| const yyjson_alc * | alc ) |
Copies and returns a new immutable document from input, returns NULL on error. This makes a deep-copy on the mutable document. The returned document should be freed with yyjson_doc_free().
Definition at line 2898 of file yyjson.c.
References yyjson_mut_doc::root, and yyjson_mut_val_imut_copy().
| yyjson_mut_doc * yyjson_mut_doc_mut_copy | ( | const yyjson_mut_doc * | doc, |
| const yyjson_alc * | alc ) |
Copies and returns a new mutable document from input, returns NULL on error. This makes a deep-copy on the mutable document. If allocator is NULL, the default allocator will be used.
Definition at line 2695 of file yyjson.c.
References yyjson_mut_doc::root, yyjson_mut_doc_free(), yyjson_mut_doc_new(), yyjson_mut_doc_set_root(), and yyjson_mut_val_mut_copy().
| yyjson_mut_doc * yyjson_mut_doc_new | ( | const yyjson_alc * | alc | ) |
Creates and returns a new mutable JSON document, returns NULL on error. If allocator is NULL, the default allocator will be used.
Definition at line 2663 of file yyjson.c.
References yyjson_mut_doc::alc, yyjson_str_pool::chunk_size, yyjson_val_pool::chunk_size, yyjson_str_pool::chunk_size_max, yyjson_val_pool::chunk_size_max, yyjson_alc::ctx, yyjson_alc::malloc, yyjson_mut_doc::str_pool, yyjson_mut_doc::val_pool, YYJSON_DEFAULT_ALC, YYJSON_MUT_DOC_STR_POOL_INIT_SIZE, YYJSON_MUT_DOC_STR_POOL_MAX_SIZE, YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE, and YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE.
Referenced by appointments_render_page_params_json_dup_runtime(), business_availability_edit_page_params_json_dup_runtime(), business_calendar_render_page_params_json_dup_runtime(), business_dashboard_render_page_params_json_dup_runtime(), business_detail_admin_render_page_params_json_dup_runtime(), business_edit_page_params_json_dup_runtime(), business_landing_render_page_params_json_dup_runtime(), diagnostics_render_page_params_json_dup_runtime(), emit_appointments_page_json_runtime(), emit_business_admin_page_json_runtime(), emit_business_admin_service_rows_json_runtime(), emit_business_admin_technician_rows_json_runtime(), emit_business_calendar_page_json_runtime(), emit_business_calendar_render_page_json_runtime(), emit_business_dashboard_page_json_runtime(), emit_business_edit_page_json_runtime(), emit_business_public_page_json_runtime(), emit_business_public_render_page_json_runtime(), emit_calendar_page_json_runtime(), emit_explore_page_json_runtime(), emit_json_string_runtime(), emit_manageable_business_cards_json_runtime(), emit_managed_appointments_json_runtime(), emit_profile_page_json_runtime(), emit_profile_render_page_json_runtime(), emit_public_business_cards_json_runtime(), emit_service_book_form_page_json_runtime(), emit_service_edit_page_json_runtime(), emit_technician_edit_page_json_runtime(), emit_template_page_params_json_runtime(), emit_user_appointments_json_runtime(), explore_render_page_params_json_dup_runtime(), generated_admin_manage_page_params_json_dup_runtime(), generated_surface_operation_path_dup_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_edit_page_json_command(), handle_generated_surface_list_columns_json_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_manage_table_json_command(), handle_generated_surface_params_json_command(), handle_generated_surface_submitted_command(), handle_object_build_command(), handle_object_merge_command(), handle_object_relative_path_array_to_absolute_json_command(), handle_request_booking_options_json_from_form_command(), handle_request_lines_to_booking_options_json_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), handle_state_ucal_import_row_json_lines_command(), handle_template_declared_page_contract_command(), handle_template_layout_page_html_command(), handle_template_layout_page_json_command(), invite_accept_done_page_params_json_dup_runtime(), invite_accept_page_params_json_dup_runtime(), invite_created_page_params_json_dup_runtime(), login_page_params_json_dup_runtime(), password_reset_complete_page_params_json_dup_runtime(), password_reset_request_page_params_json_dup_runtime(), password_reset_sent_page_params_json_dup_runtime(), profile_page_params_json_dup_runtime_local(), profile_render_page_params_json_dup_runtime(), proof_home_page_params_json_dup_runtime(), register_page_params_json_dup_runtime(), render_business_admin_empty_state_dup_runtime(), render_business_dashboard_cards_html_dup_runtime(), render_page_html_dup_runtime(), render_service_booking_options_editor_html_dup_runtime(), render_service_sort_order_options_html_dup_runtime(), render_service_visual_html_dup_runtime(), render_technician_checkboxes_html_dup_runtime(), service_book_form_page_params_json_dup_runtime(), service_edit_page_params_json_dup_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), and yyjson_mut_doc_mut_copy().
| bool yyjson_mut_doc_set_str_pool_size | ( | yyjson_mut_doc * | doc, |
| size_t | len ) |
Set the string pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed.
If the caller knows the approximate bytes of strings that the document needs to store (e.g. copy string with yyjson_mut_strcpy function), setting a larger size can avoid multiple memory allocations and improve performance.
| doc | The mutable document. |
| len | The desired string pool size in bytes (total string length). |
Definition at line 2639 of file yyjson.c.
References yyjson_str_pool::chunk_size, len, yyjson_mut_doc::str_pool, and USIZE_MAX.
| bool yyjson_mut_doc_set_val_pool_size | ( | yyjson_mut_doc * | doc, |
| size_t | count ) |
Set the value pool size for a mutable document. This function does not allocate memory immediately, but uses the size when the next memory allocation is needed.
If the caller knows the approximate number of values that the document needs to store (e.g. create new value with yyjson_mut_xxx functions), setting a larger size can avoid multiple memory allocations and improve performance.
| doc | The mutable document. |
| count | The desired value pool size (number of yyjson_mut_val). |
Definition at line 2646 of file yyjson.c.
References yyjson_val_pool::chunk_size, USIZE_MAX, and yyjson_mut_doc::val_pool.
| yyjson_mut_val * yyjson_mut_merge_patch | ( | yyjson_mut_doc * | doc, |
| const yyjson_mut_val * | orig, | ||
| const yyjson_mut_val * | patch ) |
Creates and returns a merge-patched JSON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
Definition at line 11336 of file yyjson.c.
References yyjson_mut_val::tag, yyjson_mut_val::uni, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_get_str(), unsafe_yyjson_is_null(), yyjson_mut_is_obj(), yyjson_mut_merge_patch(), yyjson_mut_obj(), yyjson_mut_obj_add(), yyjson_mut_obj_foreach, yyjson_mut_obj_getn(), and yyjson_mut_val_mut_copy().
Referenced by yyjson_mut_merge_patch().
| yyjson_mut_val * yyjson_mut_patch | ( | yyjson_mut_doc * | doc, |
| const yyjson_mut_val * | orig, | ||
| const yyjson_mut_val * | patch, | ||
| yyjson_patch_err * | err ) |
Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the doc. The err is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied.
Definition at line 11147 of file yyjson.c.
References constcast, PATCH_OP_ADD, PATCH_OP_COPY, patch_op_get(), PATCH_OP_MOVE, PATCH_OP_REMOVE, PATCH_OP_REPLACE, PATCH_OP_TEST, ptr_add, ptr_get, ptr_remove, ptr_replace, return_err, return_err_copy, return_err_key, return_err_val, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_obj(), yyjson_mut_arr_iter_init(), yyjson_mut_arr_iter_next(), yyjson_mut_equals(), yyjson_mut_is_arr(), yyjson_mut_is_str(), yyjson_mut_obj_get(), and yyjson_mut_val_mut_copy().
|
static |
Definition at line 2833 of file yyjson.c.
References len, yyjson_mut_val::next, yyjson_val_uni::ptr, yyjson_mut_val::uni, unsafe_yyjson_get_len(), unsafe_yyjson_get_type(), yyjson_mut_stat(), YYJSON_TYPE_ARR, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by yyjson_mut_stat(), and yyjson_mut_val_imut_copy().
| yyjson_doc * yyjson_mut_val_imut_copy | ( | const yyjson_mut_val * | val, |
| const yyjson_alc * | alc ) |
Copies and returns a new immutable document from input, returns NULL on error. This makes a deep-copy on the mutable value. The returned document should be freed with yyjson_doc_free().
Definition at line 2904 of file yyjson.c.
References yyjson_doc::alc, yyjson_alc::ctx, yyjson_doc::dat_read, yyjson_alc::free, yyjson_alc::malloc, yyjson_doc::root, size_align_up(), yyjson_doc::str_pool, yyjson_doc::val_read, YYJSON_DEFAULT_ALC, yyjson_imut_copy(), and yyjson_mut_stat().
Referenced by yyjson_mut_doc_imut_copy().
| yyjson_mut_val * yyjson_mut_val_mut_copy | ( | yyjson_mut_doc * | doc, |
| const yyjson_mut_val * | val ) |
Copies and returns a new mutable value from input, returns NULL on error. This makes a deep-copy on the mutable value. The memory is managed by the mutable document.
Definition at line 2826 of file yyjson.c.
References unsafe_yyjson_mut_val_mut_copy().
Referenced by yyjson_mut_doc_mut_copy(), yyjson_mut_merge_patch(), yyjson_mut_patch(), and yyjson_patch().
| size_t yyjson_mut_val_write_buf | ( | char * | buf, |
| size_t | buf_len, | ||
| const yyjson_mut_val * | val, | ||
| yyjson_write_flag | flg, | ||
| yyjson_write_err * | err ) |
Write a value into a buffer.
This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.
| buf | The output buffer. If buf is NULL, returns 0. |
| buf_len | The buffer length. If buf_len is too small, returns 0. |
| val | The JSON root value. If val is NULL, returns 0. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10365 of file yyjson.c.
References yyjson_write_err::code, yyjson_write_err::msg, mut_write_root(), unlikely, YYJSON_NULL_ALC, and YYJSON_WRITE_ERROR_INVALID_PARAMETER.
Referenced by yyjson_mut_write_buf().
| bool yyjson_mut_val_write_file | ( | const char * | path, |
| const yyjson_mut_val * | val, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a value to JSON file with options.
This function is thread-safe when:
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded. |
| val | The mutable JSON root value. If val is NULL, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10389 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_file(), YYJSON_DEFAULT_ALC, yyjson_mut_val_write_opts(), and YYJSON_WRITE_ERROR_INVALID_PARAMETER.
Referenced by yyjson_mut_write_file().
| bool yyjson_mut_val_write_fp | ( | FILE * | fp, |
| const yyjson_mut_val * | val, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a value to file pointer with options.
| fp | The file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false. |
| val | The mutable JSON root value. If val is NULL, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10415 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_fp(), YYJSON_DEFAULT_ALC, yyjson_mut_val_write_opts(), and YYJSON_WRITE_ERROR_INVALID_PARAMETER.
Referenced by yyjson_mut_write_fp().
| char * yyjson_mut_val_write_opts | ( | const yyjson_mut_val * | val, |
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| size_t * | len, | ||
| yyjson_write_err * | err ) |
Write a value to JSON string with options.
This function is thread-safe when:
| val | The mutable JSON root value. If val is NULL, returns NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10339 of file yyjson.c.
References mut_write_root().
Referenced by yyjson_mut_val_write(), yyjson_mut_val_write_file(), and yyjson_mut_val_write_fp().
| size_t yyjson_mut_write_buf | ( | char * | buf, |
| size_t | buf_len, | ||
| const yyjson_mut_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| yyjson_write_err * | err ) |
Write a document into a buffer.
This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.
| buf | The output buffer. If buf is NULL, returns 0. |
| buf_len | The buffer length. If buf_len is too small, returns 0. |
| doc | The JSON document. If doc is NULL or has no root, returns 0. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10379 of file yyjson.c.
References yyjson_mut_doc::root, and yyjson_mut_val_write_buf().
| static_inline void yyjson_mut_write_ctx_get | ( | yyjson_mut_write_ctx * | ctx, |
| yyjson_mut_val ** | ctn, | ||
| usize * | size, | ||
| bool * | is_obj ) |
Definition at line 9847 of file yyjson.c.
References bool, yyjson_mut_write_ctx::ctn, static_inline, and yyjson_mut_write_ctx::tag.
Referenced by mut_write_root_minify(), and mut_write_root_pretty().
| static_inline void yyjson_mut_write_ctx_set | ( | yyjson_mut_write_ctx * | ctx, |
| yyjson_mut_val * | ctn, | ||
| usize | size, | ||
| bool | is_obj ) |
Definition at line 9840 of file yyjson.c.
References yyjson_mut_write_ctx::ctn, static_inline, and yyjson_mut_write_ctx::tag.
Referenced by mut_write_root_minify(), and mut_write_root_pretty().
| bool yyjson_mut_write_file | ( | const char * | path, |
| const yyjson_mut_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a document to JSON file with options.
This function is thread-safe when:
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded. |
| doc | The mutable JSON document. If doc is NULL or has no root, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10441 of file yyjson.c.
References yyjson_mut_doc::root, and yyjson_mut_val_write_file().
| bool yyjson_mut_write_fp | ( | FILE * | fp, |
| const yyjson_mut_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a document to file pointer with options.
| fp | The file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false. |
| doc | The mutable JSON document. If doc is NULL or has no root, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10450 of file yyjson.c.
References yyjson_mut_doc::root, and yyjson_mut_val_write_fp().
| char * yyjson_mut_write_opts | ( | const yyjson_mut_doc * | doc, |
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| size_t * | len, | ||
| yyjson_write_err * | err ) |
Write a document to JSON string with options.
This function is thread-safe when:
| doc | The mutable JSON document. If doc is NULL or has no root, returns NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 10347 of file yyjson.c.
References likely, mut_write_root(), yyjson_mut_doc::root, and yyjson_mut_doc_estimated_val_num().
Referenced by yyjson_mut_write().
| yyjson_mut_val * yyjson_patch | ( | yyjson_mut_doc * | doc, |
| const yyjson_val * | orig, | ||
| const yyjson_val * | patch, | ||
| yyjson_patch_err * | err ) |
Creates and returns a patched JSON value (RFC 6902). The memory of the returned value is allocated by the doc. The err is used to receive error information, pass NULL if not needed. Returns NULL if the patch could not be applied.
Definition at line 11026 of file yyjson.c.
References PATCH_OP_ADD, PATCH_OP_COPY, patch_op_get(), PATCH_OP_MOVE, PATCH_OP_REMOVE, PATCH_OP_REPLACE, PATCH_OP_TEST, ptr_add, ptr_get, ptr_remove, ptr_replace, return_err, return_err_copy, return_err_key, return_err_val, unlikely, unsafe_yyjson_get_len(), unsafe_yyjson_is_obj(), yyjson_arr_iter_init(), yyjson_arr_iter_next(), yyjson_is_arr(), yyjson_is_str(), yyjson_mut_equals(), yyjson_mut_val_mut_copy(), yyjson_obj_get(), and yyjson_val_mut_copy().
| yyjson_doc * yyjson_read_file | ( | const char * | path, |
| yyjson_read_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_read_err * | err ) |
Read a JSON file.
This function is thread-safe when:
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 6341 of file yyjson.c.
References fopen_readonly(), MSG_FREAD, return_err, unlikely, and yyjson_read_fp().
| yyjson_doc * yyjson_read_fp | ( | FILE * | fp, |
| yyjson_read_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_read_err * | err ) |
Read JSON from a file pointer.
| fp | The file pointer. The data will be read from the current position of the FILE to the end. If fp is NULL or invalid, returns NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 6369 of file yyjson.c.
References yyjson_alc::ctx, fread_safe(), yyjson_alc::free, yyjson_alc::malloc, MSG_FREAD, MSG_MALLOC, yyjson_alc::realloc, return_err, yyjson_doc::str_pool, unlikely, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, YYJSON_READ_INSITU, and yyjson_read_opts().
Referenced by yyjson_read_file().
| const char * yyjson_read_number | ( | const char * | dat, |
| yyjson_val * | val, | ||
| yyjson_read_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_read_err * | err ) |
Read a JSON number.
This function is thread-safe when data is not modified by other threads.
| dat | The JSON data (UTF-8 without BOM), null-terminator is required. If dat is NULL, returns NULL. |
| val | The output value where result is stored. If val is NULL, returns NULL. The value will hold either UINT or SINT or REAL number; |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. Supports YYJSON_READ_NUMBER_AS_RAW and YYJSON_READ_ALLOW_INF_AND_NAN. |
| alc | The memory allocator used for long number. It is only used when the built-in floating point reader is disabled. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 6469 of file yyjson.c.
References constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_alc::malloc, MSG_MALLOC, read_num(), return_err, yyjson_val_uni::str, yyjson_val::uni, unlikely, YYJSON_DEFAULT_ALC, and yyjson_is_raw().
Referenced by yyjson_mut_read_number().
| yyjson_doc * yyjson_read_opts | ( | char * | dat, |
| size_t | len, | ||
| yyjson_read_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_read_err * | err ) |
Read JSON with options.
This function is thread-safe when:
| dat | The JSON data (UTF-8 without BOM), null-terminator is not required. If dat is NULL, returns NULL. The dat will not be modified without the flag YYJSON_READ_INSITU, so you can pass a const char * string and cast it to char * if you don't use the YYJSON_READ_INSITU flag. |
| len | The length of JSON data in bytes. If len is 0, returns NULL. |
| flg | The JSON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 6251 of file yyjson.c.
References char_is_ctn(), char_is_space(), char_is_trivia(), yyjson_read_err::code, yyjson_alc::ctx, yyjson_alc::free, has_allow, has_flg, is_utf16_bom(), is_utf32_bom(), is_utf8_bom(), len, likely, yyjson_alc::malloc, yyjson_read_err::msg, MSG_COMMENT, MSG_ERR_BOM, MSG_ERR_UTF16, MSG_ERR_UTF32, MSG_MALLOC, yyjson_read_err::pos, read_root_minify(), read_root_pretty(), read_root_single(), return_err, skip_trivia(), unlikely, USIZE_MAX, YYJSON_DEFAULT_ALC, YYJSON_PADDING_SIZE, and YYJSON_READ_ERROR_MEMORY_ALLOCATION.
Referenced by yyjson_read(), and yyjson_read_fp().
| yyjson_mut_val * yyjson_val_mut_copy | ( | yyjson_mut_doc * | doc, |
| const yyjson_val * | val ) |
Copies and returns a new mutable value from input, returns NULL on error. This makes a deep-copy on the immutable value. The memory is managed by the mutable document.
Definition at line 2714 of file yyjson.c.
References constcast, len, yyjson_mut_val::next, yyjson_val_uni::ptr, yyjson_val_uni::str, yyjson_mut_val::tag, yyjson_val::tag, yyjson_val_uni::u64, yyjson_mut_val::uni, yyjson_val::uni, unsafe_yyjson_get_len(), unsafe_yyjson_get_next(), unsafe_yyjson_get_type(), unsafe_yyjson_mut_strncpy(), unsafe_yyjson_mut_val(), YYJSON_TYPE_ARR, YYJSON_TYPE_OBJ, YYJSON_TYPE_RAW, and YYJSON_TYPE_STR.
Referenced by generated_surface_append_audit_event_mut_runtime(), handle_action_route(), handle_file_generated_surface_match_command(), handle_generated_surface_coerce_candidate_command(), handle_generated_surface_context_command(), handle_generated_surface_default_candidate_command(), handle_generated_surface_list_result_command(), handle_generated_surface_manage_page_json_command(), handle_generated_surface_mutate_command(), handle_generated_surface_submitted_command(), handle_object_build_command(), handle_object_merge_command(), handle_state_event_stream_row_json_lines_command(), handle_state_named_command(), merge_patch_into_mut_object_runtime(), normalized_payload_object_mut_runtime(), surface_build_active_filters_runtime(), surface_build_sort_config_runtime(), write_business_availability_api_response(), write_business_services_api_response(), write_generated_surface_schema_response(), yyjson_doc_mut_copy(), yyjson_merge_patch(), and yyjson_patch().
| size_t yyjson_val_write_buf | ( | char * | buf, |
| size_t | buf_len, | ||
| const yyjson_val * | val, | ||
| yyjson_write_flag | flg, | ||
| yyjson_write_err * | err ) |
Write a value into a buffer.
This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.
| buf | The output buffer. If buf is NULL, returns 0. |
| buf_len | The buffer length. If buf_len is too small, returns 0. |
| val | The JSON root value. If val is NULL, returns 0. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9807 of file yyjson.c.
References yyjson_write_err::code, yyjson_write_err::msg, unlikely, write_root(), YYJSON_NULL_ALC, and YYJSON_WRITE_ERROR_INVALID_PARAMETER.
Referenced by yyjson_write_buf().
| bool yyjson_val_write_file | ( | const char * | path, |
| const yyjson_val * | val, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a value to JSON file with options.
This function is thread-safe when:
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded. |
| val | The JSON root value. If val is NULL, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9735 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_file(), write_root(), YYJSON_DEFAULT_ALC, and YYJSON_READ_ERROR_INVALID_PARAMETER.
Referenced by yyjson_write_file().
| bool yyjson_val_write_fp | ( | FILE * | fp, |
| const yyjson_val * | val, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a value to file pointer with options.
| fp | The file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false. |
| val | The JSON root value. If val is NULL, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9761 of file yyjson.c.
References yyjson_write_err::code, constcast, yyjson_alc::ctx, yyjson_alc::free, yyjson_write_err::msg, unlikely, write_dat_to_fp(), write_root(), YYJSON_DEFAULT_ALC, and YYJSON_READ_ERROR_INVALID_PARAMETER.
Referenced by yyjson_write_fp().
| char * yyjson_val_write_opts | ( | const yyjson_val * | val, |
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| size_t * | len, | ||
| yyjson_write_err * | err ) |
Write a value to JSON string with options.
This function is thread-safe when: The alc is thread-safe or NULL.
| val | The JSON root value. If val is NULL, returns NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9716 of file yyjson.c.
References write_root().
Referenced by yyjson_val_write().
| uint32_t yyjson_version | ( | void | ) |
The version of yyjson in hex, same as YYJSON_VERSION_HEX.
Definition at line 58 of file yyjson.c.
References YYJSON_VERSION_HEX.
| size_t yyjson_write_buf | ( | char * | buf, |
| size_t | buf_len, | ||
| const yyjson_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| yyjson_write_err * | err ) |
Write a document into a buffer.
This function does not allocate memory, but the buffer must be larger than the final JSON size to allow temporary space. See API.md for details.
| buf | The output buffer. If buf is NULL, returns 0. |
| buf_len | The buffer length. If buf_len is too small, returns 0. |
| doc | The JSON document. If doc is NULL or has no root, returns 0. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9821 of file yyjson.c.
References yyjson_doc::root, and yyjson_val_write_buf().
| static_inline void yyjson_write_ctx_get | ( | yyjson_write_ctx * | ctx, |
| usize * | size, | ||
| bool * | is_obj ) |
Definition at line 9157 of file yyjson.c.
References bool, static_inline, and yyjson_write_ctx::tag.
Referenced by write_root_minify(), and write_root_pretty().
| static_inline void yyjson_write_ctx_set | ( | yyjson_write_ctx * | ctx, |
| usize | size, | ||
| bool | is_obj ) |
Definition at line 9152 of file yyjson.c.
References static_inline, and yyjson_write_ctx::tag.
Referenced by write_root_minify(), and write_root_pretty().
| bool yyjson_write_file | ( | const char * | path, |
| const yyjson_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a document to JSON file with options.
This function is thread-safe when:
| path | The JSON file's path. This should be a null-terminated string using the system's native encoding. If path is NULL or invalid, returns false. If the file is not empty, its content is discarded. |
| doc | The JSON document. If doc is NULL or has no root, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9787 of file yyjson.c.
References yyjson_doc::root, and yyjson_val_write_file().
| bool yyjson_write_fp | ( | FILE * | fp, |
| const yyjson_doc * | doc, | ||
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| yyjson_write_err * | err ) |
Write a document to file pointer with options.
| fp | The file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false. |
| doc | The JSON document. If doc is NULL or has no root, returns false. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9796 of file yyjson.c.
References yyjson_doc::root, and yyjson_val_write_fp().
| char * yyjson_write_number | ( | const yyjson_val * | val, |
| char * | buf ) |
Write a JSON number.
| val | A JSON number value to be converted to a string. If val is invalid, returns NULL. |
| buf | A buffer to store the resulting null-terminated string. If buf is NULL, returns NULL. For integer values, the buffer must be at least 21 bytes. For floating-point values, the buffer must be at least 40 bytes. |
Definition at line 8427 of file yyjson.c.
References likely, yyjson_val::tag, yyjson_val_uni::u64, yyjson_val::uni, unlikely, write_f32_raw(), write_f64_raw(), write_f64_raw_fixed(), write_u64(), YYJSON_SUBTYPE_REAL, YYJSON_SUBTYPE_SINT, YYJSON_SUBTYPE_UINT, YYJSON_TAG_MASK, YYJSON_TYPE_NUM, YYJSON_WRITE_ALLOW_INF_AND_NAN, YYJSON_WRITE_FP_FLAG_BITS, YYJSON_WRITE_FP_PREC_BITS, and YYJSON_WRITE_FP_TO_FLOAT.
Referenced by yyjson_mut_write_number().
| char * yyjson_write_opts | ( | const yyjson_doc * | doc, |
| yyjson_write_flag | flg, | ||
| const yyjson_alc * | alc, | ||
| size_t * | len, | ||
| yyjson_write_err * | err ) |
Write a document to JSON string with options.
This function is thread-safe when: The alc is thread-safe or NULL.
| doc | The JSON document. If doc is NULL or has no root, returns NULL. |
| flg | The JSON write options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by JSON writer. Pass NULL to use the libc's default allocator. |
| len | A pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Definition at line 9724 of file yyjson.c.
References yyjson_doc::root, and write_root().
Referenced by yyjson_write().
|
static |
Definition at line 770 of file yyjson.c.
Referenced by char_is_ascii_skip(), char_is_ascii_skip_sq(), char_is_num(), char_is_space(), char_is_space_ext(), and char_is_trivia().
|
static |
Definition at line 805 of file yyjson.c.
Referenced by char_is_eol(), char_is_eol_ext(), char_is_id_ascii(), char_is_id_next(), and char_is_id_start().
|
static |
Definition at line 840 of file yyjson.c.
Referenced by char_is_digit(), char_is_digit_or_fp(), char_is_exp(), char_is_fp(), char_is_nonzero(), and char_is_sign().
|
static |
Character encode type table: don't escape unicode, don't escape '/'. (generated with misc/make_tables.c)
Definition at line 8488 of file yyjson.c.
Referenced by get_enc_table_with_flag(), mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().
|
static |
Character encode type table: don't escape unicode, escape '/'. (generated with misc/make_tables.c)
Definition at line 8509 of file yyjson.c.
Referenced by get_enc_table_with_flag().
|
static |
Character encode type table: escape unicode, don't escape '/'. (generated with misc/make_tables.c)
Definition at line 8530 of file yyjson.c.
Referenced by get_enc_table_with_flag().
|
static |
Character encode type table: escape unicode, escape '/'. (generated with misc/make_tables.c)
Definition at line 8551 of file yyjson.c.
Referenced by get_enc_table_with_flag().
|
static |
This table is used to convert a 4-hex-character sequence to a number. A valid hex character [0-9A-Fa-f] is mapped to its raw value [0x00, 0x0F]; an invalid hex character is mapped to [0xF0]. (generated with misc/make_tables.c)
Definition at line 1027 of file yyjson.c.
Referenced by char_is_hex(), hex_load_2(), hex_load_4(), and read_num_hex().
|
static |
Definition at line 2238 of file yyjson.c.
Referenced by dyn_malloc(), dyn_realloc(), mut_write_root(), write_root(), yyjson_alc_dyn_free(), yyjson_alc_dyn_new(), yyjson_incr_new(), yyjson_mut_doc_new(), yyjson_mut_val_imut_copy(), yyjson_mut_val_write_file(), yyjson_mut_val_write_fp(), yyjson_read_fp(), yyjson_read_number(), yyjson_read_opts(), yyjson_val_write_file(), and yyjson_val_write_fp().
|
static |
Definition at line 2202 of file yyjson.c.
Referenced by yyjson_alc_pool_init(), yyjson_mut_val_write_buf(), and yyjson_val_write_buf().