Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
yyjson.c File Reference
#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
}

Functions

uint32_t yyjson_version (void)
static_inline void byte_copy_2 (void *dst, const void *src)
static_inline void byte_copy_4 (void *dst, const void *src)
static_inline void byte_copy_8 (void *dst, const void *src)
static_inline void byte_copy_16 (void *dst, const void *src)
static_inline void byte_move_2 (void *dst, const void *src)
static_inline void byte_move_4 (void *dst, const void *src)
static_inline void byte_move_8 (void *dst, const void *src)
static_inline void byte_move_16 (void *dst, const void *src)
static_inline void byte_move_forward (void *dst, void *src, usize n)
static_inline bool byte_match_2 (void *buf, const char *pat)
static_inline bool byte_match_4 (void *buf, const char *pat)
static_inline u16 byte_load_2 (const void *src)
static_inline u32 byte_load_3 (const void *src)
static_inline u32 byte_load_4 (const void *src)
static_inline bool char_is_space (u8 c)
static_inline bool char_is_space_ext (u8 c)
static_inline bool char_is_num (u8 c)
static_inline bool char_is_ascii_skip (u8 c)
static_inline bool char_is_ascii_skip_sq (u8 c)
static_inline bool char_is_trivia (u8 c)
static_inline bool char_is_eol (u8 c)
static_inline bool char_is_eol_ext (u8 c)
static_inline bool char_is_id_start (u8 c)
static_inline bool char_is_id_next (u8 c)
static_inline bool char_is_id_ascii (u8 c)
static_inline bool char_is_sign (u8 d)
static_inline bool char_is_nonzero (u8 d)
static_inline bool char_is_digit (u8 d)
static_inline bool char_is_exp (u8 d)
static_inline bool char_is_fp (u8 d)
static_inline bool char_is_digit_or_fp (u8 d)
static_inline bool char_is_ctn (u8 c)
static_inline u8 char_to_lower (u8 c)
static_inline bool is_utf8_bom (const u8 *cur)
static_inline bool is_utf16_bom (const u8 *cur)
static_inline bool is_utf32_bom (const u8 *cur)
static_inline usize ext_eol_len (const u8 *cur)
static_inline usize ext_space_len (const u8 *cur)
static_inline bool hex_load_4 (const u8 *src, u16 *dst)
static_inline bool hex_load_2 (const u8 *src, u8 *dst)
static_inline bool char_is_hex (u8 c)
 utf8_seq_def (b1_mask, utf8_seq_def(80, utf8_seq_def(00, utf8_seq_def(00, utf8_seq_def(00)
static_inline u64 f64_to_bits (f64 f)
static_inline u32 f32_to_bits (f32 f)
static_inline u64 f64_bits_inf (bool sign)
static_inline bool f64_is_inf (f64 val)
static_inline u64 f64_bits_nan (bool sign)
static_inline f32 f64_to_f32 (f64 val)
static_inline u32 u64_lz_bits (u64 v)
static_inline u32 u64_tz_bits (u64 v)
static_inline void u128_mul (u64 a, u64 b, u64 *hi, u64 *lo)
static_inline void u128_mul_add (u64 a, u64 b, u64 c, u64 *hi, u64 *lo)
static_inline FILE * fopen_safe (const char *path, const char *mode)
static_inline FILE * fopen_readonly (const char *path)
static_inline FILE * fopen_writeonly (const char *path)
static_inline usize fread_safe (void *buf, usize size, FILE *file)
static_inline bool size_add_is_overflow (usize size, usize add)
static_inline bool size_is_pow2 (usize size)
static_inline usize size_align_up (usize size, usize align)
static_inline usize size_align_down (usize size, usize align)
static_inline void * mem_align_up (void *mem, usize align)
static void * null_malloc (void *ctx, usize size)
static void * null_realloc (void *ctx, void *ptr, usize old_size, usize size)
static void null_free (void *ctx, void *ptr)
static void * default_malloc (void *ctx, usize size)
static void * default_realloc (void *ctx, void *ptr, usize old_size, usize size)
static void default_free (void *ctx, void *ptr)
static_inline void pool_size_align (usize *size)
static void * pool_malloc (void *ctx_ptr, usize size)
static void pool_free (void *ctx_ptr, void *ptr)
static void * pool_realloc (void *ctx_ptr, void *ptr, usize old_size, usize size)
bool yyjson_alc_pool_init (yyjson_alc *alc, void *buf, usize size)
static_inline bool dyn_size_align (usize *size)
static_inline void dyn_chunk_list_remove (dyn_chunk *list, dyn_chunk *chunk)
static_inline void dyn_chunk_list_add (dyn_chunk *list, dyn_chunk *chunk)
static void * dyn_malloc (void *ctx_ptr, usize size)
static void * dyn_realloc (void *ctx_ptr, void *ptr, usize old_size, usize size)
static void dyn_free (void *ctx_ptr, void *ptr)
yyjson_alcyyjson_alc_dyn_new (void)
void yyjson_alc_dyn_free (yyjson_alc *alc)
static_inline void unsafe_yyjson_str_pool_release (yyjson_str_pool *pool, yyjson_alc *alc)
static_inline void unsafe_yyjson_val_pool_release (yyjson_val_pool *pool, yyjson_alc *alc)
bool unsafe_yyjson_str_pool_grow (yyjson_str_pool *pool, const yyjson_alc *alc, usize len)
bool unsafe_yyjson_val_pool_grow (yyjson_val_pool *pool, const yyjson_alc *alc, usize count)
bool yyjson_mut_doc_set_str_pool_size (yyjson_mut_doc *doc, size_t len)
bool yyjson_mut_doc_set_val_pool_size (yyjson_mut_doc *doc, size_t count)
void yyjson_mut_doc_free (yyjson_mut_doc *doc)
yyjson_mut_docyyjson_mut_doc_new (const yyjson_alc *alc)
yyjson_mut_docyyjson_doc_mut_copy (const yyjson_doc *doc, const yyjson_alc *alc)
yyjson_mut_docyyjson_mut_doc_mut_copy (const yyjson_mut_doc *doc, const yyjson_alc *alc)
yyjson_mut_valyyjson_val_mut_copy (yyjson_mut_doc *m_doc, const yyjson_val *i_vals)
static yyjson_mut_valunsafe_yyjson_mut_val_mut_copy (yyjson_mut_doc *m_doc, const yyjson_mut_val *m_vals)
yyjson_mut_valyyjson_mut_val_mut_copy (yyjson_mut_doc *doc, const yyjson_mut_val *val)
static void yyjson_mut_stat (const yyjson_mut_val *val, usize *val_sum, usize *str_sum)
static usize yyjson_imut_copy (yyjson_val **val_ptr, char **buf_ptr, const yyjson_mut_val *mval)
yyjson_docyyjson_mut_doc_imut_copy (const yyjson_mut_doc *mdoc, const yyjson_alc *alc)
yyjson_docyyjson_mut_val_imut_copy (const yyjson_mut_val *mval, const yyjson_alc *alc)
static_inline bool unsafe_yyjson_num_equals (const void *lhs, const void *rhs)
static_inline bool unsafe_yyjson_str_equals (const void *lhs, const void *rhs)
bool unsafe_yyjson_equals (const yyjson_val *lhs, const yyjson_val *rhs)
bool unsafe_yyjson_mut_equals (const yyjson_mut_val *lhs, const yyjson_mut_val *rhs)
bool yyjson_locate_pos (const char *str, size_t len, size_t pos, size_t *line, size_t *col, size_t *chr)
static_inline bool has_rflag (yyjson_read_flag flg, yyjson_read_flag chk, bool non_standard)
static_inline bool read_true (u8 **ptr, yyjson_val *val)
static_inline bool read_false (u8 **ptr, yyjson_val *val)
static_inline bool read_null (u8 **ptr, yyjson_val *val)
static_inline bool read_inf (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val)
static_inline bool read_nan (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val)
static_inline bool read_inf_or_nan (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val)
static_noinline bool read_num_raw (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg)
static_noinline bool read_num_hex (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg)
static_noinline bool skip_trivia (u8 **ptr, u8 *eof, yyjson_read_flag flg)
static bool is_truncated_utf8 (u8 *cur, u8 *eof)
static bool is_truncated_str (u8 *cur, u8 *eof, const char *str, bool case_sensitive)
static_noinline bool is_truncated_end (u8 *hdr, u8 *cur, u8 *eof, yyjson_read_code code, yyjson_read_flag flg)
static_inline bool read_num (u8 **ptr, u8 **pre, yyjson_read_flag flg, yyjson_val *val, const char **msg)
static_inline bool read_uni_esc (u8 **src_ptr, u8 **dst_ptr, const char **msg)
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])
static_inline bool read_str (u8 **ptr, u8 *eof, yyjson_read_flag flg, yyjson_val *val, const char **msg)
static_inline bool read_str_con (u8 **ptr, u8 *eof, yyjson_read_flag flg, yyjson_val *val, const char **msg, u8 **con)
static_noinline bool read_str_sq (u8 **ptr, u8 *eof, yyjson_read_flag flg, yyjson_val *val, const char **msg)
static_noinline bool read_str_id (u8 **ptr, u8 *eof, yyjson_read_flag flg, u8 **pre, yyjson_val *val, const char **msg)
static_noinline yyjson_docread_root_single (u8 *hdr, u8 *cur, u8 *eof, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err)
static_inline yyjson_docread_root_minify (u8 *hdr, u8 *cur, u8 *eof, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err)
static_inline yyjson_docread_root_pretty (u8 *hdr, u8 *cur, u8 *eof, yyjson_alc alc, yyjson_read_flag flg, yyjson_read_err *err)
yyjson_docyyjson_read_opts (char *dat, usize len, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err)
yyjson_docyyjson_read_file (const char *path, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err)
yyjson_docyyjson_read_fp (FILE *file, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err)
const char * yyjson_read_number (const char *dat, yyjson_val *val, yyjson_read_flag flg, const yyjson_alc *alc, yyjson_read_err *err)
yyjson_incr_stateyyjson_incr_new (char *buf, size_t buf_len, yyjson_read_flag flg, const yyjson_alc *alc_ptr)
void yyjson_incr_free (yyjson_incr_state *state)
yyjson_docyyjson_incr_read (yyjson_incr_state *state, size_t len, yyjson_read_err *err)
static_inline bool has_wflag (yyjson_write_flag flg, yyjson_write_flag chk, bool non_standard)
 yyjson_align (2)
static_inline u8write_u32_len_8 (u32 val, u8 *buf)
static_inline u8write_u32_len_4 (u32 val, u8 *buf)
static_inline u8write_u32_len_1_to_8 (u32 val, u8 *buf)
static_inline u8write_u32_len_5_to_8 (u32 val, u8 *buf)
static_inline u8write_u64 (u64 val, u8 *buf)
static_noinline u8write_fp_reformat (u8 *buf, int len, yyjson_write_flag flg, bool fixed)
static_noinline u8write_f64_raw (u8 *buf, u64 raw, yyjson_write_flag flg)
static_noinline u8write_f32_raw (u8 *buf, u64 raw, yyjson_write_flag flg)
static_noinline u8write_f64_raw_fixed (u8 *buf, u64 raw, yyjson_write_flag flg, u32 prec)
static_inline u8write_num (u8 *cur, yyjson_val *val, yyjson_write_flag flg)
char * yyjson_write_number (const yyjson_val *val, char *buf)
static_inline const u8get_hex_table_with_flag (yyjson_write_flag flg)
static_inline const char_enc_typeget_enc_table_with_flag (yyjson_write_flag flg)
static_inline u8write_raw (u8 *cur, const u8 *raw, usize raw_len)
static_inline u8write_str_noesc (u8 *cur, const u8 *str, usize str_len)
static_inline u8write_str (u8 *cur, bool esc, bool inv, const u8 *str, usize str_len, const char_enc_type *enc_table, const u8 *hex_table)
static_inline u8write_null (u8 *cur)
static_inline u8write_bool (u8 *cur, bool val)
static_inline u8write_indent (u8 *cur, usize level, usize spaces)
static bool write_dat_to_fp (FILE *fp, u8 *dat, usize len, yyjson_write_err *err)
static bool write_dat_to_file (const char *path, u8 *dat, usize len, yyjson_write_err *err)
static_inline void yyjson_write_ctx_set (yyjson_write_ctx *ctx, usize size, bool is_obj)
static_inline void yyjson_write_ctx_get (yyjson_write_ctx *ctx, usize *size, bool *is_obj)
static_inline u8write_root_single (yyjson_val *val, yyjson_write_flag flg, yyjson_alc alc, char *buf, usize *dat_len, yyjson_write_err *err)
static_inline u8write_root_minify (const yyjson_val *root, const yyjson_write_flag flg, const yyjson_alc alc, char *buf, usize *dat_len, yyjson_write_err *err)
static_inline u8write_root_pretty (const yyjson_val *root, const yyjson_write_flag flg, const yyjson_alc alc, char *buf, usize *dat_len, yyjson_write_err *err)
static char * write_root (const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, char *buf, usize *dat_len, yyjson_write_err *err)
char * yyjson_val_write_opts (const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err)
char * yyjson_write_opts (const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err)
bool yyjson_val_write_file (const char *path, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_val_write_fp (FILE *fp, const yyjson_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_write_file (const char *path, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_write_fp (FILE *fp, const yyjson_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
size_t yyjson_val_write_buf (char *buf, size_t buf_len, const yyjson_val *val, yyjson_write_flag flg, yyjson_write_err *err)
size_t yyjson_write_buf (char *buf, size_t buf_len, const yyjson_doc *doc, yyjson_write_flag flg, yyjson_write_err *err)
static_inline void yyjson_mut_write_ctx_set (yyjson_mut_write_ctx *ctx, yyjson_mut_val *ctn, usize size, bool is_obj)
static_inline void yyjson_mut_write_ctx_get (yyjson_mut_write_ctx *ctx, yyjson_mut_val **ctn, usize *size, bool *is_obj)
static_inline usize yyjson_mut_doc_estimated_val_num (const yyjson_mut_doc *doc)
static_inline u8mut_write_root_single (yyjson_mut_val *val, yyjson_write_flag flg, yyjson_alc alc, char *buf, usize *dat_len, yyjson_write_err *err)
static_inline u8mut_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)
static_inline u8mut_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)
static char * mut_write_root (const yyjson_mut_val *val, usize estimated_val_num, yyjson_write_flag flg, const yyjson_alc *alc_ptr, char *buf, usize *dat_len, yyjson_write_err *err)
char * yyjson_mut_val_write_opts (const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err)
char * yyjson_mut_write_opts (const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, usize *dat_len, yyjson_write_err *err)
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)
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)
bool yyjson_mut_val_write_file (const char *path, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_mut_val_write_fp (FILE *fp, const yyjson_mut_val *val, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_mut_write_file (const char *path, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
bool yyjson_mut_write_fp (FILE *fp, const yyjson_mut_doc *doc, yyjson_write_flag flg, const yyjson_alc *alc_ptr, yyjson_write_err *err)
static_inline const char * ptr_next_token (const char **ptr, const char *end, usize *len, usize *esc)
static_inline bool ptr_token_to_idx (const char *cur, usize len, usize *idx)
static_inline bool ptr_token_eq (void *key, const char *token, usize len, usize esc)
static_inline yyjson_valptr_arr_get (const yyjson_val *arr, const char *token, usize len, usize esc)
static_inline yyjson_valptr_obj_get (const yyjson_val *obj, const char *token, usize len, usize esc)
static_inline yyjson_mut_valptr_mut_arr_get (const yyjson_mut_val *arr, const char *token, usize len, usize esc, yyjson_mut_val **pre, bool *last)
static_inline yyjson_mut_valptr_mut_obj_get (const yyjson_mut_val *obj, const char *token, usize len, usize esc, yyjson_mut_val **pre)
static_inline yyjson_mut_valptr_new_key (const char *token, usize len, usize esc, yyjson_mut_doc *doc)
yyjson_valunsafe_yyjson_ptr_getx (const yyjson_val *val, const char *ptr, size_t ptr_len, yyjson_ptr_err *err)
yyjson_mut_valunsafe_yyjson_mut_ptr_getx (const yyjson_mut_val *val, const char *ptr, size_t ptr_len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
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)
yyjson_mut_valunsafe_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)
yyjson_mut_valunsafe_yyjson_mut_ptr_removex (yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
static patch_op patch_op_get (yyjson_val *op)
yyjson_mut_valyyjson_patch (yyjson_mut_doc *doc, const yyjson_val *orig, const yyjson_val *patch, yyjson_patch_err *err)
yyjson_mut_valyyjson_mut_patch (yyjson_mut_doc *doc, const yyjson_mut_val *orig, const yyjson_mut_val *patch, yyjson_patch_err *err)
yyjson_mut_valyyjson_merge_patch (yyjson_mut_doc *doc, const yyjson_val *orig, const yyjson_val *patch)
yyjson_mut_valyyjson_mut_merge_patch (yyjson_mut_doc *doc, const yyjson_mut_val *orig, const yyjson_mut_val *patch)

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]

Macro Definition Documentation

◆ byte_move_dst

#define byte_move_dst ( x)
Value:
((char *)dst)[x] = ((const char *)tmp)[x];

Definition at line 567 of file yyjson.c.

Referenced by byte_move_16(), byte_move_2(), byte_move_4(), and byte_move_8().

◆ byte_move_idx

#define byte_move_idx ( x)
Value:
((char *)dst)[x] = ((const char *)src)[x];

Definition at line 565 of file yyjson.c.

Referenced by byte_copy_16(), byte_copy_2(), byte_copy_4(), and byte_copy_8().

◆ byte_move_src

#define byte_move_src ( x)
Value:
((char *)tmp)[x] = ((const char *)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().

◆ CHAR_ENC_CPY_1

#define CHAR_ENC_CPY_1   0 /* 1-byte UTF-8, copy. */

Definition at line 8475 of file yyjson.c.

Referenced by write_str().

◆ CHAR_ENC_CPY_2

#define CHAR_ENC_CPY_2   4 /* 2-byte UTF-8, copy. */

Definition at line 8479 of file yyjson.c.

Referenced by write_str().

◆ CHAR_ENC_CPY_3

#define CHAR_ENC_CPY_3   6 /* 3-byte UTF-8, copy. */

Definition at line 8481 of file yyjson.c.

Referenced by write_str().

◆ CHAR_ENC_CPY_4

#define CHAR_ENC_CPY_4   8 /* 4-byte UTF-8, copy. */

Definition at line 8483 of file yyjson.c.

Referenced by write_str().

◆ CHAR_ENC_ERR_1

#define CHAR_ENC_ERR_1   1 /* 1-byte UTF-8, error. */

Definition at line 8476 of file yyjson.c.

Referenced by write_str().

◆ CHAR_ENC_ESC_1

#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().

◆ CHAR_ENC_ESC_2

#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().

◆ CHAR_ENC_ESC_3

#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().

◆ CHAR_ENC_ESC_4

#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().

◆ CHAR_ENC_ESC_A

#define CHAR_ENC_ESC_A   2 /* 1-byte ASCII, escaped as '\x'. */

Definition at line 8477 of file yyjson.c.

Referenced by write_str().

◆ CHAR_TYPE_ASCII

#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().

◆ CHAR_TYPE_ASCII_SQ

#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().

◆ CHAR_TYPE_COMMENT

#define CHAR_TYPE_COMMENT   (1 << 5) /* Comment: [/] */

Definition at line 754 of file yyjson.c.

Referenced by char_is_trivia().

◆ CHAR_TYPE_DIGIT

#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().

◆ CHAR_TYPE_DOT

#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().

◆ CHAR_TYPE_EOL

#define CHAR_TYPE_EOL   (1 << 0) /* End of line: [\r\n] */

Definition at line 757 of file yyjson.c.

Referenced by char_is_eol().

◆ CHAR_TYPE_EOL_EXT

#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().

◆ CHAR_TYPE_EXP

#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().

◆ CHAR_TYPE_ID_ASCII

#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().

◆ CHAR_TYPE_ID_NEXT

#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().

◆ CHAR_TYPE_ID_START

#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().

◆ CHAR_TYPE_NONZERO

#define CHAR_TYPE_NONZERO   (1 << 2) /* [1-9] */

Definition at line 766 of file yyjson.c.

Referenced by char_is_nonzero().

◆ CHAR_TYPE_NUM

#define CHAR_TYPE_NUM   (1 << 4) /* Number: [.-+0-9] */

Definition at line 753 of file yyjson.c.

Referenced by char_is_num().

◆ CHAR_TYPE_SIGN

#define CHAR_TYPE_SIGN   (1 << 0) /* [-+] */

Definition at line 764 of file yyjson.c.

Referenced by char_is_sign().

◆ CHAR_TYPE_SPACE

#define CHAR_TYPE_SPACE   (1 << 2) /* Whitespace: [ \t\n\r] */

Definition at line 751 of file yyjson.c.

Referenced by char_is_space().

◆ CHAR_TYPE_SPACE_EXT

#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().

◆ check_maybe_truncated_number

#define check_maybe_truncated_number ( )
Value:
do { \
if (unlikely(cur >= end)) { \
if (unlikely(cur > state->cur + INCR_NUM_MAX_LEN)) { \
msg = "number too long"; \
goto fail_number; \
} \
goto unexpected_end; \
} \
} while (false)
#define INCR_NUM_MAX_LEN
Definition yyjson.c:522
#define unlikely(x)
Definition yyjson.c:369

Referenced by yyjson_incr_read().

◆ check_str_len [1/5]

#define check_str_len ( _len)
Value:
do { \
if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \
goto fail_alloc; \
} while (false)
size_t usize
Definition yyjson.c:541
#define USIZE_MAX
Definition yyjson.c:451

◆ check_str_len [2/5]

#define check_str_len ( _len)
Value:
do { \
if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \
goto fail_alloc; \
} while (false)

◆ check_str_len [3/5]

#define check_str_len ( _len)
Value:
do { \
if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \
goto fail_alloc; \
} while (false)

◆ check_str_len [4/5]

#define check_str_len ( _len)
Value:
do { \
if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \
goto fail_alloc; \
} while (false)

◆ check_str_len [5/5]

#define check_str_len ( _len)
Value:
do { \
if ((sizeof(usize) < 8) && (_len >= (USIZE_MAX - 16) / 6)) \
goto fail_alloc; \
} while (false)

Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().

◆ constcast

◆ expr_intg

#define expr_intg ( i)
Value:
if (likely((num = (u64)(cur[i] - (u8)'0')) <= 9)) sig = num + sig * 10; \
else { cur += i; goto intg_end; }
#define likely(x)
Definition yyjson.c:367
uint64_t u64
Definition yyjson.c:540
uint8_t u8
Definition yyjson.c:534

Referenced by read_num().

◆ expr_jump [1/9]

#define expr_jump ( i)
Value:
if (unlikely(enc_table[src[i]])) goto stop_char_##i;

◆ expr_jump [2/9]

#define expr_jump ( i)
Value:
copy_ascii_stop_##i: \
byte_move_forward(dst, src, i); \
dst += i; src += i; \
goto copy_utf8;

◆ expr_jump [3/9]

#define expr_jump ( i)
Value:
if (likely((char_is_id_ascii(src[i])))) {} \
else { gcc_store_barrier(src[i]); goto copy_ascii_stop_##i; }
#define gcc_store_barrier(val)
Definition yyjson.c:409
static_inline bool char_is_id_ascii(u8 c)
Definition yyjson.c:926

◆ expr_jump [4/9]

#define expr_jump ( i)
Value:
if (likely(char_is_id_ascii(src[i]))) {} \
else goto skip_ascii_stop##i;

◆ expr_jump [5/9]

#define expr_jump ( i)
Value:
copy_ascii_stop_##i: \
byte_move_forward(dst, src, i); \
dst += i; src += i; \
goto copy_utf8;

◆ expr_jump [6/9]

#define expr_jump ( i)
Value:
if (likely((char_is_ascii_skip_sq(src[i])))) {} \
else { gcc_store_barrier(src[i]); goto copy_ascii_stop_##i; }
static_inline bool char_is_ascii_skip_sq(u8 c)
Definition yyjson.c:896

◆ expr_jump [7/9]

#define expr_jump ( i)
Value:
if (likely((char_is_ascii_skip(src[i])))) {} \
else { gcc_store_barrier(src[i]); goto copy_ascii_stop_##i; }
static_inline bool char_is_ascii_skip(u8 c)
Definition yyjson.c:891

◆ expr_jump [8/9]

#define expr_jump ( i)
Value:
if (likely(char_is_ascii_skip_sq(src[i]))) {} \
else goto skip_ascii_stop_sq##i;

◆ expr_jump [9/9]

#define expr_jump ( i)
Value:
if (likely(char_is_ascii_skip(src[i]))) {} \
else goto skip_ascii_stop##i;

Referenced by read_str_id(), read_str_opt(), and write_str().

◆ expr_stop [1/4]

#define expr_stop ( i)
Value:
stop_char_##i: \
memcpy(cur, src, i); \
cur += i; src += i; goto copy_utf8;

◆ expr_stop [2/4]

#define expr_stop ( i)
Value:
skip_ascii_stop##i: \
src += i; \
goto skip_ascii_end;

◆ expr_stop [3/4]

#define expr_stop ( i)
Value:
skip_ascii_stop_sq##i: \
src += i; \
goto skip_ascii_end;

◆ expr_stop [4/4]

#define expr_stop ( i)
Value:
skip_ascii_stop##i: \
src += i; \
goto skip_ascii_end;

Referenced by read_str_id(), read_str_opt(), and write_str().

◆ F32_BITS

#define F32_BITS   32

Definition at line 487 of file yyjson.c.

◆ F32_DEC_DIG

#define F32_DEC_DIG   9

Definition at line 515 of file yyjson.c.

Referenced by write_f32_raw().

◆ F32_EXP_BIAS

#define F32_EXP_BIAS   127

Definition at line 511 of file yyjson.c.

◆ F32_EXP_BITS

#define F32_EXP_BITS   8

Definition at line 491 of file yyjson.c.

◆ F32_EXP_MASK

#define F32_EXP_MASK   U32(0x7F800000)

Definition at line 507 of file yyjson.c.

◆ F32_SIG_BITS

#define F32_SIG_BITS   23

Definition at line 495 of file yyjson.c.

◆ F32_SIG_FULL_BITS

#define F32_SIG_FULL_BITS   24

Definition at line 499 of file yyjson.c.

◆ F32_SIG_MASK

#define F32_SIG_MASK   U32(0x007FFFFF)

Definition at line 503 of file yyjson.c.

◆ F64_BITS

#define F64_BITS   64

Definition at line 488 of file yyjson.c.

◆ F64_BITS_INF

#define F64_BITS_INF   U64(0x7FF00000, 0x00000000)

Definition at line 462 of file yyjson.c.

Referenced by f64_bits_inf(), and f64_is_inf().

◆ F64_BITS_NAN

#define F64_BITS_NAN   U64(0x7FF80000, 0x00000000)

Definition at line 468 of file yyjson.c.

Referenced by f64_bits_nan().

◆ F64_DEC_DIG

#define F64_DEC_DIG   17

Definition at line 516 of file yyjson.c.

Referenced by write_f64_raw().

◆ F64_EXP_BIAS

#define F64_EXP_BIAS   1023

Definition at line 512 of file yyjson.c.

◆ F64_EXP_BITS

#define F64_EXP_BITS   11

Definition at line 492 of file yyjson.c.

◆ F64_EXP_MASK

#define F64_EXP_MASK   U64(0x7FF00000, 0x00000000)

Definition at line 508 of file yyjson.c.

Referenced by f64_is_inf().

◆ F64_MAX_BIN_EXP

#define F64_MAX_BIN_EXP   1024

Definition at line 481 of file yyjson.c.

◆ F64_MAX_DEC_DIG

#define F64_MAX_DEC_DIG   768

Definition at line 472 of file yyjson.c.

◆ F64_MAX_DEC_EXP

#define F64_MAX_DEC_EXP   308

Definition at line 475 of file yyjson.c.

◆ F64_MIN_BIN_EXP

#define F64_MIN_BIN_EXP   (-1021)

Definition at line 484 of file yyjson.c.

◆ F64_MIN_DEC_EXP

#define F64_MIN_DEC_EXP   (-324)

Definition at line 478 of file yyjson.c.

◆ F64_SIG_BITS

#define F64_SIG_BITS   52

Definition at line 496 of file yyjson.c.

◆ F64_SIG_FULL_BITS

#define F64_SIG_FULL_BITS   53

Definition at line 500 of file yyjson.c.

◆ F64_SIG_MASK

#define F64_SIG_MASK   U64(0x000FFFFF, 0xFFFFFFFF)

Definition at line 504 of file yyjson.c.

◆ FP_BUF_LEN

◆ gcc_full_barrier

#define gcc_full_barrier ( val)

Definition at line 410 of file yyjson.c.

◆ GCC_HAS_CLZLL

#define GCC_HAS_CLZLL   0

Definition at line 102 of file yyjson.c.

◆ GCC_HAS_CTZLL

#define GCC_HAS_CTZLL   0

Definition at line 108 of file yyjson.c.

◆ gcc_load_barrier

#define gcc_load_barrier ( val)

Definition at line 408 of file yyjson.c.

◆ gcc_store_barrier

#define gcc_store_barrier ( val)

Definition at line 409 of file yyjson.c.

Referenced by read_str_id(), and read_str_opt().

◆ has_allow [1/2]

#define has_allow ( _flg)
Value:
unlikely(has_wflag(flg, YYJSON_WRITE_ALLOW_##_flg, 1))
static_inline bool has_wflag(yyjson_write_flag flg, yyjson_write_flag chk, bool non_standard)
Definition yyjson.c:7175

Definition at line 3120 of file yyjson.c.

◆ has_allow [2/2]

#define has_allow ( _flg)

◆ has_flg [1/2]

#define has_flg ( _flg)
Value:
unlikely(has_wflag(flg, YYJSON_WRITE_##_flg, 0))

Definition at line 3119 of file yyjson.c.

◆ has_flg [2/2]

◆ I64_MAX

#define I64_MAX   U64(0x7FFFFFFF, 0xFFFFFFFF)

Definition at line 449 of file yyjson.c.

◆ incr_len [1/5]

#define incr_len ( _len)
Value:
do { \
ext_len = (usize)(_len); \
if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \
usize ctx_pos = (usize)((u8 *)ctx - hdr); \
usize cur_pos = (usize)(cur - hdr); \
yyjson_assume((u8 *)ctx <= (u8 *)end); \
ctx_len = (usize)((u8 *)end - (u8 *)ctx); \
alc_inc = yyjson_max(alc_len / 2, ext_len); \
alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \
if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \
goto fail_alloc; \
alc_len += alc_inc; \
tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \
if (unlikely(!tmp)) goto fail_alloc; \
ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \
memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \
ctx = ctx_tmp; \
cur = tmp + cur_pos; \
end = tmp + alc_len; \
hdr = tmp; \
} \
} while (false)
#define yyjson_max(x, y)
Definition yyjson.c:381
static_inline bool size_add_is_overflow(usize size, usize add)
Definition yyjson.c:2146
static_inline usize size_align_up(usize size, usize align)
Definition yyjson.c:2156

◆ incr_len [2/5]

#define incr_len ( _len)
Value:
do { \
ext_len = (usize)(_len); \
if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \
usize ctx_pos = (usize)((u8 *)ctx - hdr); \
usize cur_pos = (usize)(cur - hdr); \
yyjson_assume((u8 *)ctx <= (u8 *)end); \
ctx_len = (usize)((u8 *)end - (u8 *)ctx); \
alc_inc = yyjson_max(alc_len / 2, ext_len); \
alc_inc = size_align_up(alc_inc, sizeof(yyjson_mut_write_ctx)); \
if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \
goto fail_alloc; \
alc_len += alc_inc; \
tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \
if (unlikely(!tmp)) goto fail_alloc; \
ctx_tmp = (yyjson_mut_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \
memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \
ctx = ctx_tmp; \
cur = tmp + cur_pos; \
end = tmp + alc_len; \
hdr = tmp; \
} \
} while (false)

◆ incr_len [3/5]

#define incr_len ( _len)
Value:
do { \
ext_len = (usize)(_len); \
if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \
usize ctx_pos = (usize)((u8 *)ctx - hdr); \
usize cur_pos = (usize)(cur - hdr); \
yyjson_assume((u8 *)ctx <= (u8 *)end); \
ctx_len = (usize)((u8 *)end - (u8 *)ctx); \
alc_inc = yyjson_max(alc_len / 2, ext_len); \
alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \
if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \
goto fail_alloc; \
alc_len += alc_inc; \
tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \
if (unlikely(!tmp)) goto fail_alloc; \
ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \
memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \
ctx = ctx_tmp; \
cur = tmp + cur_pos; \
end = tmp + alc_len; \
hdr = tmp; \
} \
} while (false)

◆ incr_len [4/5]

#define incr_len ( _len)
Value:
do { \
ext_len = (usize)(_len); \
if (unlikely((u8 *)(cur + ext_len) >= (u8 *)ctx)) { \
usize ctx_pos = (usize)((u8 *)ctx - hdr); \
usize cur_pos = (usize)(cur - hdr); \
yyjson_assume((u8 *)ctx <= (u8 *)end); \
ctx_len = (usize)((u8 *)end - (u8 *)ctx); \
alc_inc = yyjson_max(alc_len / 2, ext_len); \
alc_inc = size_align_up(alc_inc, sizeof(yyjson_write_ctx)); \
if ((sizeof(usize) < 8) && size_add_is_overflow(alc_len, alc_inc)) \
goto fail_alloc; \
alc_len += alc_inc; \
tmp = (u8 *)alc.realloc(alc.ctx, hdr, alc_len - alc_inc, alc_len); \
if (unlikely(!tmp)) goto fail_alloc; \
ctx_tmp = (yyjson_write_ctx *)(void *)(tmp + (alc_len - ctx_len)); \
memmove((void *)ctx_tmp, (void *)(tmp + ctx_pos), ctx_len); \
ctx = ctx_tmp; \
cur = tmp + cur_pos; \
end = tmp + alc_len; \
hdr = tmp; \
} \
} while (false)

◆ incr_len [5/5]

#define incr_len ( _len)
Value:
do { \
if (buf) hdr = *dat_len >= _len ? (u8 *)buf : (u8 *)NULL; \
else hdr = (u8 *)alc.malloc(alc.ctx, _len); \
if (!hdr) goto fail_alloc; \
cur = hdr; \
} while (false)

Referenced by mut_write_root_minify(), mut_write_root_pretty(), write_root_minify(), write_root_pretty(), and write_root_single().

◆ INCR_NUM_MAX_LEN

#define INCR_NUM_MAX_LEN   1024

Definition at line 522 of file yyjson.c.

◆ INFINITY

#define INFINITY   ((double)(1.0 / 0.0))

Definition at line 148 of file yyjson.c.

Referenced by f64_bits_inf(), and f64_is_inf().

◆ is_utf8_seq1

#define is_utf8_seq1 ( uni)
Value:
( \
((uni & utf8_seq(b1_mask)) == utf8_seq(b1_patt)) )
#define utf8_seq(name)
Definition yyjson.c:1108

Referenced by read_str_opt().

◆ is_utf8_seq2

#define is_utf8_seq2 ( uni)
Value:
( \
((uni & utf8_seq(b2_mask)) == utf8_seq(b2_patt)) && \
((uni & utf8_seq(b2_requ))) )

Referenced by read_str_id(), read_str_opt(), and write_str().

◆ is_utf8_seq3

#define is_utf8_seq3 ( uni)
Value:
( \
((uni & utf8_seq(b3_mask)) == utf8_seq(b3_patt)) && \
((tmp = (uni & utf8_seq(b3_requ)))) && \
((tmp != utf8_seq(b3_erro))) )

Referenced by read_str_id(), read_str_opt(), and write_str().

◆ is_utf8_seq4

#define is_utf8_seq4 ( uni)
Value:
( \
((uni & utf8_seq(b4_mask)) == utf8_seq(b4_patt)) && \
((tmp = (uni & utf8_seq(b4_requ)))) && \
((tmp & utf8_seq(b4_req1)) == 0 || (tmp & utf8_seq(b4_req2)) == 0) )

Referenced by read_str_id(), read_str_opt(), and write_str().

◆ LABEL_arr_val_begin

#define LABEL_arr_val_begin   1

Definition at line 6547 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_arr_val_end

#define LABEL_arr_val_end   2

Definition at line 6548 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_doc_begin

#define LABEL_doc_begin   0

Definition at line 6546 of file yyjson.c.

Referenced by yyjson_incr_new(), and yyjson_incr_read().

◆ LABEL_doc_end

#define LABEL_doc_end   7

Definition at line 6553 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_obj_key_begin

#define LABEL_obj_key_begin   3

Definition at line 6549 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_obj_key_end

#define LABEL_obj_key_end   4

Definition at line 6550 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_obj_val_begin

#define LABEL_obj_val_begin   5

Definition at line 6551 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ LABEL_obj_val_end

#define LABEL_obj_val_end   6

Definition at line 6552 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ likely

◆ MSC_HAS_BIT_SCAN

#define MSC_HAS_BIT_SCAN   0

Definition at line 94 of file yyjson.c.

◆ MSC_HAS_BIT_SCAN_64

#define MSC_HAS_BIT_SCAN_64   0

Definition at line 93 of file yyjson.c.

◆ MSC_HAS_UMUL128

#define MSC_HAS_UMUL128   0

Definition at line 95 of file yyjson.c.

◆ MSG_ARR_END

#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().

◆ MSG_CHAR

#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().

◆ MSG_CHAR_F

#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().

◆ MSG_CHAR_N

#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().

◆ MSG_CHAR_T

#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().

◆ MSG_COMMA

#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().

◆ MSG_COMMENT

#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().

◆ MSG_DEPTH

#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().

◆ MSG_ERR_BOM

#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().

◆ MSG_ERR_TYPE

#define MSG_ERR_TYPE   "invalid JSON value type"

◆ MSG_ERR_UTF16

#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().

◆ MSG_ERR_UTF32

#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().

◆ MSG_ERR_UTF8

#define MSG_ERR_UTF8   "invalid utf-8 encoding in string"

◆ MSG_FCLOSE

#define MSG_FCLOSE   "failed to close file"

Definition at line 423 of file yyjson.c.

Referenced by write_dat_to_file().

◆ MSG_FOPEN

#define MSG_FOPEN   "failed to open file"

Definition at line 420 of file yyjson.c.

Referenced by write_dat_to_file().

◆ MSG_FREAD

#define MSG_FREAD   "failed to read file"

Definition at line 421 of file yyjson.c.

Referenced by yyjson_read_file(), and yyjson_read_fp().

◆ MSG_FWRITE

#define MSG_FWRITE   "failed to write file"

Definition at line 422 of file yyjson.c.

Referenced by write_dat_to_file().

◆ MSG_GARBAGE

#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().

◆ MSG_MALLOC

◆ MSG_NAN_INF

#define MSG_NAN_INF   "nan or inf number is not allowed"

◆ MSG_NOT_END

#define MSG_NOT_END   "unexpected end of data"

Definition at line 434 of file yyjson.c.

Referenced by yyjson_incr_read().

◆ MSG_OBJ_END

#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().

◆ MSG_OBJ_KEY

#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().

◆ MSG_OBJ_SEP

#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().

◆ NAN

#define NAN   ((double)(0.0 / 0.0))

Definition at line 154 of file yyjson.c.

Referenced by f64_bits_nan().

◆ ptr_add

#define ptr_add ( _ptr,
_val )
Value:
root, _ptr->uni.str, _ptr##_len, _val, doc, false, NULL, &err->ptr)
yyjson_api_inline bool yyjson_mut_ptr_addx(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_mut_val *new_val, yyjson_mut_doc *doc, bool create_parent, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
Definition yyjson.h:7842

Definition at line 11019 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ ptr_get

#define ptr_get ( _ptr)
Value:
root, _ptr->uni.str, _ptr##_len, NULL, &err->ptr)
yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_getx(const yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
Definition yyjson.h:7744

Definition at line 11017 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ ptr_remove

#define ptr_remove ( _ptr)
Value:
root, _ptr->uni.str, _ptr##_len, NULL, &err->ptr)
yyjson_api_inline yyjson_mut_val * yyjson_mut_ptr_removex(yyjson_mut_val *val, const char *ptr, size_t len, yyjson_ptr_ctx *ctx, yyjson_ptr_err *err)
Definition yyjson.h:8103

Definition at line 11021 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ ptr_replace

#define ptr_replace ( _ptr,
_val )
Value:
root, _ptr->uni.str, _ptr##_len, _val, NULL, &err->ptr)
yyjson_api_inline yyjson_mut_val * 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 yyjson.h:8030

Definition at line 11023 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ repeat16

#define repeat16 ( x)
Value:
{ x x x x x x x x x x x x x x x x }

Definition at line 354 of file yyjson.c.

Referenced by read_root_pretty().

◆ repeat16_incr

#define repeat16_incr ( x)
Value:
{ x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) \
x(8) x(9) x(10) x(11) x(12) x(13) x(14) x(15) }

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().

◆ repeat2

#define repeat2 ( x)
Value:
{ x x }

Definition at line 351 of file yyjson.c.

◆ repeat2_incr

#define repeat2_incr ( x)
Value:
{ x(0) x(1) }

Definition at line 356 of file yyjson.c.

Referenced by byte_copy_2(), and byte_move_2().

◆ repeat4

#define repeat4 ( x)
Value:
{ x x x x }

Definition at line 352 of file yyjson.c.

Referenced by read_str_opt().

◆ repeat4_incr

#define repeat4_incr ( x)
Value:
{ x(0) x(1) x(2) x(3) }

Definition at line 357 of file yyjson.c.

Referenced by byte_copy_4(), byte_move_4(), and write_str().

◆ repeat8

#define repeat8 ( x)
Value:
{ x x x x x x x x }

Definition at line 353 of file yyjson.c.

Referenced by read_str_opt().

◆ repeat8_incr

#define repeat8_incr ( x)
Value:
{ x(0) x(1) x(2) x(3) x(4) x(5) x(6) x(7) }

Definition at line 358 of file yyjson.c.

Referenced by byte_copy_8(), and byte_move_8().

◆ repeat_in_1_18

#define repeat_in_1_18 ( x)
Value:
{ x(1) x(2) x(3) x(4) x(5) x(6) x(7) x(8) \
x(9) x(10) x(11) x(12) x(13) x(14) x(15) x(16) \
x(17) x(18) }

Definition at line 361 of file yyjson.c.

Referenced by read_num().

◆ return_0

#define return_0 ( )
Value:
do { \
val->tag = YYJSON_TYPE_NUM | (u64)((u8)sign << 3); \
val->uni.u64 = 0; \
*end = cur; return true; \
} while (false)
#define YYJSON_TYPE_NUM
Definition yyjson.h:605

Referenced by read_num().

◆ return_err [1/21]

#define return_err ( _code,
_msg )
Value:
do { \
if (err->ptr.code == YYJSON_PTR_ERR_MEMORY_ALLOCATION) { \
err->msg = _msg; \
memset(&err->ptr, 0, sizeof(yyjson_ptr_err)); \
} else { \
err->code = YYJSON_PATCH_ERROR_##_code; \
err->msg = _msg; \
err->idx = iter.idx ? iter.idx - 1 : 0; \
} \
return NULL; \
} while (false)
static const yyjson_ptr_code YYJSON_PTR_ERR_MEMORY_ALLOCATION
Definition yyjson.h:4295
static const yyjson_patch_code YYJSON_PATCH_ERROR_MEMORY_ALLOCATION
Definition yyjson.h:4865

Definition at line 10698 of file yyjson.c.

◆ return_err [2/21]

#define return_err ( _code,
_msg )
Value:
do { \
*dat_len = 0; \
err->code = YYJSON_WRITE_ERROR_##_code; \
err->msg = _msg; \
if (hdr) alc.free(alc.ctx, hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [3/21]

#define return_err ( _code,
_msg )
Value:
do { \
*dat_len = 0; \
err->code = YYJSON_WRITE_ERROR_##_code; \
err->msg = _msg; \
if (hdr) alc.free(alc.ctx, hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [4/21]

#define return_err ( _code,
_msg )
Value:
do { \
*dat_len = 0; \
err->code = YYJSON_WRITE_ERROR_##_code; \
err->msg = _msg; \
if (hdr) alc.free(alc.ctx, hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [5/21]

#define return_err ( _code,
_msg )
Value:
do { \
*dat_len = 0; \
err->code = YYJSON_WRITE_ERROR_##_code; \
err->msg = _msg; \
if (hdr) alc.free(alc.ctx, hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [6/21]

#define return_err ( _code,
_msg )
Value:
do { \
if (hdr) alc.free(alc.ctx, (void *)hdr); \
*dat_len = 0; \
err->code = YYJSON_WRITE_ERROR_##_code; \
err->msg = _msg; \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [7/21]

#define return_err ( _code,
_msg )
Value:
do { \
err->msg = _msg; \
err->code = YYJSON_WRITE_ERROR_##_code; \
if (file) fclose(file); \
return false; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [8/21]

#define return_err ( _code,
_msg )
Value:
do { \
err->pos = 0; \
err->msg = _msg; \
err->code = YYJSON_READ_ERROR_##_code; \
if (buf) alc.free(alc.ctx, buf); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [9/21]

#define return_err ( _code,
_msg )
Value:
do { \
err->pos = 0; \
err->msg = _msg; \
err->code = YYJSON_READ_ERROR_##_code; \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [10/21]

#define return_err ( _end,
_msg )
Value:
do { \
*msg = _msg; \
*end = _end; \
return false; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [11/21]

#define return_err ( _end,
_msg )
Value:
do { \
*msg = _msg; \
*end = _end; \
if (con) { con[0] = _end; con[1] = dst; } \
return false; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [12/21]

#define return_err ( _end,
_msg )
Value:
*msg = _msg; *src_ptr = _end; return false

Definition at line 10698 of file yyjson.c.

◆ return_err [13/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
if (is_truncated_end(hdr, _pos, end, YYJSON_READ_ERROR_##_code, flg)) { \
goto unexpected_end; \
} else { \
err->pos = (usize)(_pos - hdr); \
err->code = YYJSON_READ_ERROR_##_code; \
err->msg = _msg; \
} \
return NULL; \
} while (false)
static_noinline bool is_truncated_end(u8 *hdr, u8 *cur, u8 *eof, yyjson_read_code code, yyjson_read_flag flg)
Definition yyjson.c:3501

Definition at line 10698 of file yyjson.c.

◆ return_err [14/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
err->pos = _pos > hdr ? (usize)(_pos - hdr) : 0; \
err->msg = _msg; \
err->code = YYJSON_READ_ERROR_##_code; \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [15/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
err->pos = (usize)(_pos); \
err->msg = _msg; \
err->code = YYJSON_READ_ERROR_##_code; \
if (!has_flg(INSITU) && hdr) alc.free(alc.ctx, (void *)hdr); \
return NULL; \
} while (false)
#define has_flg(_flg)
Definition yyjson.c:3119

Definition at line 10698 of file yyjson.c.

◆ return_err [16/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
if (is_truncated_end(hdr, _pos, eof, YYJSON_READ_ERROR_##_code, flg)) { \
err->pos = (usize)(eof - hdr); \
err->msg = MSG_NOT_END; \
} else { \
err->pos = (usize)(_pos - hdr); \
err->code = YYJSON_READ_ERROR_##_code; \
err->msg = _msg; \
} \
if (val_hdr) alc.free(alc.ctx, val_hdr); \
return NULL; \
} while (false)
#define MSG_NOT_END
Definition yyjson.c:434
static const yyjson_read_code YYJSON_READ_ERROR_UNEXPECTED_END
Definition yyjson.h:925

Definition at line 10698 of file yyjson.c.

◆ return_err [17/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
if (is_truncated_end(hdr, _pos, eof, YYJSON_READ_ERROR_##_code, flg)) { \
err->pos = (usize)(eof - hdr); \
err->msg = MSG_NOT_END; \
} else { \
err->pos = (usize)(_pos - hdr); \
err->code = YYJSON_READ_ERROR_##_code; \
err->msg = _msg; \
} \
if (val_hdr) alc.free(alc.ctx, val_hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [18/21]

#define return_err ( _pos,
_code,
_msg )
Value:
do { \
if (is_truncated_end(hdr, _pos, eof, YYJSON_READ_ERROR_##_code, flg)) { \
err->pos = (usize)(eof - hdr); \
err->msg = MSG_NOT_END; \
} else { \
err->pos = (usize)(_pos - hdr); \
err->code = YYJSON_READ_ERROR_##_code; \
err->msg = _msg; \
} \
if (val_hdr) alc.free(alc.ctx, val_hdr); \
return NULL; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [19/21]

#define return_err ( _pos,
_msg )
Value:
do { \
*msg = _msg; \
*end = _pos; \
return false; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err [20/21]

◆ return_err [21/21]

#define return_err ( _ret,
_code,
_pos,
_msg )
Value:
do { \
if (err) { \
err->code = YYJSON_PTR_ERR_##_code; \
err->msg = _msg; \
err->pos = (usize)(_pos); \
} \
return _ret; \
} while (false)

Definition at line 10698 of file yyjson.c.

◆ return_err_alloc

#define return_err_alloc ( _ret)
Value:
return_err(_ret, MEMORY_ALLOCATION, 0, "failed to create value")
#define return_err(_pos, _msg)
Definition yyjson.c:10698

Definition at line 10711 of file yyjson.c.

Referenced by unsafe_yyjson_mut_ptr_putx().

◆ return_err_copy

#define return_err_copy ( )
Value:
return_err(MEMORY_ALLOCATION, "failed to copy value")

Definition at line 11010 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ return_err_inv_param

#define return_err_inv_param ( _msg)
Value:
do { \
err->pos = 0; \
err->msg = _msg; \
return NULL; \
} while (false)
static const yyjson_read_code YYJSON_READ_ERROR_INVALID_PARAMETER
Definition yyjson.h:913

Referenced by yyjson_incr_read().

◆ return_err_key

#define return_err_key ( _key)
Value:
return_err(MISSING_KEY, "missing key " _key)

Definition at line 11012 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ return_err_resolve

#define return_err_resolve ( _ret,
_pos )
Value:
return_err(_ret, RESOLVE, _pos, "JSON pointer cannot be resolved")

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().

◆ return_err_syntax

#define return_err_syntax ( _ret,
_pos )
Value:
return_err(_ret, SYNTAX, _pos, "invalid escaped character")

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().

◆ return_err_val

#define return_err_val ( _key)
Value:
return_err(INVALID_MEMBER, "invalid member " _key)

Definition at line 11014 of file yyjson.c.

Referenced by yyjson_mut_patch(), and yyjson_patch().

◆ return_f64

#define return_f64 ( _v)
Value:
do { \
val->uni.f64 = sign ? -(f64)(_v) : (f64)(_v); \
*end = cur; return true; \
} while (false)
double f64
Definition yyjson.c:532
#define YYJSON_SUBTYPE_REAL
Definition yyjson.h:626

Referenced by read_num().

◆ return_f64_bin

#define return_f64_bin ( _v)
Value:
do { \
val->uni.u64 = ((u64)sign << 63) | (u64)(_v); \
*end = cur; return true; \
} while (false)

◆ return_i64

#define return_i64 ( _v)
Value:
do { \
val->tag = YYJSON_TYPE_NUM | (u64)((u8)sign << 3); \
val->uni.u64 = (u64)(sign ? (u64)(~(_v) + 1) : (u64)(_v)); \
*end = cur; return true; \
} while (false)

Referenced by read_num().

◆ return_inf

#define return_inf ( )
Value:
do { \
if (has_flg(BIGNUM_AS_RAW)) return_raw(); \
if (has_allow(INF_AND_NAN)) return_f64_bin(F64_BITS_INF); \
else return_err(hdr, "number is infinity when parsed as double"); \
} while (false)
#define has_allow(_flg)
Definition yyjson.c:3120
#define return_raw()
#define F64_BITS_INF
Definition yyjson.c:462
#define return_f64_bin(_v)

Referenced by read_num().

◆ return_raw [1/2]

#define return_raw ( )
Value:
do { \
val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \
val->uni.str = (const char *)hdr; \
**pre = '\0'; *pre = cur; *end = cur; return true; \
} while (false)
#define YYJSON_TAG_BIT
Definition yyjson.h:645
#define YYJSON_TYPE_RAW
Definition yyjson.h:599

◆ return_raw [2/2]

#define return_raw ( )
Value:
do { \
val->tag = ((u64)(cur - hdr) << YYJSON_TAG_BIT) | YYJSON_TYPE_RAW; \
val->uni.str = (const char *)hdr; \
**pre = '\0'; *pre = cur; *end = cur; return true; \
} while (false)

Referenced by read_num(), and read_num_raw().

◆ return_suc

#define return_suc ( _str_end,
_cur_end )
Value:
do { \
val->tag = ((u64)(_str_end - hdr) << YYJSON_TAG_BIT) | \
val->uni.str = (const char *)hdr; \
*pre = _str_end; *end = _cur_end; \
return true; \
} while (false)
#define YYJSON_TYPE_STR
Definition yyjson.h:607

Referenced by read_str_id().

◆ save_incr_state

#define save_incr_state ( _label)
Value:
do { \
state->label = LABEL_##_label; \
state->cur = cur; \
state->val = val; \
state->ctn_len = ctn_len; \
state->hdr_len = hdr_len; \
state->raw_ptr = raw_ptr; \
if (unlikely(cur >= end)) goto unexpected_end; \
} while (false)

Referenced by yyjson_incr_read().

◆ snprintf_num

#define snprintf_num ( buf,
len,
fmt,
dig,
val )
Value:
sprintf((char *)buf, fmt, dig, val)

Definition at line 8283 of file yyjson.c.

Referenced by write_f32_raw(), write_f64_raw(), and write_f64_raw_fixed().

◆ static_inline

#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().

◆ static_noinline

◆ U32

#define U32 ( hi)
Value:
((u32)(hi##UL))
uint32_t u32
Definition yyjson.c:538

Definition at line 387 of file yyjson.c.

◆ U32_SAFE_DIG

#define U32_SAFE_DIG   9 /* u32 max is 4294967295, 10 digits */

Definition at line 455 of file yyjson.c.

◆ U64

#define U64 ( hi,
lo )
Value:
((((u64)hi##UL) << 32U) + lo##UL)

Definition at line 385 of file yyjson.c.

Referenced by u64_lz_bits(), and u64_tz_bits().

◆ U64_MAX

#define U64_MAX   U64(0xFFFFFFFF, 0xFFFFFFFF)

Definition at line 447 of file yyjson.c.

Referenced by read_num().

◆ U64_SAFE_DIG

#define U64_SAFE_DIG   19 /* u64 max is 18446744073709551615, 20 digits */

Definition at line 457 of file yyjson.c.

◆ unlikely

◆ USIZE_MAX

◆ USIZE_SAFE_DIG

#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().

◆ utf8_seq

#define utf8_seq ( name)
Value:
utf8_uni_##name.u

Definition at line 1108 of file yyjson.c.

Referenced by read_str_opt().

◆ utf8_seq_def

#define utf8_seq_def ( name,
a,
b,
c,
d )
Value:
static const v32_uni utf8_uni_##name = {{ 0x##a, 0x##b, 0x##c, 0x##d }};

Definition at line 1106 of file yyjson.c.

Referenced by utf8_seq_def().

◆ val_incr [1/3]

#define val_incr ( )
Value:
do { \
val++; \
if (unlikely(val >= val_end)) { \
usize alc_old = alc_len; \
alc_len += alc_len / 2; \
if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \
val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \
alc_old * sizeof(yyjson_val), \
alc_len * sizeof(yyjson_val)); \
if ((!val_tmp)) goto fail_alloc; \
val = val_tmp + (usize)(val - val_hdr); \
ctn = val_tmp + (usize)(ctn - val_hdr); \
state->val = val_tmp + (usize)(state->val - val_hdr); \
state->val_hdr = val_hdr = val_tmp; \
val_end = val_tmp + (alc_len - 2); \
state->val_end = val_end; \
} \
} while (false)

◆ val_incr [2/3]

#define val_incr ( )
Value:
do { \
val++; \
if (unlikely(val >= val_end)) { \
usize alc_old = alc_len; \
usize val_ofs = (usize)(val - val_hdr); \
usize ctn_ofs = (usize)(ctn - val_hdr); \
alc_len += alc_len / 2; \
if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \
val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \
alc_old * sizeof(yyjson_val), \
alc_len * sizeof(yyjson_val)); \
if ((!val_tmp)) goto fail_alloc; \
val = val_tmp + val_ofs; \
ctn = val_tmp + ctn_ofs; \
val_hdr = val_tmp; \
val_end = val_tmp + (alc_len - 2); \
} \
} while (false)

◆ val_incr [3/3]

#define val_incr ( )
Value:
do { \
val++; \
if (unlikely(val >= val_end)) { \
usize alc_old = alc_len; \
usize val_ofs = (usize)(val - val_hdr); \
usize ctn_ofs = (usize)(ctn - val_hdr); \
alc_len += alc_len / 2; \
if ((sizeof(usize) < 8) && (alc_len >= alc_max)) goto fail_alloc; \
val_tmp = (yyjson_val *)alc.realloc(alc.ctx, (void *)val_hdr, \
alc_old * sizeof(yyjson_val), \
alc_len * sizeof(yyjson_val)); \
if ((!val_tmp)) goto fail_alloc; \
val = val_tmp + val_ofs; \
ctn = val_tmp + ctn_ofs; \
val_hdr = val_tmp; \
val_end = val_tmp + (alc_len - 2); \
} \
} while (false)

Referenced by read_root_minify(), read_root_pretty(), and yyjson_incr_read().

◆ YYJSON_ALC_DYN_MIN_SIZE

#define YYJSON_ALC_DYN_MIN_SIZE   0x1000

Definition at line 338 of file yyjson.c.

Referenced by dyn_size_align().

◆ YYJSON_BIG_ENDIAN

#define YYJSON_BIG_ENDIAN   4321

Definition at line 216 of file yyjson.c.

◆ YYJSON_DISABLE_FAST_FP_CONV

#define YYJSON_DISABLE_FAST_FP_CONV   1

Definition at line 137 of file yyjson.c.

◆ YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS

#define YYJSON_DISABLE_UNALIGNED_MEMORY_ACCESS   0

Definition at line 306 of file yyjson.c.

◆ YYJSON_DOUBLE_MATH_CORRECT

#define YYJSON_DOUBLE_MATH_CORRECT   1

Definition at line 208 of file yyjson.c.

◆ YYJSON_ENDIAN

#define YYJSON_ENDIAN   0 /* unknown endian, detect at run-time */

Definition at line 269 of file yyjson.c.

◆ YYJSON_FOPEN_E

#define YYJSON_FOPEN_E

Definition at line 2102 of file yyjson.c.

Referenced by fopen_readonly(), and fopen_writeonly().

◆ YYJSON_HAS_IEEE_754

#define YYJSON_HAS_IEEE_754   0

Definition at line 135 of file yyjson.c.

◆ YYJSON_HAS_INT128

#define YYJSON_HAS_INT128   0

Definition at line 118 of file yyjson.c.

◆ YYJSON_LITTLE_ENDIAN

#define YYJSON_LITTLE_ENDIAN   1234

Definition at line 217 of file yyjson.c.

◆ yyjson_max

#define yyjson_max ( x,
y )
Value:
((x) > (y) ? (x) : (y))

Definition at line 381 of file yyjson.c.

Referenced by unsafe_yyjson_str_pool_grow(), and unsafe_yyjson_val_pool_grow().

◆ yyjson_min

#define yyjson_min ( x,
y )
Value:
((x) < (y) ? (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().

◆ YYJSON_MUT_DOC_STR_POOL_INIT_SIZE

#define YYJSON_MUT_DOC_STR_POOL_INIT_SIZE   0x100

Definition at line 332 of file yyjson.c.

Referenced by yyjson_mut_doc_new().

◆ YYJSON_MUT_DOC_STR_POOL_MAX_SIZE

#define YYJSON_MUT_DOC_STR_POOL_MAX_SIZE   0x10000000

Definition at line 333 of file yyjson.c.

Referenced by yyjson_mut_doc_new().

◆ YYJSON_MUT_DOC_VAL_POOL_INIT_SIZE

#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().

◆ YYJSON_MUT_DOC_VAL_POOL_MAX_SIZE

#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().

◆ YYJSON_READ_ALLOW_TRIVIA

#define YYJSON_READ_ALLOW_TRIVIA
Value:
static const yyjson_read_flag YYJSON_READ_ALLOW_EXT_WHITESPACE
Definition yyjson.h:879
static const yyjson_read_flag YYJSON_READ_ALLOW_COMMENTS
Definition yyjson.h:829

Definition at line 3121 of file yyjson.c.

◆ YYJSON_READER_ESTIMATED_MINIFY_RATIO

#define YYJSON_READER_ESTIMATED_MINIFY_RATIO   6

Definition at line 327 of file yyjson.c.

Referenced by read_root_minify(), and yyjson_incr_read().

◆ YYJSON_READER_ESTIMATED_PRETTY_RATIO

#define YYJSON_READER_ESTIMATED_PRETTY_RATIO   16

Definition at line 326 of file yyjson.c.

Referenced by read_root_pretty().

◆ YYJSON_WRITER_ESTIMATED_MINIFY_RATIO

#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().

◆ YYJSON_WRITER_ESTIMATED_PRETTY_RATIO

#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 Documentation

◆ char_enc_type

typedef u8 char_enc_type

Character encode type, if (type > CHAR_ENC_ERR_1) bytes = type / 2;

Definition at line 8474 of file yyjson.c.

◆ dyn_chunk

typedef struct dyn_chunk dyn_chunk

memory chunk header

◆ f32

typedef float f32

Type aliases for primitive types.

Definition at line 531 of file yyjson.c.

◆ f64

typedef double f64

Definition at line 532 of file yyjson.c.

◆ i16

typedef int16_t i16

Definition at line 535 of file yyjson.c.

◆ i32

typedef int32_t i32

Definition at line 537 of file yyjson.c.

◆ i64

typedef int64_t i64

Definition at line 539 of file yyjson.c.

◆ i8

typedef int8_t i8

Definition at line 533 of file yyjson.c.

◆ patch_op

typedef enum patch_op patch_op

◆ pool_chunk

typedef struct pool_chunk pool_chunk

memory chunk header

◆ pool_ctx

typedef struct pool_ctx pool_ctx

allocator ctx header

◆ u16

typedef uint16_t u16

Definition at line 536 of file yyjson.c.

◆ u32

typedef uint32_t u32

Definition at line 538 of file yyjson.c.

◆ u64

typedef uint64_t u64

Definition at line 540 of file yyjson.c.

◆ u8

typedef uint8_t u8

Definition at line 534 of file yyjson.c.

◆ usize

typedef size_t usize

Definition at line 541 of file yyjson.c.

◆ v16

typedef struct v16 v16

128-bit integer, used by floating-point number reader and writer. 16/32/64-bit vector

◆ v16_uni

typedef union v16_uni v16_uni

16/32/64-bit vector union

◆ v32

typedef struct v32 v32

◆ v32_uni

typedef union v32_uni v32_uni

◆ v64

typedef struct v64 v64

◆ v64_uni

typedef union v64_uni v64_uni

◆ yyjson_mut_write_ctx

typedef struct yyjson_mut_write_ctx yyjson_mut_write_ctx

◆ yyjson_write_ctx

typedef struct yyjson_write_ctx yyjson_write_ctx

Enumeration Type Documentation

◆ patch_op

enum patch_op
Enumerator
PATCH_OP_ADD 
PATCH_OP_REMOVE 
PATCH_OP_REPLACE 
PATCH_OP_MOVE 
PATCH_OP_COPY 
PATCH_OP_TEST 
PATCH_OP_NONE 

Definition at line 10964 of file yyjson.c.

Function Documentation

◆ byte_copy_16()

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().

◆ byte_copy_2()

static_inline void byte_copy_2 ( void * dst,
const void * src )

◆ byte_copy_4()

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().

◆ byte_copy_8()

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().

◆ byte_load_2()

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().

◆ byte_load_3()

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().

◆ byte_load_4()

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().

◆ byte_match_2()

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().

◆ byte_match_4()

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().

◆ byte_move_16()

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().

◆ byte_move_2()

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().

◆ byte_move_4()

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().

◆ byte_move_8()

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().

◆ 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.

◆ char_is_ascii_skip()

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.

◆ char_is_ascii_skip_sq()

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.

◆ char_is_ctn()

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().

◆ char_is_digit()

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().

◆ char_is_digit_or_fp()

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().

◆ char_is_eol()

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().

◆ char_is_eol_ext()

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().

◆ char_is_exp()

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().

◆ char_is_fp()

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().

◆ char_is_hex()

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().

◆ char_is_id_ascii()

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().

◆ char_is_id_next()

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().

◆ char_is_id_start()

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().

◆ char_is_nonzero()

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.

◆ char_is_num()

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().

◆ char_is_sign()

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().

◆ char_is_space()

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().

◆ char_is_space_ext()

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().

◆ char_is_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().

◆ char_to_lower()

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().

◆ default_free()

void default_free ( void * ctx,
void * ptr )
static

Definition at line 2235 of file yyjson.c.

References ptr.

◆ default_malloc()

void * default_malloc ( void * ctx,
usize size )
static

Definition at line 2229 of file yyjson.c.

◆ default_realloc()

void * default_realloc ( void * ctx,
void * ptr,
usize old_size,
usize size )
static

Definition at line 2232 of file yyjson.c.

References ptr.

◆ dyn_chunk_list_add()

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().

◆ dyn_chunk_list_remove()

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().

◆ dyn_free()

void dyn_free ( void * ctx_ptr,
void * ptr )
static

◆ dyn_malloc()

◆ dyn_realloc()

void * dyn_realloc ( void * ctx_ptr,
void * ptr,
usize old_size,
usize size )
static

◆ dyn_size_align()

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().

◆ ext_eol_len()

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().

◆ ext_space_len()

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().

◆ f32_to_bits()

static_inline u32 f32_to_bits ( f32 f)

Convert float to bits.

Definition at line 1950 of file yyjson.c.

References static_inline.

◆ f64_bits_inf()

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().

◆ f64_bits_nan()

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().

◆ f64_is_inf()

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().

◆ f64_to_bits()

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().

◆ f64_to_f32()

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().

◆ fopen_readonly()

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().

◆ fopen_safe()

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().

◆ 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().

◆ fread_safe()

static_inline usize fread_safe ( void * buf,
usize size,
FILE * file )

Definition at line 2128 of file yyjson.c.

References static_inline.

Referenced by yyjson_read_fp().

◆ get_enc_table_with_flag()

static_inline const char_enc_type * get_enc_table_with_flag ( yyjson_write_flag flg)

◆ get_hex_table_with_flag()

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().

◆ has_rflag()

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.

◆ has_wflag()

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.

◆ hex_load_2()

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().

◆ hex_load_4()

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().

◆ is_truncated_end()

◆ is_truncated_str()

bool is_truncated_str ( u8 * cur,
u8 * eof,
const char * str,
bool case_sensitive )
static

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().

◆ is_truncated_utf8()

bool is_truncated_utf8 ( u8 * cur,
u8 * eof )
static

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().

◆ is_utf16_bom()

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().

◆ is_utf32_bom()

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().

◆ is_utf8_bom()

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().

◆ mem_align_up()

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().

◆ mut_write_root()

◆ mut_write_root_minify()

◆ mut_write_root_pretty()

◆ mut_write_root_single()

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().

◆ null_free()

void null_free ( void * ctx,
void * ptr )
static

Definition at line 2198 of file yyjson.c.

References ptr.

◆ null_malloc()

void * null_malloc ( void * ctx,
usize size )
static

Definition at line 2190 of file yyjson.c.

◆ null_realloc()

void * null_realloc ( void * ctx,
void * ptr,
usize old_size,
usize size )
static

Definition at line 2194 of file yyjson.c.

References ptr.

◆ patch_op_get()

◆ pool_free()

void pool_free ( void * ctx_ptr,
void * ptr )
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().

◆ pool_malloc()

void * pool_malloc ( void * ctx_ptr,
usize size )
static

◆ pool_realloc()

void * pool_realloc ( void * ctx_ptr,
void * ptr,
usize old_size,
usize size )
static

◆ pool_size_align()

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().

◆ ptr_arr_get()

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.

Parameters
arran array, should not be NULL or non-array type
tokena JSON pointer token
lenunescaped token length
escnumber of escaped characters in this token
Returns
value at index, or NULL if token is not index or index is out of range

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().

◆ ptr_mut_arr_get()

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.

Parameters
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
Returns
value at index, or NULL if token is not index or index is out of range

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().

◆ ptr_mut_obj_get()

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.

Parameters
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
Returns
value associated with the token, or NULL if no value

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().

◆ ptr_new_key()

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.

Parameters
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
Returns
new string value, or NULL if memory allocation failed

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().

◆ ptr_next_token()

static_inline const char * ptr_next_token ( const char ** ptr,
const char * end,
usize * len,
usize * esc )

Get a token from JSON pointer string.

Parameters
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
Returns
head of the token, or NULL if syntax error

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().

◆ ptr_obj_get()

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.

Parameters
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
Returns
value associated with the token, or NULL if no value

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().

◆ ptr_token_eq()

static_inline bool ptr_token_eq ( void * key,
const char * token,
usize len,
usize esc )

Compare JSON key with token.

Parameters
keya string key (yyjson_val or yyjson_mut_val)
tokena JSON pointer token
lenunescaped token length
escnumber of escaped characters in this token
Returns
true if str is equal to 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().

◆ ptr_token_to_idx()

static_inline bool ptr_token_to_idx ( const char * cur,
usize len,
usize * idx )

Convert token string to index.

Parameters
cur[in] token head
len[in] token length
idx[out] the index number, or USIZE_MAX if token is '-'
Returns
true if token is a valid array index

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().

◆ read_false()

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().

◆ read_inf()

◆ 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().

◆ read_nan()

◆ read_null()

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().

◆ read_num()

◆ read_num_hex()

static_noinline bool read_num_hex ( u8 ** ptr,
u8 ** pre,
yyjson_read_flag flg,
yyjson_val * val,
const char ** msg )

◆ read_num_raw()

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().

◆ read_root_minify()

◆ read_root_pretty()

◆ read_root_single()

◆ read_str()

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().

◆ read_str_con()

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().

◆ read_str_id()

◆ read_str_opt()

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.

Parameters
quoThe quote character (single quote or double quote).
ptrThe head pointer of string before quote (inout).
eofJSON end position.
flgJSON read flag.
valThe string value to be written.
msgThe error message pointer.
conContinuation for incremental parsing.
Returns
Whether success.

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().

◆ 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().

◆ read_true()

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().

◆ read_uni_esc()

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().

◆ size_add_is_overflow()

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.

◆ size_align_down()

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().

◆ size_align_up()

static_inline usize size_align_up ( usize size,
usize align )

◆ size_is_pow2()

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().

◆ skip_trivia()

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.

Parameters
ptr(inout) Input current position, output end position.
eofJSON end position.
flgJSON read flags.
Returns
true if at least one character was skipped. false if no characters were skipped, or if a multi-line comment is unterminated; in the latter case, ptr will be set to eof.

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().

◆ u128_mul()

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().

◆ u128_mul_add()

static_inline void u128_mul_add ( u64 a,
u64 b,
u64 c,
u64 * hi,
u64 * lo )

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().

◆ u64_lz_bits()

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.

◆ u64_tz_bits()

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.

◆ unsafe_yyjson_equals()

◆ unsafe_yyjson_mut_equals()

◆ unsafe_yyjson_mut_ptr_getx()

◆ unsafe_yyjson_mut_ptr_putx()

◆ unsafe_yyjson_mut_ptr_removex()

◆ unsafe_yyjson_mut_ptr_replacex()

◆ unsafe_yyjson_mut_val_mut_copy()

◆ unsafe_yyjson_num_equals()

static_inline bool unsafe_yyjson_num_equals ( const void * lhs,
const void * rhs )

◆ unsafe_yyjson_ptr_getx()

yyjson_val * unsafe_yyjson_ptr_getx ( const yyjson_val * val,
const char * ptr,
size_t ptr_len,
yyjson_ptr_err * err )

◆ unsafe_yyjson_str_equals()

static_inline bool unsafe_yyjson_str_equals ( const void * lhs,
const void * rhs )

◆ unsafe_yyjson_str_pool_grow()

◆ unsafe_yyjson_str_pool_release()

static_inline void unsafe_yyjson_str_pool_release ( yyjson_str_pool * pool,
yyjson_alc * alc )

◆ unsafe_yyjson_val_pool_grow()

◆ unsafe_yyjson_val_pool_release()

static_inline void unsafe_yyjson_val_pool_release ( yyjson_val_pool * pool,
yyjson_alc * alc )

◆ utf8_seq_def()

utf8_seq_def ( b1_mask ,
utf8_seq_def( 80,
utf8_seq_def( 00,
utf8_seq_def( 00,
utf8_seq_def( 00 )

Convert bits to double.

Definition at line 1118 of file yyjson.c.

References utf8_seq_def.

◆ write_bool()

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().

◆ write_dat_to_file()

bool write_dat_to_file ( const char * path,
u8 * dat,
usize len,
yyjson_write_err * err )
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().

◆ write_dat_to_fp()

bool write_dat_to_fp ( FILE * fp,
u8 * dat,
usize len,
yyjson_write_err * err )
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().

◆ write_f32_raw()

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().

◆ write_f64_raw()

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().

◆ write_f64_raw_fixed()

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().

◆ write_fp_reformat()

static_noinline u8 * write_fp_reformat ( u8 * buf,
int len,
yyjson_write_flag flg,
bool fixed )

◆ write_indent()

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().

◆ write_null()

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().

◆ write_num()

◆ write_raw()

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().

◆ write_root()

◆ write_root_minify()

◆ write_root_pretty()

◆ write_root_single()

◆ write_str()

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).

Parameters
curBuffer cursor.
escEscape unicode.
invAllow invalid unicode.
strA UTF-8 string, null-terminator is not required.
str_lenLength of string in bytes.
enc_tableEncode type table for character.
Returns
The buffer cursor after string, or NULL on invalid unicode.

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().

◆ write_str_noesc()

static_inline u8 * write_str_noesc ( u8 * cur,
const u8 * str,
usize str_len )

Write string no-escape.

Parameters
curBuffer cursor.
strA UTF-8 string, null-terminator is not required.
str_lenLength of string in bytes.
Returns
The buffer cursor after string.

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().

◆ write_u32_len_1_to_8()

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().

◆ write_u32_len_4()

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().

◆ write_u32_len_5_to_8()

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().

◆ write_u32_len_8()

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().

◆ write_u64()

static_inline u8 * write_u64 ( u64 val,
u8 * buf )

◆ yyjson_alc_dyn_free()

void yyjson_alc_dyn_free ( yyjson_alc * alc)

Free a dynamic allocator which is created by yyjson_alc_dyn_new().

Parameters
alcThe 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_dyn_new()

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.

Returns
A new dynamic allocator, or NULL if memory allocation failed.
Note
The returned value should be freed with yyjson_alc_dyn_free().
Warning
This Allocator is not thread-safe.

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.

◆ yyjson_alc_pool_init()

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.

Parameters
alcThe allocator to be initialized. If alc is NULL, returns false. If buf or size is invalid, this will be set to an empty allocator.
bufThe buffer memory for this allocator. If buf is NULL, returns false.
sizeThe size of buf, in bytes. If size is less than 8 words (32/64 bytes on 32/64-bit OS), returns false.
Returns
true if the alc has been successfully initialized.

Example

// parse JSON with stack memory
char buf[1024];
yyjson_alc_pool_init(&alc, buf, 1024);
const char *json = "{\"name\":\"Helvetica\",\"size\":16}";
yyjson_doc *doc = yyjson_read_opts(json, strlen(json), 0, &alc, NULL);
// the memory of `doc` is on the stack
yyjson_doc * yyjson_read_opts(char *dat, usize len, yyjson_read_flag flg, const yyjson_alc *alc_ptr, yyjson_read_err *err)
Definition yyjson.c:6251
bool yyjson_alc_pool_init(yyjson_alc *alc, void *buf, usize size)
Definition yyjson.c:2376
Warning
This Allocator is not thread-safe.

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()

yyjson_align ( 2 )

Digit table from 00 to 99.

Escaped hex character table: ["00" "01" "02" ... "FD" "FE" "FF"]. (generated with misc/make_tables.c)

Lowercase variant of esc_hex_char_table.

Escaped single character table. (generated with misc/make_tables.c)

Definition at line 7201 of file yyjson.c.

◆ yyjson_doc_mut_copy()

◆ yyjson_imut_copy()

◆ yyjson_incr_free()

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_new()

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:

  1. Call yyjson_incr_new() to create the state for incremental reading.
  2. Call yyjson_incr_read() repeatedly.
  3. Call yyjson_incr_free() to free the state.

Note: The incremental JSON reader only supports standard JSON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.

Parameters
bufThe JSON data, null-terminator is not required. If buf is NULL, returns NULL.
buf_lenThe length of the JSON data in buf. If using YYJSON_READ_INSITU, buf_len should not include the padding size.
flgThe JSON read options. Multiple options can be combined with | operator.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
Returns
A state for incremental reading. It should be freed with yyjson_incr_free(). NULL is returned if memory allocation fails.

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_incr_read()

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.

Parameters
stateThe state for incremental reading, created using yyjson_incr_new().
lenThe number of bytes of JSON data available to parse. If len is 0, returns NULL.
errA pointer to receive error information.
Returns
A new JSON document, or NULL if an error occurs. When the document is no longer needed, it should be freed with yyjson_doc_free().

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.

◆ yyjson_locate_pos()

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.

Parameters
strThe input string.
lenThe byte length of the input string.
posThe byte position within the input string.
lineA pointer to receive the line number, starting from 1.
colA pointer to receive the column number, starting from 1.
chrA pointer to receive the character index, starting from 0.
Returns
true on success, false if str is NULL or pos is out of bounds.
Note
Line/column/character are calculated based on Unicode characters for compatibility with text editors. For multi-byte UTF-8 characters, the returned value may not directly correspond to the byte position.

Definition at line 3078 of file yyjson.c.

References is_utf8_bom(), len, and likely.

◆ yyjson_merge_patch()

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.

Warning
This function is recursive and may cause a stack overflow if the object level is too deep.

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().

◆ yyjson_mut_doc_estimated_val_num()

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().

◆ yyjson_mut_doc_free()

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_mut_doc_imut_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().

Note
mut_doc -> imut_doc.
Warning
This function is recursive and may cause a stack overflow if the object level is too deep.

Definition at line 2898 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_imut_copy().

◆ yyjson_mut_doc_mut_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.

Note
mut_doc -> mut_doc.

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_new()

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().

◆ yyjson_mut_doc_set_str_pool_size()

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.

Parameters
docThe mutable document.
lenThe desired string pool size in bytes (total string length).
Returns
true if successful, false if size is 0 or overflow.

Definition at line 2639 of file yyjson.c.

References yyjson_str_pool::chunk_size, len, yyjson_mut_doc::str_pool, and USIZE_MAX.

◆ yyjson_mut_doc_set_val_pool_size()

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.

Parameters
docThe mutable document.
countThe desired value pool size (number of yyjson_mut_val).
Returns
true if successful, false if size is 0 or overflow.

Definition at line 2646 of file yyjson.c.

References yyjson_val_pool::chunk_size, USIZE_MAX, and yyjson_mut_doc::val_pool.

◆ yyjson_mut_merge_patch()

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.

Warning
This function is recursive and may cause a stack overflow if the object level is too deep.

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_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().

◆ yyjson_mut_stat()

◆ 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().

Note
mut_val -> imut_doc.
Warning
This function is recursive and may cause a stack overflow if the object level is too deep.

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_mut_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.

Note
mut_val -> mut_val.
Warning
This function is recursive and may cause a stack overflow if the object level is too deep.

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().

◆ yyjson_mut_val_write_buf()

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.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
valThe JSON root value. If val is NULL, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

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().

◆ yyjson_mut_val_write_file()

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:

  1. The file is not accessed by other threads.
  2. The val is not modified by other threads.
  3. The alc is thread-safe or NULL.
Parameters
pathThe 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.
valThe mutable JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

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().

◆ yyjson_mut_val_write_fp()

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.

Parameters
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
valThe mutable JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

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().

◆ yyjson_mut_val_write_opts()

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:

  1. The val is not modified by other threads.
  2. The alc is thread-safe or NULL.
Parameters
valThe mutable JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().

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().

◆ yyjson_mut_write_buf()

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.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
docThe JSON document. If doc is NULL or has no root, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 10379 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_buf().

◆ yyjson_mut_write_ctx_get()

static_inline void yyjson_mut_write_ctx_get ( yyjson_mut_write_ctx * ctx,
yyjson_mut_val ** ctn,
usize * size,
bool * is_obj )

◆ yyjson_mut_write_ctx_set()

static_inline void yyjson_mut_write_ctx_set ( yyjson_mut_write_ctx * ctx,
yyjson_mut_val * ctn,
usize size,
bool is_obj )

◆ yyjson_mut_write_file()

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:

  1. The file is not accessed by other threads.
  2. The doc is not modified by other threads.
  3. The alc is thread-safe or NULL.
Parameters
pathThe 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.
docThe mutable JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

Definition at line 10441 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_file().

◆ yyjson_mut_write_fp()

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.

Parameters
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
docThe mutable JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

Definition at line 10450 of file yyjson.c.

References yyjson_mut_doc::root, and yyjson_mut_val_write_fp().

◆ yyjson_mut_write_opts()

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:

  1. The doc is not modified by other threads.
  2. The alc is thread-safe or NULL.
Parameters
docThe mutable JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().

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_patch()

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_read_file()

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:

  1. The file is not modified by other threads.
  2. The alc is thread-safe or NULL.
Parameters
pathThe 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.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().
Warning
On 32-bit operating system, files larger than 2GB may fail to read.

Definition at line 6341 of file yyjson.c.

References fopen_readonly(), MSG_FREAD, return_err, unlikely, and yyjson_read_fp().

◆ 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.

Parameters
fpThe 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.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().
Warning
On 32-bit operating system, files larger than 2GB may fail to read.

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().

◆ yyjson_read_number()

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.

Parameters
datThe JSON data (UTF-8 without BOM), null-terminator is required. If dat is NULL, returns NULL.
valThe output value where result is stored. If val is NULL, returns NULL. The value will hold either UINT or SINT or REAL number;
flgThe 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.
alcThe 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.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
If successful, a pointer to the character after the last character used in the conversion, NULL if an error occurs.

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_read_opts()

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:

  1. The dat is not modified by other threads.
  2. The alc is thread-safe or NULL.
Parameters
datThe 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.
lenThe length of JSON data in bytes. If len is 0, returns NULL.
flgThe JSON read options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON reader. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON document, or NULL if an error occurs. When it's no longer needed, it should be freed with yyjson_doc_free().

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_val_mut_copy()

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.

Note
imut_val -> mut_val.

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().

◆ yyjson_val_write_buf()

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.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
valThe JSON root value. If val is NULL, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

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().

◆ yyjson_val_write_file()

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:

  1. The file is not accessed by other threads.
  2. The alc is thread-safe or NULL.
Parameters
pathThe 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.
valThe JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

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().

◆ yyjson_val_write_fp()

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.

Parameters
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
valThe JSON root value. If val is NULL, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

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().

◆ yyjson_val_write_opts()

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.

Parameters
valThe JSON root value. If val is NULL, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().

Definition at line 9716 of file yyjson.c.

References write_root().

Referenced by yyjson_val_write().

◆ yyjson_version()

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.

◆ yyjson_write_buf()

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.

Parameters
bufThe output buffer. If buf is NULL, returns 0.
buf_lenThe buffer length. If buf_len is too small, returns 0.
docThe JSON document. If doc is NULL or has no root, returns 0.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
The number of bytes written (excluding the null terminator), or 0 on failure.

Definition at line 9821 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_buf().

◆ yyjson_write_ctx_get()

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().

◆ yyjson_write_ctx_set()

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().

◆ yyjson_write_file()

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:

  1. The file is not accessed by other threads.
  2. The alc is thread-safe or NULL.
Parameters
pathThe 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.
docThe JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

Definition at line 9787 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_file().

◆ yyjson_write_fp()

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.

Parameters
fpThe file pointer. The data will be written to the current position of the file. If fp is NULL or invalid, returns false.
docThe JSON document. If doc is NULL or has no root, returns false.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
true if successful, false if an error occurs.
Warning
On 32-bit operating system, files larger than 2GB may fail to write.

Definition at line 9796 of file yyjson.c.

References yyjson_doc::root, and yyjson_val_write_fp().

◆ yyjson_write_number()

char * yyjson_write_number ( const yyjson_val * val,
char * buf )

Write a JSON number.

Parameters
valA JSON number value to be converted to a string. If val is invalid, returns NULL.
bufA 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.
Returns
On success, returns a pointer to the character after the last written character. On failure, returns NULL.
Note
  • This function is thread-safe and does not allocate memory (when YYJSON_DISABLE_FAST_FP_CONV is not defined).
  • This function will fail and return NULL only in the following cases: 1) val or buf is NULL; 2) val is not a number type; 3) val is inf or nan, and non-standard JSON is explicitly disabled via the YYJSON_DISABLE_NON_STANDARD flag.

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().

◆ yyjson_write_opts()

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.

Parameters
docThe JSON document. If doc is NULL or has no root, returns NULL.
flgThe JSON write options. Multiple options can be combined with | operator. 0 means no options.
alcThe memory allocator used by JSON writer. Pass NULL to use the libc's default allocator.
lenA pointer to receive output length in bytes (not including the null-terminator). Pass NULL if you don't need length information.
errA pointer to receive error information. Pass NULL if you don't need error information.
Returns
A new JSON string, or NULL if an error occurs. This string is encoded as UTF-8 with a null-terminator. When it's no longer needed, it should be freed with free() or alc->free().

Definition at line 9724 of file yyjson.c.

References yyjson_doc::root, and write_root().

Referenced by yyjson_write().

Variable Documentation

◆ char_table1

const u8 char_table1[256]
static

◆ char_table2

const u8 char_table2[256]
static

◆ char_table3

const u8 char_table3[256]
static

◆ enc_table_cpy

const char_enc_type enc_table_cpy[256]
static
Initial value:
= {
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1
}

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().

◆ enc_table_cpy_slash

const char_enc_type enc_table_cpy_slash[256]
static
Initial value:
= {
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1
}

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().

◆ enc_table_esc

const char_enc_type enc_table_esc[256]
static
Initial value:
= {
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1
}

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().

◆ enc_table_esc_slash

const char_enc_type enc_table_esc_slash[256]
static
Initial value:
= {
3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 2, 2, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1
}

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().

◆ hex_conv_table

const u8 hex_conv_table[256]
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().

◆ YYJSON_DEFAULT_ALC

const yyjson_alc YYJSON_DEFAULT_ALC
static
Initial value:
= {
}
static void default_free(void *ctx, void *ptr)
Definition yyjson.c:2235
static void * default_realloc(void *ctx, void *ptr, usize old_size, usize size)
Definition yyjson.c:2232
static void * default_malloc(void *ctx, usize size)
Definition yyjson.c:2229

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().

◆ YYJSON_NULL_ALC

const yyjson_alc YYJSON_NULL_ALC
static
Initial value:
= {
}
static void * null_realloc(void *ctx, void *ptr, usize old_size, usize size)
Definition yyjson.c:2194
static void null_free(void *ctx, void *ptr)
Definition yyjson.c:2198
static void * null_malloc(void *ctx, usize size)
Definition yyjson.c:2190

Definition at line 2202 of file yyjson.c.

Referenced by yyjson_alc_pool_init(), yyjson_mut_val_write_buf(), and yyjson_val_write_buf().