|
CToon C 0.6.1
A C99 TOON/JSON serialization library
|
#include <stdio.h>#include <stdlib.h>#include <stddef.h>#include <limits.h>#include <string.h>#include <float.h>
Go to the source code of this file.
Data Structures | |
| struct | ctoon_alc |
| struct | ctoon_read_err |
| struct | ctoon_write_err |
| struct | ctoon_write_options |
| struct | ctoon_arr_iter |
| struct | ctoon_obj_iter |
| struct | ctoon_mut_arr_iter |
| struct | ctoon_mut_obj_iter |
| struct | ctoon_ptr_err |
| struct | ctoon_ptr_ctx |
| struct | ctoon_patch_err |
| union | ctoon_val_uni |
| struct | ctoon_val |
| struct | ctoon_doc |
| struct | ctoon_mut_val |
| struct | ctoon_str_chunk |
| struct | ctoon_str_pool |
| struct | ctoon_val_chunk |
| struct | ctoon_val_pool |
| struct | ctoon_mut_doc |
Macros | |
| #define | CTOON_MSC_VER 0 |
| #define | CTOON_GCC_VER 0 |
| #define | ctoon_gcc_available(major, minor, patch) 0 |
| #define | CTOON_IS_REAL_GCC 0 |
| #define | CTOON_STDC_VER 0 |
| #define | CTOON_CPP_VER 0 |
| #define | ctoon_has_builtin(x) 0 |
| #define | ctoon_has_attribute(x) 0 |
| #define | ctoon_has_feature(x) 0 |
| #define | ctoon_has_include(x) 0 |
| #define | ctoon_inline |
| #define | ctoon_noinline |
| #define | ctoon_align(x) |
| #define | ctoon_likely(expr) (expr) |
| #define | ctoon_unlikely(expr) (expr) |
| #define | CTOON_HAS_CONSTANT_P 0 |
| #define | ctoon_constant_p(value) 0 |
| #define | ctoon_deprecated(msg) |
| #define | ctoon_api |
| #define | ctoon_api_inline static ctoon_inline |
| #define | __bool_true_false_are_defined 1 |
| #define | bool unsigned char |
| #define | true 1 |
| #define | false 0 |
| #define | CTOON_U64_TO_F64_NO_IMPL 0 |
| #define | CTOON_VERSION_MAJOR 0 |
| #define | CTOON_VERSION_MINOR 6 |
| #define | CTOON_VERSION_PATCH 1 |
| #define | CTOON_VERSION_ENCODE(maj, min, pat) (((maj)*10000)+((min)*100)+(pat)) |
| #define | CTOON_VERSION CTOON_VERSION_ENCODE(CTOON_VERSION_MAJOR,CTOON_VERSION_MINOR,CTOON_VERSION_PATCH) |
| #define | CTOON_VERSION_HEX ((CTOON_VERSION_MAJOR << 16) | (CTOON_VERSION_MINOR << 8) | CTOON_VERSION_PATCH) |
| #define | _CTOON_VERSION_XSTR(a, b, c) #a"."#b"."#c |
| #define | _CTOON_VERSION_STR(a, b, c) _CTOON_VERSION_XSTR(a,b,c) |
| #define | CTOON_VERSION_STRING _CTOON_VERSION_STR(CTOON_VERSION_MAJOR,CTOON_VERSION_MINOR,CTOON_VERSION_PATCH) |
| #define | CTOON_TYPE_NONE ((uint8_t)0) /* _____000 */ |
| #define | CTOON_TYPE_RAW ((uint8_t)1) /* _____001 */ |
| #define | CTOON_TYPE_NULL ((uint8_t)2) /* _____010 */ |
| #define | CTOON_TYPE_BOOL ((uint8_t)3) /* _____011 */ |
| #define | CTOON_TYPE_NUM ((uint8_t)4) /* _____100 */ |
| #define | CTOON_TYPE_STR ((uint8_t)5) /* _____101 */ |
| #define | CTOON_TYPE_ARR ((uint8_t)6) /* _____110 */ |
| #define | CTOON_TYPE_OBJ ((uint8_t)7) /* _____111 */ |
| #define | CTOON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define | CTOON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define | CTOON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define | CTOON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define | CTOON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define | CTOON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */ |
| #define | CTOON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define | CTOON_TYPE_MASK ((uint8_t)0x07) /* _____111 */ |
| #define | CTOON_TYPE_BIT ((uint8_t)3) |
| #define | CTOON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */ |
| #define | CTOON_SUBTYPE_BIT ((uint8_t)2) |
| #define | CTOON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */ |
| #define | CTOON_RESERVED_BIT ((uint8_t)3) |
| #define | CTOON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */ |
| #define | CTOON_TAG_BIT ((uint8_t)8) |
| #define | CTOON_PADDING_SIZE 4 |
| #define | CTOON_WRITE_FP_FLAG_BITS 8 |
| #define | CTOON_WRITE_FP_PREC_BITS 4 |
| #define | CTOON_WRITE_FP_TO_FIXED(prec) |
| #define | CTOON_WRITE_FP_TO_FLOAT ((ctoon_write_flag)(1 << (32 - 5))) |
| #define | ctoon_arr_foreach(arr, idx, max, val) |
| #define | ctoon_obj_foreach(obj, idx, max, key, val) |
| #define | ctoon_mut_arr_foreach(arr, idx, max, val) |
| #define | ctoon_mut_obj_foreach(obj, idx, max, key, val) |
| #define | ctoon_mut_val_one(func) |
| #define | ctoon_mut_val_one_str(func) |
| #define | ctoon_mut_arr_with_func(func) |
| #define | ctoon_mut_obj_add_func(func) |
| #define | ctoon_ptr_set_err(_code, _msg) |
Enumerations | |
| enum | ctoon_delimiter { CTOON_DELIMITER_COMMA = 0 , CTOON_DELIMITER_TAB , CTOON_DELIMITER_PIPE } |
Functions | |
| uint32_t | ctoon_version (void) |
| unsigned char | ctoon_alc_pool_init (ctoon_alc *alc, void *buf, size_t size) |
| ctoon_alc * | ctoon_alc_dyn_new (void) |
| void | ctoon_alc_dyn_free (ctoon_alc *alc) |
| unsigned char | ctoon_locate_pos (const char *str, size_t len, size_t pos, size_t *line, size_t *col, size_t *chr) |
| ctoon_doc * | ctoon_read_opts (char *dat, size_t len, ctoon_read_flag flg, const ctoon_alc *alc, ctoon_read_err *err) |
| ctoon_doc * | ctoon_read_opts_indent (char *dat, size_t len, ctoon_read_flag flg, int indent_size, const ctoon_alc *alc, ctoon_read_err *err) |
| ctoon_doc * | ctoon_read_file (const char *path, ctoon_read_flag flg, const ctoon_alc *alc, ctoon_read_err *err) |
| ctoon_doc * | ctoon_read_fp (FILE *fp, ctoon_read_flag flg, const ctoon_alc *alc, ctoon_read_err *err) |
| static ctoon_doc * | ctoon_read (const char *dat, size_t len, ctoon_read_flag flg) |
| ctoon_incr_state * | ctoon_incr_new (char *buf, size_t buf_len, ctoon_read_flag flg, const ctoon_alc *alc) |
| ctoon_doc * | ctoon_incr_read (ctoon_incr_state *state, size_t len, ctoon_read_err *err) |
| void | ctoon_incr_free (ctoon_incr_state *state) |
| static size_t | ctoon_read_max_memory_usage (size_t len, ctoon_read_flag flg) |
| const char * | ctoon_read_number (const char *dat, ctoon_val *val, ctoon_read_flag flg, const ctoon_alc *alc, ctoon_read_err *err) |
| static const char * | ctoon_mut_read_number (const char *dat, ctoon_mut_val *val, ctoon_read_flag flg, const ctoon_alc *alc, ctoon_read_err *err) |
| char * | ctoon_write_opts (const ctoon_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| static char * | ctoon_write (const ctoon_doc *doc, size_t *len) |
| unsigned char | ctoon_write_file (const char *path, const ctoon_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, ctoon_write_err *err) |
| unsigned char | ctoon_write_fp (FILE *fp, const ctoon_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, ctoon_write_err *err) |
| char * | ctoon_val_write_opts (const ctoon_val *val, const ctoon_write_options *opts, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| static char * | ctoon_val_write (const ctoon_val *val, size_t *len) |
| char * | ctoon_mut_write_opts (const ctoon_mut_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| static char * | ctoon_mut_write (const ctoon_mut_doc *doc, size_t *len) |
| unsigned char | ctoon_mut_write_file (const char *path, const ctoon_mut_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, ctoon_write_err *err) |
| unsigned char | ctoon_mut_write_fp (FILE *fp, const ctoon_mut_doc *doc, const ctoon_write_options *opts, const ctoon_alc *alc, ctoon_write_err *err) |
| char * | ctoon_mut_val_write_opts (const ctoon_mut_val *val, const ctoon_write_options *opts, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| static char * | ctoon_mut_val_write (const ctoon_mut_val *val, size_t *len) |
| char * | ctoon_write_number (const ctoon_val *val, char *buf) |
| char * | ctoon_doc_to_json (const ctoon_doc *doc, int indent, ctoon_write_flag flags, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| char * | ctoon_mut_doc_to_json (const ctoon_mut_doc *doc, int indent, ctoon_write_flag flags, const ctoon_alc *alc, size_t *len, ctoon_write_err *err) |
| static ctoon_val * | ctoon_doc_get_root (ctoon_doc *doc) |
| static size_t | ctoon_doc_get_read_size (ctoon_doc *doc) |
| static size_t | ctoon_doc_get_val_count (ctoon_doc *doc) |
| static void | ctoon_doc_free (ctoon_doc *doc) |
| static unsigned char | ctoon_is_raw (ctoon_val *val) |
| static unsigned char | ctoon_is_null (ctoon_val *val) |
| static unsigned char | ctoon_is_true (ctoon_val *val) |
| static unsigned char | ctoon_is_false (ctoon_val *val) |
| static unsigned char | ctoon_is_bool (ctoon_val *val) |
| static unsigned char | ctoon_is_uint (ctoon_val *val) |
| static unsigned char | ctoon_is_sint (ctoon_val *val) |
| static unsigned char | ctoon_is_int (ctoon_val *val) |
| static unsigned char | ctoon_is_real (ctoon_val *val) |
| static unsigned char | ctoon_is_num (ctoon_val *val) |
| static unsigned char | ctoon_is_str (ctoon_val *val) |
| static unsigned char | ctoon_is_arr (ctoon_val *val) |
| static unsigned char | ctoon_is_obj (ctoon_val *val) |
| static unsigned char | ctoon_is_ctn (ctoon_val *val) |
| static ctoon_type | ctoon_get_type (ctoon_val *val) |
| static ctoon_subtype | ctoon_get_subtype (ctoon_val *val) |
| static uint8_t | ctoon_get_tag (ctoon_val *val) |
| static const char * | ctoon_get_type_desc (ctoon_val *val) |
| static const char * | ctoon_get_raw (ctoon_val *val) |
| static unsigned char | ctoon_get_bool (ctoon_val *val) |
| static uint64_t | ctoon_get_uint (ctoon_val *val) |
| static int64_t | ctoon_get_sint (ctoon_val *val) |
| static int | ctoon_get_int (ctoon_val *val) |
| static double | ctoon_get_real (ctoon_val *val) |
| static double | ctoon_get_num (ctoon_val *val) |
| static const char * | ctoon_get_str (ctoon_val *val) |
| static size_t | ctoon_get_len (ctoon_val *val) |
| static unsigned char | ctoon_equals_str (ctoon_val *val, const char *str) |
| static unsigned char | ctoon_equals_strn (ctoon_val *val, const char *str, size_t len) |
| static unsigned char | ctoon_equals (ctoon_val *lhs, ctoon_val *rhs) |
| static unsigned char | ctoon_set_raw (ctoon_val *val, const char *raw, size_t len) |
| static unsigned char | ctoon_set_null (ctoon_val *val) |
| static unsigned char | ctoon_set_bool (ctoon_val *val, unsigned char num) |
| static unsigned char | ctoon_set_uint (ctoon_val *val, uint64_t num) |
| static unsigned char | ctoon_set_sint (ctoon_val *val, int64_t num) |
| static unsigned char | ctoon_set_int (ctoon_val *val, int num) |
| static unsigned char | ctoon_set_float (ctoon_val *val, float num) |
| static unsigned char | ctoon_set_double (ctoon_val *val, double num) |
| static unsigned char | ctoon_set_real (ctoon_val *val, double num) |
| static unsigned char | ctoon_set_fp_to_fixed (ctoon_val *val, int prec) |
| static unsigned char | ctoon_set_fp_to_float (ctoon_val *val, unsigned char flt) |
| static unsigned char | ctoon_set_str (ctoon_val *val, const char *str) |
| static unsigned char | ctoon_set_strn (ctoon_val *val, const char *str, size_t len) |
| static unsigned char | ctoon_set_str_noesc (ctoon_val *val, unsigned char noesc) |
| static size_t | ctoon_arr_size (ctoon_val *arr) |
| static ctoon_val * | ctoon_arr_get (ctoon_val *arr, size_t idx) |
| static ctoon_val * | ctoon_arr_get_first (ctoon_val *arr) |
| static ctoon_val * | ctoon_arr_get_last (ctoon_val *arr) |
| static unsigned char | ctoon_arr_iter_init (ctoon_val *arr, ctoon_arr_iter *iter) |
| static ctoon_arr_iter | ctoon_arr_iter_with (ctoon_val *arr) |
| static unsigned char | ctoon_arr_iter_has_next (ctoon_arr_iter *iter) |
| static ctoon_val * | ctoon_arr_iter_next (ctoon_arr_iter *iter) |
| static size_t | ctoon_obj_size (ctoon_val *obj) |
| static ctoon_val * | ctoon_obj_get (ctoon_val *obj, const char *key) |
| static ctoon_val * | ctoon_obj_getn (ctoon_val *obj, const char *key, size_t key_len) |
| static unsigned char | ctoon_obj_iter_init (ctoon_val *obj, ctoon_obj_iter *iter) |
| static ctoon_obj_iter | ctoon_obj_iter_with (ctoon_val *obj) |
| static unsigned char | ctoon_obj_iter_has_next (ctoon_obj_iter *iter) |
| static ctoon_val * | ctoon_obj_iter_next (ctoon_obj_iter *iter) |
| static ctoon_val * | ctoon_obj_iter_get_val (ctoon_val *key) |
| static ctoon_val * | ctoon_obj_iter_get (ctoon_obj_iter *iter, const char *key) |
| static ctoon_val * | ctoon_obj_iter_getn (ctoon_obj_iter *iter, const char *key, size_t key_len) |
| static ctoon_mut_val * | ctoon_mut_doc_get_root (ctoon_mut_doc *doc) |
| static void | ctoon_mut_doc_set_root (ctoon_mut_doc *doc, ctoon_mut_val *root) |
| unsigned char | ctoon_mut_doc_set_str_pool_size (ctoon_mut_doc *doc, size_t len) |
| unsigned char | ctoon_mut_doc_set_val_pool_size (ctoon_mut_doc *doc, size_t count) |
| void | ctoon_mut_doc_free (ctoon_mut_doc *doc) |
| ctoon_mut_doc * | ctoon_mut_doc_new (const ctoon_alc *alc) |
| ctoon_mut_doc * | ctoon_doc_mut_copy (ctoon_doc *doc, const ctoon_alc *alc) |
| ctoon_mut_doc * | ctoon_mut_doc_mut_copy (ctoon_mut_doc *doc, const ctoon_alc *alc) |
| ctoon_mut_val * | ctoon_val_mut_copy (ctoon_mut_doc *doc, ctoon_val *val) |
| ctoon_mut_val * | ctoon_mut_val_mut_copy (ctoon_mut_doc *doc, ctoon_mut_val *val) |
| ctoon_doc * | ctoon_mut_doc_imut_copy (ctoon_mut_doc *doc, const ctoon_alc *alc) |
| ctoon_doc * | ctoon_mut_val_imut_copy (ctoon_mut_val *val, const ctoon_alc *alc) |
| static unsigned char | ctoon_mut_is_raw (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_null (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_true (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_false (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_bool (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_uint (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_sint (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_int (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_real (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_num (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_str (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_arr (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_obj (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_is_ctn (ctoon_mut_val *val) |
| static ctoon_type | ctoon_mut_get_type (ctoon_mut_val *val) |
| static ctoon_subtype | ctoon_mut_get_subtype (ctoon_mut_val *val) |
| static uint8_t | ctoon_mut_get_tag (ctoon_mut_val *val) |
| static const char * | ctoon_mut_get_type_desc (ctoon_mut_val *val) |
| static const char * | ctoon_mut_get_raw (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_get_bool (ctoon_mut_val *val) |
| static uint64_t | ctoon_mut_get_uint (ctoon_mut_val *val) |
| static int64_t | ctoon_mut_get_sint (ctoon_mut_val *val) |
| static int | ctoon_mut_get_int (ctoon_mut_val *val) |
| static double | ctoon_mut_get_real (ctoon_mut_val *val) |
| static double | ctoon_mut_get_num (ctoon_mut_val *val) |
| static const char * | ctoon_mut_get_str (ctoon_mut_val *val) |
| static size_t | ctoon_mut_get_len (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_equals_str (ctoon_mut_val *val, const char *str) |
| static unsigned char | ctoon_mut_equals_strn (ctoon_mut_val *val, const char *str, size_t len) |
| static unsigned char | ctoon_mut_equals (ctoon_mut_val *lhs, ctoon_mut_val *rhs) |
| static unsigned char | ctoon_mut_set_raw (ctoon_mut_val *val, const char *raw, size_t len) |
| static unsigned char | ctoon_mut_set_null (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_set_bool (ctoon_mut_val *val, unsigned char num) |
| static unsigned char | ctoon_mut_set_uint (ctoon_mut_val *val, uint64_t num) |
| static unsigned char | ctoon_mut_set_sint (ctoon_mut_val *val, int64_t num) |
| static unsigned char | ctoon_mut_set_int (ctoon_mut_val *val, int num) |
| static unsigned char | ctoon_mut_set_float (ctoon_mut_val *val, float num) |
| static unsigned char | ctoon_mut_set_double (ctoon_mut_val *val, double num) |
| static unsigned char | ctoon_mut_set_real (ctoon_mut_val *val, double num) |
| static unsigned char | ctoon_mut_set_fp_to_fixed (ctoon_mut_val *val, int prec) |
| static unsigned char | ctoon_mut_set_fp_to_float (ctoon_mut_val *val, unsigned char flt) |
| static unsigned char | ctoon_mut_set_str (ctoon_mut_val *val, const char *str) |
| static unsigned char | ctoon_mut_set_strn (ctoon_mut_val *val, const char *str, size_t len) |
| static unsigned char | ctoon_mut_set_str_noesc (ctoon_mut_val *val, unsigned char noesc) |
| static unsigned char | ctoon_mut_set_arr (ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_set_obj (ctoon_mut_val *val) |
| static ctoon_mut_val * | ctoon_mut_raw (ctoon_mut_doc *doc, const char *str) |
| static ctoon_mut_val * | ctoon_mut_rawn (ctoon_mut_doc *doc, const char *str, size_t len) |
| static ctoon_mut_val * | ctoon_mut_rawcpy (ctoon_mut_doc *doc, const char *str) |
| static ctoon_mut_val * | ctoon_mut_rawncpy (ctoon_mut_doc *doc, const char *str, size_t len) |
| static ctoon_mut_val * | ctoon_mut_null (ctoon_mut_doc *doc) |
| static ctoon_mut_val * | ctoon_mut_true (ctoon_mut_doc *doc) |
| static ctoon_mut_val * | ctoon_mut_false (ctoon_mut_doc *doc) |
| static ctoon_mut_val * | ctoon_mut_bool (ctoon_mut_doc *doc, unsigned char val) |
| static ctoon_mut_val * | ctoon_mut_uint (ctoon_mut_doc *doc, uint64_t num) |
| static ctoon_mut_val * | ctoon_mut_sint (ctoon_mut_doc *doc, int64_t num) |
| static ctoon_mut_val * | ctoon_mut_int (ctoon_mut_doc *doc, int64_t num) |
| static ctoon_mut_val * | ctoon_mut_float (ctoon_mut_doc *doc, float num) |
| static ctoon_mut_val * | ctoon_mut_double (ctoon_mut_doc *doc, double num) |
| static ctoon_mut_val * | ctoon_mut_real (ctoon_mut_doc *doc, double num) |
| static ctoon_mut_val * | ctoon_mut_str (ctoon_mut_doc *doc, const char *str) |
| static ctoon_mut_val * | ctoon_mut_strn (ctoon_mut_doc *doc, const char *str, size_t len) |
| static ctoon_mut_val * | ctoon_mut_strcpy (ctoon_mut_doc *doc, const char *str) |
| static ctoon_mut_val * | ctoon_mut_strncpy (ctoon_mut_doc *doc, const char *str, size_t len) |
| static size_t | ctoon_mut_arr_size (ctoon_mut_val *arr) |
| static ctoon_mut_val * | ctoon_mut_arr_get (ctoon_mut_val *arr, size_t idx) |
| static ctoon_mut_val * | ctoon_mut_arr_get_first (ctoon_mut_val *arr) |
| static ctoon_mut_val * | ctoon_mut_arr_get_last (ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_iter_init (ctoon_mut_val *arr, ctoon_mut_arr_iter *iter) |
| static ctoon_mut_arr_iter | ctoon_mut_arr_iter_with (ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_iter_has_next (ctoon_mut_arr_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_arr_iter_next (ctoon_mut_arr_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_arr_iter_remove (ctoon_mut_arr_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_arr (ctoon_mut_doc *doc) |
| static ctoon_mut_val * | ctoon_mut_arr_with_bool (ctoon_mut_doc *doc, const unsigned char *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_sint (ctoon_mut_doc *doc, const int64_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_uint (ctoon_mut_doc *doc, const uint64_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_real (ctoon_mut_doc *doc, const double *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_sint8 (ctoon_mut_doc *doc, const int8_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_sint16 (ctoon_mut_doc *doc, const int16_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_sint32 (ctoon_mut_doc *doc, const int32_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_sint64 (ctoon_mut_doc *doc, const int64_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_uint8 (ctoon_mut_doc *doc, const uint8_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_uint16 (ctoon_mut_doc *doc, const uint16_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_uint32 (ctoon_mut_doc *doc, const uint32_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_uint64 (ctoon_mut_doc *doc, const uint64_t *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_float (ctoon_mut_doc *doc, const float *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_double (ctoon_mut_doc *doc, const double *vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_str (ctoon_mut_doc *doc, const char **vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_strn (ctoon_mut_doc *doc, const char **vals, const size_t *lens, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_strcpy (ctoon_mut_doc *doc, const char **vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_arr_with_strncpy (ctoon_mut_doc *doc, const char **vals, const size_t *lens, size_t count) |
| static unsigned char | ctoon_mut_arr_insert (ctoon_mut_val *arr, ctoon_mut_val *val, size_t idx) |
| static unsigned char | ctoon_mut_arr_append (ctoon_mut_val *arr, ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_arr_prepend (ctoon_mut_val *arr, ctoon_mut_val *val) |
| static ctoon_mut_val * | ctoon_mut_arr_replace (ctoon_mut_val *arr, size_t idx, ctoon_mut_val *val) |
| static ctoon_mut_val * | ctoon_mut_arr_remove (ctoon_mut_val *arr, size_t idx) |
| static ctoon_mut_val * | ctoon_mut_arr_remove_first (ctoon_mut_val *arr) |
| static ctoon_mut_val * | ctoon_mut_arr_remove_last (ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_remove_range (ctoon_mut_val *arr, size_t idx, size_t len) |
| static unsigned char | ctoon_mut_arr_clear (ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_rotate (ctoon_mut_val *arr, size_t idx) |
| static unsigned char | ctoon_mut_arr_add_val (ctoon_mut_val *arr, ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_arr_add_null (ctoon_mut_doc *doc, ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_add_true (ctoon_mut_doc *doc, ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_add_false (ctoon_mut_doc *doc, ctoon_mut_val *arr) |
| static unsigned char | ctoon_mut_arr_add_bool (ctoon_mut_doc *doc, ctoon_mut_val *arr, unsigned char val) |
| static unsigned char | ctoon_mut_arr_add_uint (ctoon_mut_doc *doc, ctoon_mut_val *arr, uint64_t num) |
| static unsigned char | ctoon_mut_arr_add_sint (ctoon_mut_doc *doc, ctoon_mut_val *arr, int64_t num) |
| static unsigned char | ctoon_mut_arr_add_int (ctoon_mut_doc *doc, ctoon_mut_val *arr, int64_t num) |
| static unsigned char | ctoon_mut_arr_add_float (ctoon_mut_doc *doc, ctoon_mut_val *arr, float num) |
| static unsigned char | ctoon_mut_arr_add_double (ctoon_mut_doc *doc, ctoon_mut_val *arr, double num) |
| static unsigned char | ctoon_mut_arr_add_real (ctoon_mut_doc *doc, ctoon_mut_val *arr, double num) |
| static unsigned char | ctoon_mut_arr_add_str (ctoon_mut_doc *doc, ctoon_mut_val *arr, const char *str) |
| static unsigned char | ctoon_mut_arr_add_strn (ctoon_mut_doc *doc, ctoon_mut_val *arr, const char *str, size_t len) |
| static unsigned char | ctoon_mut_arr_add_strcpy (ctoon_mut_doc *doc, ctoon_mut_val *arr, const char *str) |
| static unsigned char | ctoon_mut_arr_add_strncpy (ctoon_mut_doc *doc, ctoon_mut_val *arr, const char *str, size_t len) |
| static ctoon_mut_val * | ctoon_mut_arr_add_arr (ctoon_mut_doc *doc, ctoon_mut_val *arr) |
| static ctoon_mut_val * | ctoon_mut_arr_add_obj (ctoon_mut_doc *doc, ctoon_mut_val *arr) |
| static size_t | ctoon_mut_obj_size (ctoon_mut_val *obj) |
| static ctoon_mut_val * | ctoon_mut_obj_get (ctoon_mut_val *obj, const char *key) |
| static ctoon_mut_val * | ctoon_mut_obj_getn (ctoon_mut_val *obj, const char *key, size_t key_len) |
| static unsigned char | ctoon_mut_obj_iter_init (ctoon_mut_val *obj, ctoon_mut_obj_iter *iter) |
| static ctoon_mut_obj_iter | ctoon_mut_obj_iter_with (ctoon_mut_val *obj) |
| static unsigned char | ctoon_mut_obj_iter_has_next (ctoon_mut_obj_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_obj_iter_next (ctoon_mut_obj_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_obj_iter_get_val (ctoon_mut_val *key) |
| static ctoon_mut_val * | ctoon_mut_obj_iter_remove (ctoon_mut_obj_iter *iter) |
| static ctoon_mut_val * | ctoon_mut_obj_iter_get (ctoon_mut_obj_iter *iter, const char *key) |
| static ctoon_mut_val * | ctoon_mut_obj_iter_getn (ctoon_mut_obj_iter *iter, const char *key, size_t key_len) |
| static ctoon_mut_val * | ctoon_mut_obj (ctoon_mut_doc *doc) |
| static ctoon_mut_val * | ctoon_mut_obj_with_str (ctoon_mut_doc *doc, const char **keys, const char **vals, size_t count) |
| static ctoon_mut_val * | ctoon_mut_obj_with_kv (ctoon_mut_doc *doc, const char **kv_pairs, size_t pair_count) |
| static unsigned char | ctoon_mut_obj_add (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_obj_put (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_obj_insert (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val, size_t idx) |
| static ctoon_mut_val * | ctoon_mut_obj_remove (ctoon_mut_val *obj, ctoon_mut_val *key) |
| static ctoon_mut_val * | ctoon_mut_obj_remove_key (ctoon_mut_val *obj, const char *key) |
| static ctoon_mut_val * | ctoon_mut_obj_remove_keyn (ctoon_mut_val *obj, const char *key, size_t key_len) |
| static unsigned char | ctoon_mut_obj_clear (ctoon_mut_val *obj) |
| static unsigned char | ctoon_mut_obj_replace (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val) |
| static unsigned char | ctoon_mut_obj_rotate (ctoon_mut_val *obj, size_t idx) |
| static unsigned char | ctoon_mut_obj_add_null (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key) |
| static unsigned char | ctoon_mut_obj_add_true (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key) |
| static unsigned char | ctoon_mut_obj_add_false (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key) |
| static unsigned char | ctoon_mut_obj_add_bool (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, unsigned char val) |
| static unsigned char | ctoon_mut_obj_add_uint (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, uint64_t val) |
| static unsigned char | ctoon_mut_obj_add_sint (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, int64_t val) |
| static unsigned char | ctoon_mut_obj_add_int (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, int64_t val) |
| static unsigned char | ctoon_mut_obj_add_float (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, float val) |
| static unsigned char | ctoon_mut_obj_add_double (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, double val) |
| static unsigned char | ctoon_mut_obj_add_real (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, double val) |
| static unsigned char | ctoon_mut_obj_add_str (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, const char *val) |
| static unsigned char | ctoon_mut_obj_add_strn (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, const char *val, size_t len) |
| static unsigned char | ctoon_mut_obj_add_strcpy (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, const char *val) |
| static unsigned char | ctoon_mut_obj_add_strncpy (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, const char *val, size_t len) |
| static ctoon_mut_val * | ctoon_mut_obj_add_arr (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key) |
| static ctoon_mut_val * | ctoon_mut_obj_add_obj (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key) |
| static unsigned char | ctoon_mut_obj_add_val (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, ctoon_mut_val *val) |
| static ctoon_mut_val * | ctoon_mut_obj_remove_str (ctoon_mut_val *obj, const char *key) |
| static ctoon_mut_val * | ctoon_mut_obj_remove_strn (ctoon_mut_val *obj, const char *key, size_t len) |
| static unsigned char | ctoon_mut_obj_rename_key (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, const char *new_key) |
| static unsigned char | ctoon_mut_obj_rename_keyn (ctoon_mut_doc *doc, ctoon_mut_val *obj, const char *key, size_t len, const char *new_key, size_t new_len) |
| static ctoon_val * | ctoon_doc_ptr_get (ctoon_doc *doc, const char *ptr) |
| static ctoon_val * | ctoon_doc_ptr_getn (ctoon_doc *doc, const char *ptr, size_t len) |
| static ctoon_val * | ctoon_doc_ptr_getx (ctoon_doc *doc, const char *ptr, size_t len, ctoon_ptr_err *err) |
| static ctoon_val * | ctoon_ptr_get (ctoon_val *val, const char *ptr) |
| static ctoon_val * | ctoon_ptr_getn (ctoon_val *val, const char *ptr, size_t len) |
| static ctoon_val * | ctoon_ptr_getx (ctoon_val *val, const char *ptr, size_t len, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_get (ctoon_mut_doc *doc, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_getn (ctoon_mut_doc *doc, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_getx (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_ptr_get (ctoon_mut_val *val, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_ptr_getn (ctoon_mut_val *val, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_ptr_getx (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_mut_doc_ptr_add (ctoon_mut_doc *doc, const char *ptr, ctoon_mut_val *new_val) |
| static unsigned char | ctoon_mut_doc_ptr_addn (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val) |
| static unsigned char | ctoon_mut_doc_ptr_addx (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val, unsigned char create_parent, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_mut_ptr_add (ctoon_mut_val *val, const char *ptr, ctoon_mut_val *new_val, ctoon_mut_doc *doc) |
| static unsigned char | ctoon_mut_ptr_addn (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_mut_doc *doc) |
| static unsigned char | ctoon_mut_ptr_addx (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_mut_doc *doc, unsigned char create_parent, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_mut_doc_ptr_set (ctoon_mut_doc *doc, const char *ptr, ctoon_mut_val *new_val) |
| static unsigned char | ctoon_mut_doc_ptr_setn (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val) |
| static unsigned char | ctoon_mut_doc_ptr_setx (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val, unsigned char create_parent, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_mut_ptr_set (ctoon_mut_val *val, const char *ptr, ctoon_mut_val *new_val, ctoon_mut_doc *doc) |
| static unsigned char | ctoon_mut_ptr_setn (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_mut_doc *doc) |
| static unsigned char | ctoon_mut_ptr_setx (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_mut_doc *doc, unsigned char create_parent, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_replace (ctoon_mut_doc *doc, const char *ptr, ctoon_mut_val *new_val) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_replacen (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_replacex (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_ptr_replace (ctoon_mut_val *val, const char *ptr, ctoon_mut_val *new_val) |
| static ctoon_mut_val * | ctoon_mut_ptr_replacen (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val) |
| static ctoon_mut_val * | ctoon_mut_ptr_replacex (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_remove (ctoon_mut_doc *doc, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_removen (ctoon_mut_doc *doc, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_doc_ptr_removex (ctoon_mut_doc *doc, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static ctoon_mut_val * | ctoon_mut_ptr_remove (ctoon_mut_val *val, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_ptr_removen (ctoon_mut_val *val, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_ptr_removex (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_ptr_ctx_append (ctoon_ptr_ctx *ctx, ctoon_mut_val *key, ctoon_mut_val *val) |
| static unsigned char | ctoon_ptr_ctx_replace (ctoon_ptr_ctx *ctx, ctoon_mut_val *val) |
| static unsigned char | ctoon_ptr_ctx_remove (ctoon_ptr_ctx *ctx) |
| ctoon_mut_val * | ctoon_patch (ctoon_mut_doc *doc, ctoon_val *orig, ctoon_val *patch, ctoon_patch_err *err) |
| ctoon_mut_val * | ctoon_mut_patch (ctoon_mut_doc *doc, ctoon_mut_val *orig, ctoon_mut_val *patch, ctoon_patch_err *err) |
| ctoon_mut_val * | ctoon_merge_patch (ctoon_mut_doc *doc, ctoon_val *orig, ctoon_val *patch) |
| ctoon_mut_val * | ctoon_mut_merge_patch (ctoon_mut_doc *doc, ctoon_mut_val *orig, ctoon_mut_val *patch) |
| static unsigned char | unsafe_ctoon_is_str_noesc (const char *str, size_t len) |
| static double | unsafe_ctoon_u64_to_f64 (uint64_t num) |
| static ctoon_type | unsafe_ctoon_get_type (void *val) |
| static ctoon_subtype | unsafe_ctoon_get_subtype (void *val) |
| static uint8_t | unsafe_ctoon_get_tag (void *val) |
| static unsigned char | unsafe_ctoon_is_raw (void *val) |
| static unsigned char | unsafe_ctoon_is_null (void *val) |
| static unsigned char | unsafe_ctoon_is_bool (void *val) |
| static unsigned char | unsafe_ctoon_is_num (void *val) |
| static unsigned char | unsafe_ctoon_is_str (void *val) |
| static unsigned char | unsafe_ctoon_is_arr (void *val) |
| static unsigned char | unsafe_ctoon_is_obj (void *val) |
| static unsigned char | unsafe_ctoon_is_ctn (void *val) |
| static unsigned char | unsafe_ctoon_is_uint (void *val) |
| static unsigned char | unsafe_ctoon_is_sint (void *val) |
| static unsigned char | unsafe_ctoon_is_int (void *val) |
| static unsigned char | unsafe_ctoon_is_real (void *val) |
| static unsigned char | unsafe_ctoon_is_true (void *val) |
| static unsigned char | unsafe_ctoon_is_false (void *val) |
| static unsigned char | unsafe_ctoon_arr_is_flat (ctoon_val *val) |
| static const char * | unsafe_ctoon_get_raw (void *val) |
| static unsigned char | unsafe_ctoon_get_bool (void *val) |
| static uint64_t | unsafe_ctoon_get_uint (void *val) |
| static int64_t | unsafe_ctoon_get_sint (void *val) |
| static int | unsafe_ctoon_get_int (void *val) |
| static double | unsafe_ctoon_get_real (void *val) |
| static double | unsafe_ctoon_get_num (void *val) |
| static const char * | unsafe_ctoon_get_str (void *val) |
| static size_t | unsafe_ctoon_get_len (void *val) |
| static ctoon_val * | unsafe_ctoon_get_first (ctoon_val *ctn) |
| static ctoon_val * | unsafe_ctoon_get_next (ctoon_val *val) |
| static unsigned char | unsafe_ctoon_equals_strn (void *val, const char *str, size_t len) |
| static unsigned char | unsafe_ctoon_equals_str (void *val, const char *str) |
| static void | unsafe_ctoon_set_type (void *val, ctoon_type type, ctoon_subtype subtype) |
| static void | unsafe_ctoon_set_len (void *val, size_t len) |
| static void | unsafe_ctoon_set_tag (void *val, ctoon_type type, ctoon_subtype subtype, size_t len) |
| static void | unsafe_ctoon_inc_len (void *val) |
| static void | unsafe_ctoon_set_raw (void *val, const char *raw, size_t len) |
| static void | unsafe_ctoon_set_null (void *val) |
| static void | unsafe_ctoon_set_bool (void *val, unsigned char num) |
| static void | unsafe_ctoon_set_uint (void *val, uint64_t num) |
| static void | unsafe_ctoon_set_sint (void *val, int64_t num) |
| static void | unsafe_ctoon_set_fp_to_fixed (void *val, int prec) |
| static void | unsafe_ctoon_set_fp_to_float (void *val, unsigned char flt) |
| static void | unsafe_ctoon_set_float (void *val, float num) |
| static void | unsafe_ctoon_set_double (void *val, double num) |
| static void | unsafe_ctoon_set_real (void *val, double num) |
| static void | unsafe_ctoon_set_str_noesc (void *val, unsigned char noesc) |
| static void | unsafe_ctoon_set_strn (void *val, const char *str, size_t len) |
| static void | unsafe_ctoon_set_str (void *val, const char *str) |
| static void | unsafe_ctoon_set_arr (void *val, size_t size) |
| static void | unsafe_ctoon_set_obj (void *val, size_t size) |
| unsigned char | unsafe_ctoon_equals (ctoon_val *lhs, ctoon_val *rhs) |
| unsigned char | unsafe_ctoon_str_pool_grow (ctoon_str_pool *pool, const ctoon_alc *alc, size_t len) |
| unsigned char | unsafe_ctoon_val_pool_grow (ctoon_val_pool *pool, const ctoon_alc *alc, size_t count) |
| static char * | unsafe_ctoon_mut_str_alc (ctoon_mut_doc *doc, size_t len) |
| static char * | unsafe_ctoon_mut_strncpy (ctoon_mut_doc *doc, const char *str, size_t len) |
| static ctoon_mut_val * | unsafe_ctoon_mut_val (ctoon_mut_doc *doc, size_t count) |
| unsigned char | unsafe_ctoon_mut_equals (ctoon_mut_val *lhs, ctoon_mut_val *rhs) |
| static void | unsafe_ctoon_mut_obj_add (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val, size_t len) |
| static ctoon_mut_val * | unsafe_ctoon_mut_obj_remove (ctoon_mut_val *obj, const char *key, size_t key_len) |
| static unsigned char | unsafe_ctoon_mut_obj_replace (ctoon_mut_val *obj, ctoon_mut_val *key, ctoon_mut_val *val) |
| static void | unsafe_ctoon_mut_obj_rotate (ctoon_mut_val *obj, size_t idx) |
| ctoon_val * | unsafe_ctoon_ptr_getx (ctoon_val *val, const char *ptr, size_t len, ctoon_ptr_err *err) |
| ctoon_mut_val * | unsafe_ctoon_mut_ptr_getx (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| unsigned char | unsafe_ctoon_mut_ptr_putx (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_mut_doc *doc, unsigned char create_parent, unsigned char insert_new, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| ctoon_mut_val * | unsafe_ctoon_mut_ptr_replacex (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_mut_val *new_val, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| ctoon_mut_val * | unsafe_ctoon_mut_ptr_removex (ctoon_mut_val *val, const char *ptr, size_t len, ctoon_ptr_ctx *ctx, ctoon_ptr_err *err) |
| static unsigned char | ctoon_ptr_get_bool (ctoon_val *root, const char *ptr, unsigned char *value) |
| static unsigned char | ctoon_ptr_get_uint (ctoon_val *root, const char *ptr, uint64_t *value) |
| static unsigned char | ctoon_ptr_get_sint (ctoon_val *root, const char *ptr, int64_t *value) |
| static unsigned char | ctoon_ptr_get_real (ctoon_val *root, const char *ptr, double *value) |
| static unsigned char | ctoon_ptr_get_num (ctoon_val *root, const char *ptr, double *value) |
| static unsigned char | ctoon_ptr_get_str (ctoon_val *root, const char *ptr, const char **value) |
| static ctoon_val * | ctoon_doc_get_pointer (ctoon_doc *doc, const char *ptr) |
| static ctoon_val * | ctoon_doc_get_pointern (ctoon_doc *doc, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_doc_get_pointer (ctoon_mut_doc *doc, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_doc_get_pointern (ctoon_mut_doc *doc, const char *ptr, size_t len) |
| static ctoon_val * | ctoon_get_pointer (ctoon_val *val, const char *ptr) |
| static ctoon_val * | ctoon_get_pointern (ctoon_val *val, const char *ptr, size_t len) |
| static ctoon_mut_val * | ctoon_mut_get_pointer (ctoon_mut_val *val, const char *ptr) |
| static ctoon_mut_val * | ctoon_mut_get_pointern (ctoon_mut_val *val, const char *ptr, size_t len) |
| static ctoon_val * | unsafe_ctoon_get_pointer (ctoon_val *val, const char *ptr, size_t len) |
| static ctoon_mut_val * | unsafe_ctoon_mut_get_pointer (ctoon_mut_val *val, const char *ptr, size_t len) |
Definition in file ctoon.h.
| #define __bool_true_false_are_defined 1 |
| #define _CTOON_VERSION_STR | ( | a, | |
| b, | |||
| c | |||
| ) | _CTOON_VERSION_XSTR(a,b,c) |
| #define ctoon_api_inline static ctoon_inline |
| #define ctoon_arr_foreach | ( | arr, | |
| idx, | |||
| max, | |||
| val | |||
| ) |
Macro for iterating over an array. It works like iterator, but with a more intuitive API.
Example
| #define ctoon_has_attribute | ( | x | ) | 0 |
| #define ctoon_has_builtin | ( | x | ) | 0 |
| #define CTOON_HAS_CONSTANT_P 0 |
| #define ctoon_has_feature | ( | x | ) | 0 |
| #define ctoon_has_include | ( | x | ) | 0 |
| #define ctoon_mut_arr_foreach | ( | arr, | |
| idx, | |||
| max, | |||
| val | |||
| ) |
Macro for iterating over an array. It works like iterator, but with a more intuitive API.
Example
| #define ctoon_mut_arr_with_func | ( | func | ) |
| #define ctoon_mut_obj_add_func | ( | func | ) |
| #define ctoon_mut_obj_foreach | ( | obj, | |
| idx, | |||
| max, | |||
| key, | |||
| val | |||
| ) |
Macro for iterating over an object. It works like iterator, but with a more intuitive API.
Example
| #define ctoon_mut_val_one | ( | func | ) |
| #define ctoon_mut_val_one_str | ( | func | ) |
| #define ctoon_obj_foreach | ( | obj, | |
| idx, | |||
| max, | |||
| key, | |||
| val | |||
| ) |
Macro for iterating over an object. It works like iterator, but with a more intuitive API.
Example
| #define ctoon_ptr_set_err | ( | _code, | |
| _msg | |||
| ) |
| #define CTOON_RESERVED_BIT ((uint8_t)3) |
| #define CTOON_RESERVED_MASK ((uint8_t)0xE0) /* 111_____ */ |
| #define CTOON_SUBTYPE_BIT ((uint8_t)2) |
| #define CTOON_SUBTYPE_FALSE ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define CTOON_SUBTYPE_MASK ((uint8_t)0x18) /* ___11___ */ |
| #define CTOON_SUBTYPE_NOESC ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define CTOON_SUBTYPE_NONE ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define CTOON_SUBTYPE_REAL ((uint8_t)(2 << 3)) /* ___10___ */ |
| #define CTOON_SUBTYPE_SINT ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define CTOON_SUBTYPE_TRUE ((uint8_t)(1 << 3)) /* ___01___ */ |
| #define CTOON_SUBTYPE_UINT ((uint8_t)(0 << 3)) /* ___00___ */ |
| #define CTOON_TAG_BIT ((uint8_t)8) |
| #define CTOON_TAG_MASK ((uint8_t)0xFF) /* 11111111 */ |
| #define CTOON_TYPE_ARR ((uint8_t)6) /* _____110 */ |
| #define CTOON_TYPE_BIT ((uint8_t)3) |
| #define CTOON_TYPE_BOOL ((uint8_t)3) /* _____011 */ |
| #define CTOON_TYPE_MASK ((uint8_t)0x07) /* _____111 */ |
| #define CTOON_TYPE_NONE ((uint8_t)0) /* _____000 */ |
| #define CTOON_TYPE_NULL ((uint8_t)2) /* _____010 */ |
| #define CTOON_TYPE_NUM ((uint8_t)4) /* _____100 */ |
| #define CTOON_TYPE_OBJ ((uint8_t)7) /* _____111 */ |
| #define CTOON_TYPE_RAW ((uint8_t)1) /* _____001 */ |
| #define CTOON_TYPE_STR ((uint8_t)5) /* _____101 */ |
| #define CTOON_U64_TO_F64_NO_IMPL 0 |
| #define CTOON_VERSION CTOON_VERSION_ENCODE(CTOON_VERSION_MAJOR,CTOON_VERSION_MINOR,CTOON_VERSION_PATCH) |
| #define CTOON_VERSION_ENCODE | ( | maj, | |
| min, | |||
| pat | |||
| ) | (((maj)*10000)+((min)*100)+(pat)) |
| #define CTOON_VERSION_HEX ((CTOON_VERSION_MAJOR << 16) | (CTOON_VERSION_MINOR << 8) | CTOON_VERSION_PATCH) |
| #define CTOON_VERSION_STRING _CTOON_VERSION_STR(CTOON_VERSION_MAJOR,CTOON_VERSION_MINOR,CTOON_VERSION_PATCH) |
| #define CTOON_WRITE_FP_FLAG_BITS 8 |
| #define CTOON_WRITE_FP_TO_FIXED | ( | prec | ) |
Write floating-point as fixed notation with prec decimal places (1-15).
| #define CTOON_WRITE_FP_TO_FLOAT ((ctoon_write_flag)(1 << (32 - 5))) |
A memory allocator.
Typically you don't need to use it, unless you want to customize your own memory allocator.
| typedef struct ctoon_arr_iter ctoon_arr_iter |
A TOON array iterator.
Example
| typedef enum ctoon_delimiter ctoon_delimiter |
Array value delimiter used during encoding.
An immutable document for reading TOON. This document holds memory for all its TOON values and strings. When it is no longer used, the user should call ctoon_doc_free() to free its memory.
| typedef struct ctoon_incr_state ctoon_incr_state |
| typedef struct ctoon_mut_arr_iter ctoon_mut_arr_iter |
A mutable TOON array iterator.
ctoon_mut_arr_iter_remove() to remove current value.Example
| typedef struct ctoon_mut_doc ctoon_mut_doc |
A mutable document for building TOON. This document holds memory for all its TOON values and strings. When it is no longer used, the user should call ctoon_mut_doc_free() to free its memory.
| typedef struct ctoon_mut_obj_iter ctoon_mut_obj_iter |
A mutable TOON object iterator.
ctoon_mut_obj_iter_remove() to remove current value.Example
If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups:
ctoon_mut_obj_iter_get() and ctoon_mut_obj_iter_getn() | typedef struct ctoon_mut_val ctoon_mut_val |
| typedef struct ctoon_obj_iter ctoon_obj_iter |
A TOON object iterator.
Example
If the ordering of the keys is known at compile-time, you can use this method to speed up value lookups:
| typedef uint32_t ctoon_patch_code |
| typedef struct ctoon_patch_err ctoon_patch_err |
Error information for TOON patch.
| typedef uint32_t ctoon_ptr_code |
| typedef struct ctoon_ptr_ctx ctoon_ptr_ctx |
A context for TOON pointer operation.
This struct stores the context of TOON Pointer operation result. The struct can be used with three helper functions: ctx_append(), ctx_replace(), and ctx_remove(), which perform the corresponding operations on the container without re-parsing the TOON Pointer.
For example:
| typedef struct ctoon_ptr_err ctoon_ptr_err |
Error information for TOON pointer.
| typedef uint32_t ctoon_read_code |
| typedef struct ctoon_read_err ctoon_read_err |
Error information for TOON reader.
| typedef uint32_t ctoon_read_flag |
| typedef struct ctoon_str_chunk ctoon_str_chunk |
A memory chunk in string memory pool.
| typedef struct ctoon_str_pool ctoon_str_pool |
A memory pool to hold all strings in a mutable document.
| typedef uint8_t ctoon_subtype |
| typedef uint8_t ctoon_type |
| typedef struct ctoon_val_chunk ctoon_val_chunk |
A memory chunk in value memory pool. sizeof(ctoon_val_chunk) should not larger than sizeof(ctoon_mut_val).
| typedef struct ctoon_val_pool ctoon_val_pool |
A memory pool to hold all values in a mutable document.
| typedef union ctoon_val_uni ctoon_val_uni |
Payload of a TOON value (8 bytes).
| typedef uint32_t ctoon_write_code |
| typedef struct ctoon_write_err ctoon_write_err |
Error information for TOON writer.
| typedef uint32_t ctoon_write_flag |
| typedef struct ctoon_write_options ctoon_write_options |
Full options for ctoon_write_opts / ctoon_val_write_opts.
| enum ctoon_delimiter |
| void ctoon_alc_dyn_free | ( | ctoon_alc * | alc | ) |
Free a dynamic allocator which is created by ctoon_alc_dyn_new().
| alc | The dynamic allocator to be destroyed. |
| ctoon_alc * ctoon_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.
ctoon_alc_dyn_free().| unsigned char ctoon_alc_pool_init | ( | ctoon_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 TOON can be calculated using the ctoon_read_max_memory_usage() function, but the amount of memory required to write a TOON cannot be directly calculated.
This is not a general-purpose allocator. It is designed to handle a single TOON data at a time. If it is used for overly complex memory tasks, such as parsing multiple TOON documents using the same allocator but releasing only a few of them, it may cause memory fragmentation, resulting in performance degradation and memory waste.
| alc | The allocator to be initialized. If this parameter is NULL, the function will fail and return false. If buf or size is invalid, this will be set to an empty allocator. |
| buf | The buffer memory for this allocator. If this parameter is NULL, the function will fail and return false. |
| size | The size of buf, in bytes. If this parameter is less than 8 words (32/64 bytes on 32/64-bit OS), the function will fail and return false. |
alc has been successfully initialized.Example
|
static |
|
static |
Initialize an iterator for this array.
| arr | The array to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
iter has been successfully initialized.
|
static |
|
static |
Create an iterator with an array , same as ctoon_arr_iter_init().
| arr | The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. |
|
static |
|
static |
ctoon_doc_ptr_get ctoon_doc_ptr_getn
|
static |
|
static |
| ctoon_mut_doc * ctoon_doc_mut_copy | ( | ctoon_doc * | doc, |
| const ctoon_alc * | alc | ||
| ) |
Copies and returns a new mutable document from input, returns NULL on error. This makes a deep-copy on the immutable document. If allocator is NULL, the default allocator will be used.
imut_doc -> mut_doc. Get value by a TOON Pointer.
| doc | The TOON document to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
doc or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
Get value by a TOON Pointer.
| doc | The TOON document to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| err | A pointer to store the error information, or NULL if not needed. |
doc or ptr is NULL, or the TOON pointer cannot be resolved. | char * ctoon_doc_to_json | ( | const ctoon_doc * | doc, |
| int | indent, | ||
| ctoon_write_flag | flags, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Serialize a document to a JSON string.
The flags parameter accepts the same CTOON_WRITE_* flags used by the TOON writer (e.g. CTOON_WRITE_ESCAPE_UNICODE, CTOON_WRITE_ALLOW_INF_AND_NAN, CTOON_WRITE_INF_AND_NAN_AS_NULL). Note: flags that are TOON-specific (e.g. CTOON_WRITE_LENGTH_MARKER) are silently ignored.
| doc | The document to serialize. Must not be NULL. |
| indent | Spaces per indent level. 0 = compact (no whitespace). |
| flags | CTOON_WRITE_* flags (subset shared with JSON). |
| alc | Custom allocator, or NULL for the default. |
| len | If not NULL, receives the byte length of the result (not counting the null terminator). |
| err | If not NULL, receives error details on failure. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
ctoon_ptr_get ctoon_ptr_getn
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| void ctoon_incr_free | ( | ctoon_incr_state * | state | ) |
Release the incremental read state and free the memory.
| ctoon_incr_state * ctoon_incr_new | ( | char * | buf, |
| size_t | buf_len, | ||
| ctoon_read_flag | flg, | ||
| const ctoon_alc * | alc | ||
| ) |
Initialize state for incremental read.
To read a large TOON document incrementally:
ctoon_incr_new() to create the state for incremental reading.ctoon_incr_read() repeatedly.ctoon_incr_free() to free the state.Note: The incremental TOON reader only supports standard TOON. Flags for non-standard features (e.g. comments, trailing commas) are ignored.
| buf | The TOON data, null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. |
| buf_len | The length of the TOON data in buf. If use CTOON_READ_INSITU, buf_len should not include the padding size. |
| flg | The TOON read options. Multiple options can be combined with | operator. |
| alc | The memory allocator used by TOON reader. Pass NULL to use the libc's default allocator. |
ctoon_incr_free(). NULL is returned if memory allocation fails. | ctoon_doc * ctoon_incr_read | ( | ctoon_incr_state * | state, |
| size_t | len, | ||
| ctoon_read_err * | err | ||
| ) |
Performs incremental read of up to len bytes.
If NULL is returned and err->code is set to CTOON_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 CTOON_READ_ERROR_MORE is returned.
Note: Parsing in very small increments is not efficient. An increment of several kilobytes or megabytes is recommended.
| state | The state for incremental reading, created using ctoon_incr_new(). |
| len | The number of bytes of TOON data available to parse. If this parameter is 0, the function will fail and return NULL. |
| err | A pointer to receive error information. |
ctoon_doc_free().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| unsigned char ctoon_locate_pos | ( | const char * | str, |
| size_t | len, | ||
| size_t | pos, | ||
| size_t * | line, | ||
| size_t * | col, | ||
| size_t * | chr | ||
| ) |
Locate the line and column number for a byte position in a string. This can be used to get better description for error position.
| str | The input string. |
| len | The byte length of the input string. |
| pos | The byte position within the input string. |
| line | A pointer to receive the line number, starting from 1. |
| col | A pointer to receive the column number, starting from 1. |
| chr | A pointer to receive the character index, starting from 0. |
str is NULL or pos is out of bounds. | ctoon_mut_val * ctoon_merge_patch | ( | ctoon_mut_doc * | doc, |
| ctoon_val * | orig, | ||
| ctoon_val * | patch | ||
| ) |
Creates and returns a merge-patched TOON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Adds a signed integer value at the end of the array.
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
|
static |
Adds a string value at the end of the array (no copy).
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A null-terminated UTF-8 string. |
|
static |
Adds a string value at the end of the array (copied).
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A null-terminated UTF-8 string. |
|
static |
Adds a string value at the end of the array (no copy).
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A UTF-8 string, null-terminator is not required. |
| len | The length of the string, in bytes. |
|
static |
Adds a string value at the end of the array (copied).
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| str | A UTF-8 string, null-terminator is not required. |
| len | The length of the string, in bytes. |
|
static |
|
static |
Adds an unsigned integer value at the end of the array.
| doc | The doc is only used for memory allocation. |
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| num | The number to be added. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Inserts a value into an array at a given index.
| arr | The array to which the value is to be inserted. Returns false if it is NULL or not an array. |
| val | The value to be inserted. Returns false if it is NULL. |
| idx | The index to which to insert the new value. Returns false if the index is out of range. |
|
static |
|
static |
Initialize an iterator for this array.
| arr | The array to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
iter has been successfully initialized.
|
static |
|
static |
|
static |
Create an iterator with an array , same as ctoon_mut_arr_iter_init().
| arr | The array to be iterated over. If this parameter is NULL or not an array, an empty iterator will returned. |
|
static |
|
static |
Removes and returns a value at index.
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. |
| idx | The index from which to remove the value. Returns false if the index is out of range. |
|
static |
|
static |
|
static |
Removes all values within a specified range in the array.
| arr | The array from which the value is to be removed. Returns false if it is NULL or not an array. |
| idx | The start index of the range (0 is the first). |
| len | The number of items in the range (can be 0). |
|
static |
Replaces a value at index and returns old value.
| arr | The array to which the value is to be replaced. Returns false if it is NULL or not an array. |
| idx | The index to which to replace the value. Returns false if the index is out of range. |
| val | The new value to replace. Returns false if it is NULL. |
|
static |
|
static |
|
static |
Creates and returns a new mutable array with the given boolean values.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of boolean values. |
| count | The value count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given double numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of double numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given float numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of float numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given real numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of real numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given sint numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of sint numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given int16 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of int16 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given int32 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of int32 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given int64 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of int64 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given int8 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of int8 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given strings, these strings will not be copied.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. |
| count | The number of values in vals. If this value is 0, an empty array will return. |
ctoon_mut_arr_with_strcpy() instead.Example
|
static |
Creates and returns a new mutable array with the given strings, these strings will be copied.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 null-terminator strings. If this array contains NULL, the function will fail and return NULL. |
| count | The number of values in vals. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given strings and string lengths, these strings will not be copied.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. |
| lens | A C array of string lengths, in bytes. |
| count | The number of strings in vals. If this value is 0, an empty array will return. |
ctoon_mut_arr_with_strncpy() instead.Example
|
static |
Creates and returns a new mutable array with the given strings and string lengths, these strings will be copied.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of UTF-8 strings, null-terminator is not required. If this array contains NULL, the function will fail and return NULL. |
| lens | A C array of string lengths, in bytes. |
| count | The number of strings in vals. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given uint numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of uint numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given uint16 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of uint16 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given uint32 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of uint32 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given uint64 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of uint64 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
Creates and returns a new mutable array with the given uint8 numbers.
| doc | A mutable document, used for memory allocation only. If this parameter is NULL, the function will fail and return NULL. |
| vals | A C array of uint8 numbers. |
| count | The number count. If this value is 0, an empty array will return. |
Example
|
static |
| void ctoon_mut_doc_free | ( | ctoon_mut_doc * | doc | ) |
Release the TOON 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.
|
static |
ctoon_mut_doc_ptr_get
|
static |
ctoon_mut_doc_ptr_getn
|
static |
| ctoon_doc * ctoon_mut_doc_imut_copy | ( | ctoon_mut_doc * | doc, |
| const ctoon_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 ctoon_doc_free().
mut_doc -> imut_doc. | ctoon_mut_doc * ctoon_mut_doc_mut_copy | ( | ctoon_mut_doc * | doc, |
| const ctoon_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.
mut_doc -> mut_doc. | ctoon_mut_doc * ctoon_mut_doc_new | ( | const ctoon_alc * | alc | ) |
Creates and returns a new mutable TOON document, returns NULL on error. If allocator is NULL, the default allocator will be used.
|
static |
Add (insert) value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8 with null-terminator). |
| new_val | The value to be added. |
|
static |
Add (insert) value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be added. |
|
static |
Add (insert) value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be added. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
|
static |
Get value by a TOON Pointer.
| doc | The TOON document to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
doc or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
Get value by a TOON Pointer.
| doc | The TOON document to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
doc or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
|
static |
|
static |
Remove value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
|
static |
Replace value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
|
static |
Replace value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
Set value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8 with null-terminator). |
| new_val | The value to be set, pass NULL to remove. |
|
static |
Set value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
|
static |
Set value by a TOON pointer.
| doc | The target TOON document. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
| unsigned char ctoon_mut_doc_set_str_pool_size | ( | ctoon_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 ctoon_mut_strcpy function), setting a larger size can avoid multiple memory allocations and improve performance.
| doc | The mutable document. |
| len | The desired string pool size in bytes (total string length). |
| unsigned char ctoon_mut_doc_set_val_pool_size | ( | ctoon_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 ctoon_mut_xxx functions), setting a larger size can avoid multiple memory allocations and improve performance.
| doc | The mutable document. |
| count | The desired value pool size (number of ctoon_mut_val). |
| char * ctoon_mut_doc_to_json | ( | const ctoon_mut_doc * | doc, |
| int | indent, | ||
| ctoon_write_flag | flags, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Serialize a mutable document to a JSON string.
Internally converts the mutable circular-linked-list layout to the flat immutable arena layout (one O(n) pass), then serializes. Prefer ctoon_doc_to_json / ctoon_write_json when the document is already immutable to avoid the extra copy.
| doc | The mutable document to serialize. Must not be NULL. |
| indent | Spaces per indent level. 0 = compact (no whitespace). |
| flags | CTOON_WRITE_* flags (subset shared with JSON). |
| alc | Custom allocator, or NULL for the default. |
| len | If not NULL, receives the byte length of the result (not counting the null terminator). |
| err | If not NULL, receives error details on failure. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
ctoon_mut_ptr_get
|
static |
ctoon_mut_ptr_getn
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| ctoon_mut_val * ctoon_mut_merge_patch | ( | ctoon_mut_doc * | doc, |
| ctoon_mut_val * | orig, | ||
| ctoon_mut_val * | patch | ||
| ) |
Creates and returns a merge-patched TOON value (RFC 7386). The memory of the returned value is allocated by the doc. Returns NULL if the patch could not be applied.
|
static |
|
static |
|
static |
Adds a key-value pair at the end of the object. This function allows duplicated key in one object.
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by ctoon_mut_str(), ctoon_mut_strn(), ctoon_mut_strcpy() or ctoon_mut_strncpy(). |
| val | The value to add to the object. |
|
static |
Creates and adds a new array to the target object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a bool value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a double value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a false value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a float value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds an int value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a null value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Creates and adds a new object to the target object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a real value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a signed integer value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a string value at the end of the object. The key and val should be null-terminated UTF-8 strings. This function allows duplicated key in one object.
|
static |
Adds a string value at the end of the object. The key and val should be null-terminated UTF-8 strings. The value string is copied. This function allows duplicated key in one object.
|
static |
Adds a string value at the end of the object. The key should be a null-terminated UTF-8 string. The val should be a UTF-8 string, null-terminator is not required. The len should be the length of the val, in bytes. This function allows duplicated key in one object.
|
static |
Adds a string value at the end of the object. The key should be a null-terminated UTF-8 string. The val should be a UTF-8 string, null-terminator is not required. The len should be the length of the val, in bytes. This function allows duplicated key in one object.
|
static |
Adds a true value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds an unsigned integer value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
Adds a TOON value at the end of the object. The key should be a null-terminated UTF-8 string. This function allows duplicated key in one object.
|
static |
|
static |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a null-terminated UTF-8 string.
|
static |
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a UTF-8 string, null-terminator is not required. The key_len should be the length of the key, in bytes.
|
static |
Inserts a key-value pair to the object at the given position. This function allows duplicated key in one object.
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by ctoon_mut_str(), ctoon_mut_strn(), ctoon_mut_strcpy() or ctoon_mut_strncpy(). |
| val | The value to add to the object. |
| idx | The index to which to insert the new pair. |
|
static |
Iterates to a specified key and returns the value.
This function does the same thing as ctoon_mut_obj_get(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string with null-terminator. |
|
static |
|
static |
Iterates to a specified key and returns the value.
This function does the same thing as ctoon_mut_obj_getn() but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string, null-terminator is not required. |
| key_len | The the length of key, in bytes. |
|
static |
|
static |
Initialize an iterator for this object.
| obj | The object to be iterated over. If this parameter is NULL or not an array, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
iter has been successfully initialized.
|
static |
|
static |
|
static |
Create an iterator with an object, same as ctoon_obj_iter_init().
| obj | The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. |
|
static |
Sets a key-value pair at the end of the object. This function may remove all key-value pairs for the given key before add.
| obj | The object to which the new key-value pair is to be added. |
| key | The key, should be a string which is created by ctoon_mut_str(), ctoon_mut_strn(), ctoon_mut_strcpy() or ctoon_mut_strncpy(). |
| val | The value to add to the object. If this value is null, the behavior is same as ctoon_mut_obj_remove(). |
|
static |
Removes all key-value pair from the object with given key.
| obj | The object from which the key-value pair is to be removed. |
| key | The key, should be a string value. |
|
static |
Removes all key-value pair from the object with given key.
| obj | The object from which the key-value pair is to be removed. |
| key | The key, should be a UTF-8 string with null-terminator. |
|
static |
Removes all key-value pair from the object with given key.
| obj | The object from which the key-value pair is to be removed. |
| key | The key, should be a UTF-8 string, null-terminator is not required. |
| key_len | The length of the key. |
|
static |
Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The key should be a null-terminated UTF-8 string.
|
static |
Removes all key-value pairs for the given key. Returns the first value to which the specified key is mapped or NULL if this object contains no mapping for the key. The key should be a UTF-8 string, null-terminator is not required. The len should be the length of the key, in bytes.
|
static |
Replaces all matching keys with the new key. Returns true if at least one key was renamed. The key and new_key should be a null-terminated UTF-8 string. The new_key is copied and held by doc.
new_key already exists, it will cause duplicate keys.
|
static |
Replaces all matching keys with the new key. Returns true if at least one key was renamed. The key and new_key should be a UTF-8 string, null-terminator is not required. The new_key is copied and held by doc.
new_key already exists, it will cause duplicate keys.
|
static |
Replaces value from the object with given key. If the key is not exist, or the value is NULL, it will fail.
| obj | The object to which the value is to be replaced. |
| key | The key, should be a string value. |
| val | The value to replace into the object. |
|
static |
Rotates key-value pairs in the object for the given number of times. For example: {"a":1,"b":2,"c":3,"d":4} rotate 1 is {"b":2,"c":3,"d":4,"a":1}.
| obj | The object to be rotated. |
| idx | Index (or times) to rotate. |
|
static |
|
static |
Creates and returns a mutable object with key-value pairs and pair count, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string.
Example
|
static |
Creates and returns a mutable object with keys and values, returns NULL on error. The keys and values are not copied. The strings should be a null-terminated UTF-8 string.
Example
| ctoon_mut_val * ctoon_mut_patch | ( | ctoon_mut_doc * | doc, |
| ctoon_mut_val * | orig, | ||
| ctoon_mut_val * | patch, | ||
| ctoon_patch_err * | err | ||
| ) |
Creates and returns a patched TOON 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.
|
static |
Add (insert) value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8 with null-terminator). |
| doc | Only used to create new values when needed. |
| new_val | The value to be added. |
|
static |
Add (insert) value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| doc | Only used to create new values when needed. |
| new_val | The value to be added. |
|
static |
Add (insert) value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| doc | Only used to create new values when needed. |
| new_val | The value to be added. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
|
static |
Get value by a TOON Pointer.
| val | The TOON value to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
val or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
Get value by a TOON Pointer.
| val | The TOON value to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
val or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
|
static |
|
static |
Remove value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
|
static |
Replace value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
|
static |
Replace value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The new value to replace the old one. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
Set value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8 with null-terminator). |
| new_val | The value to be set, pass NULL to remove. |
| doc | Only used to create new values when needed. |
|
static |
Set value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| doc | Only used to create new values when needed. |
|
static |
Set value by a TOON pointer.
| val | The target TOON value. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| new_val | The value to be set, pass NULL to remove. |
| doc | Only used to create new values when needed. |
| create_parent | Whether to create parent nodes if not exist. |
| ctx | A pointer to store the result context, or NULL if not needed. |
| err | A pointer to store the error information, or NULL if not needed. |
|
static |
|
static |
|
static |
|
static |
|
static |
Same as ctoon_read_number().
Definition at line 1178 of file ctoon.h.
References ctoon_read_number().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Set the floating-point number's output format to fixed-point notation. Returns false if input is NULL or val is not real type.
immutable value, use with caution.
|
static |
Set the floating-point number's output format to single-precision. Returns false if input is NULL or val is not real type.
immutable value, use with caution.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Marks this string as not needing to be escaped during TOON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if input is NULL or val is not string.
immutable value, use with caution.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| ctoon_doc * ctoon_mut_val_imut_copy | ( | ctoon_mut_val * | val, |
| const ctoon_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 ctoon_doc_free().
mut_val -> imut_doc. | ctoon_mut_val * ctoon_mut_val_mut_copy | ( | ctoon_mut_doc * | doc, |
| ctoon_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 was managed by mutable document.
mut_val -> mut_val.
|
static |
Definition at line 1345 of file ctoon.h.
References ctoon_mut_val_write_opts().
| char * ctoon_mut_val_write_opts | ( | const ctoon_mut_val * | val, |
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Referenced by ctoon_mut_val_write().
|
static |
Definition at line 1323 of file ctoon.h.
References ctoon_mut_write_opts().
| unsigned char ctoon_mut_write_file | ( | const char * | path, |
| const ctoon_mut_doc * | doc, | ||
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| ctoon_write_err * | err | ||
| ) |
| unsigned char ctoon_mut_write_fp | ( | FILE * | fp, |
| const ctoon_mut_doc * | doc, | ||
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| ctoon_write_err * | err | ||
| ) |
| char * ctoon_mut_write_opts | ( | const ctoon_mut_doc * | doc, |
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Write a mutable document to TOON string with full options.
Referenced by ctoon_mut_write().
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a null-terminated UTF-8 string.
Returns the value to which the specified key is mapped. Returns NULL if this object contains no mapping for the key. Returns NULL if obj/key is NULL, or type is not object.
The key should be a UTF-8 string, null-terminator is not required. The key_len should be the length of the key, in bytes.
|
static |
Iterates to a specified key and returns the value.
This function does the same thing as ctoon_obj_get(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string with null-terminator. |
|
static |
Iterates to a specified key and returns the value.
This function does the same thing as ctoon_obj_getn(), but is much faster if the ordering of the keys is known at compile-time and you are using the same order to look up the values. If the key exists in this object, then the iterator will stop at the next key, otherwise the iterator will not change and NULL is returned.
| iter | The object iterator, should not be NULL. |
| key | The key, should be a UTF-8 string, null-terminator is not required. |
| key_len | The the length of key, in bytes. |
|
static |
|
static |
Initialize an iterator for this object.
| obj | The object to be iterated over. If this parameter is NULL or not an object, iter will be set to empty. |
| iter | The iterator to be initialized. If this parameter is NULL, the function will fail and return false. |
iter has been successfully initialized.
|
static |
|
static |
Create an iterator with an object, same as ctoon_obj_iter_init().
| obj | The object to be iterated over. If this parameter is NULL or not an object, an empty iterator will returned. |
|
static |
| ctoon_mut_val * ctoon_patch | ( | ctoon_mut_doc * | doc, |
| ctoon_val * | orig, | ||
| ctoon_val * | patch, | ||
| ctoon_patch_err * | err | ||
| ) |
Creates and returns a patched TOON 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.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Get value by a TOON Pointer.
| val | The TOON value to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
val or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
Get value by a TOON Pointer.
| val | The TOON value to be queried. |
| ptr | The TOON pointer string (UTF-8, null-terminator is not required). |
| len | The length of ptr in bytes. |
| err | A pointer to store the error information, or NULL if not needed. |
val or ptr is NULL, or the TOON pointer cannot be resolved.
|
static |
Read a TOON string.
This function is thread-safe.
| dat | The TOON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. |
| len | The length of TOON data in bytes. If this parameter is 0, the function will fail and return NULL. |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. |
ctoon_doc_free(). Definition at line 1023 of file ctoon.h.
References ctoon_read_opts().
| ctoon_doc * ctoon_read_file | ( | const char * | path, |
| ctoon_read_flag | flg, | ||
| const ctoon_alc * | alc, | ||
| ctoon_read_err * | err | ||
| ) |
Read a TOON file.
This function is thread-safe when:
alc is thread-safe or NULL.| path | The TOON file's path. This should be a null-terminated string using the system's native encoding. If this path is NULL or invalid, the function will fail and return NULL. |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by TOON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ctoon_doc_free().| ctoon_doc * ctoon_read_fp | ( | FILE * | fp, |
| ctoon_read_flag | flg, | ||
| const ctoon_alc * | alc, | ||
| ctoon_read_err * | err | ||
| ) |
Read TOON from a file pointer.
| fp | The file pointer. The data will be read from the current position of the FILE to the end. If this fp is NULL or invalid, the function will fail and return NULL. |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by TOON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ctoon_doc_free().
|
static |
Returns the size of maximum memory usage to read a TOON data.
You may use this value to avoid malloc() or calloc() call inside the reader to get better performance, or read multiple TOON with one piece of memory.
| len | The length of TOON data in bytes. |
| flg | The TOON read options. |
Example
Definition at line 1130 of file ctoon.h.
References CTOON_READ_INSITU, and CTOON_READ_STOP_WHEN_DONE.
| const char * ctoon_read_number | ( | const char * | dat, |
| ctoon_val * | val, | ||
| ctoon_read_flag | flg, | ||
| const ctoon_alc * | alc, | ||
| ctoon_read_err * | err | ||
| ) |
Read a TOON number.
This function is thread-safe when data is not modified by other threads.
| dat | The TOON data (UTF-8 without BOM), null-terminator is required. If this parameter is NULL, the function will fail and return NULL. |
| val | The output value where result is stored. If this parameter is NULL, the function will fail and return NULL. The value will hold either UINT or SINT or REAL number; |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. Supports CTOON_READ_NUMBER_AS_RAW and CTOON_READ_ALLOW_INF_AND_NAN. |
| alc | The memory allocator used for long number. It is only used when the built-in floating point reader is disabled. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
Referenced by ctoon_mut_read_number().
| ctoon_doc * ctoon_read_opts | ( | char * | dat, |
| size_t | len, | ||
| ctoon_read_flag | flg, | ||
| const ctoon_alc * | alc, | ||
| ctoon_read_err * | err | ||
| ) |
Read TOON with options.
This function is thread-safe when:
dat is not modified by other threads.alc is thread-safe or NULL.| dat | The TOON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. The dat will not be modified without the flag CTOON_READ_INSITU, so you can pass a const char * string and case it to char * if you don't use the CTOON_READ_INSITU flag. |
| len | The length of TOON data in bytes. If this parameter is 0, the function will fail and return NULL. |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. |
| alc | The memory allocator used by TOON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ctoon_doc_free(). Referenced by ctoon_read().
| ctoon_doc * ctoon_read_opts_indent | ( | char * | dat, |
| size_t | len, | ||
| ctoon_read_flag | flg, | ||
| int | indent_size, | ||
| const ctoon_alc * | alc, | ||
| ctoon_read_err * | err | ||
| ) |
Read TOON with options and a custom indent size (spec §12 "indentSize").
Same as ctoon_read_opts(), but lets the caller override the number of spaces that count as one indentation level when decoding (default 2, and what ctoon_read_opts() always uses). Pass indent_size <= 0 to fall back to the default of 2.
| dat | The TOON data (UTF-8 without BOM), null-terminator is not required. If this parameter is NULL, the function will fail and return NULL. The dat will not be modified without the flag CTOON_READ_INSITU, so you can pass a const char * string and case it to char * if you don't use the CTOON_READ_INSITU flag. |
| len | The length of TOON data in bytes. If this parameter is 0, the function will fail and return NULL. |
| flg | The TOON read options. Multiple options can be combined with | operator. 0 means no options. |
| indent_size | Spaces per indentation level. Must match how the document being read was actually indented, or depths will be computed incorrectly (or, in strict mode, indentation that isn't an exact multiple of this value is rejected). |
| alc | The memory allocator used by TOON reader. Pass NULL to use the libc's default allocator. |
| err | A pointer to receive error information. Pass NULL if you don't need error information. |
ctoon_doc_free().
|
static |
|
static |
|
static |
|
static |
Set the floating-point number's output format to fixed-point notation. Returns false if input is NULL or val is not real type.
immutable value, use with caution.
|
static |
Set the floating-point number's output format to single-precision. Returns false if input is NULL or val is not real type.
immutable value, use with caution.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Marks this string as not needing to be escaped during TOON writing. This can be used to avoid the overhead of escaping if the string contains only characters that do not require escaping. Returns false if input is NULL or val is not string.
immutable value, use with caution.
|
static |
|
static |
| ctoon_mut_val * ctoon_val_mut_copy | ( | ctoon_mut_doc * | doc, |
| ctoon_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 was managed by mutable document.
imut_val -> mut_val.
|
static |
Definition at line 1312 of file ctoon.h.
References ctoon_val_write_opts().
| char * ctoon_val_write_opts | ( | const ctoon_val * | val, |
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Write a single value (not a full document) to TOON string with options.
Referenced by ctoon_val_write().
| uint32_t ctoon_version | ( | void | ) |
The version of ctoon in hex, same as CTOON_VERSION_HEX.
|
static |
Write a document with default options (indent=2, comma delimiter).
Definition at line 1287 of file ctoon.h.
References ctoon_write_opts().
| unsigned char ctoon_write_file | ( | const char * | path, |
| const ctoon_doc * | doc, | ||
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| ctoon_write_err * | err | ||
| ) |
Write a document to file with full options.
| unsigned char ctoon_write_fp | ( | FILE * | fp, |
| const ctoon_doc * | doc, | ||
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| ctoon_write_err * | err | ||
| ) |
Write a document to file pointer with full options.
| char * ctoon_write_number | ( | const ctoon_val * | val, |
| char * | buf | ||
| ) |
Write a TOON number value to a buffer (at least 40 bytes).
| char * ctoon_write_opts | ( | const ctoon_doc * | doc, |
| const ctoon_write_options * | opts, | ||
| const ctoon_alc * | alc, | ||
| size_t * | len, | ||
| ctoon_write_err * | err | ||
| ) |
Write a document to TOON string with full options.
| doc | The TOON document. |
| opts | Write options (NULL = defaults: indent=2, comma delimiter). |
| alc | Allocator, or NULL for libc default. |
| len | Receives output byte length (not including null-terminator); may be NULL. |
| err | Receives error info; may be NULL. |
Referenced by ctoon_write().
|
static |
|
static |
|
static |
|
static |
|
static |
ctoon_mut_ptr_getn
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 4575 of file ctoon.h.
References ctoon_constant_p.
|
static |
|
static |
| unsigned char unsafe_ctoon_mut_equals | ( | ctoon_mut_val * | lhs, |
| ctoon_mut_val * | rhs | ||
| ) |
|
static |
unsafe_ctoon_mut_ptr_getx
|
static |
|
static |
|
static |
|
static |
| ctoon_mut_val * unsafe_ctoon_mut_ptr_getx | ( | ctoon_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| ctoon_ptr_ctx * | ctx, | ||
| ctoon_ptr_err * | err | ||
| ) |
| unsigned char unsafe_ctoon_mut_ptr_putx | ( | ctoon_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| ctoon_mut_val * | new_val, | ||
| ctoon_mut_doc * | doc, | ||
| unsigned char | create_parent, | ||
| unsigned char | insert_new, | ||
| ctoon_ptr_ctx * | ctx, | ||
| ctoon_ptr_err * | err | ||
| ) |
| ctoon_mut_val * unsafe_ctoon_mut_ptr_removex | ( | ctoon_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| ctoon_ptr_ctx * | ctx, | ||
| ctoon_ptr_err * | err | ||
| ) |
| ctoon_mut_val * unsafe_ctoon_mut_ptr_replacex | ( | ctoon_mut_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| ctoon_mut_val * | new_val, | ||
| ctoon_ptr_ctx * | ctx, | ||
| ctoon_ptr_err * | err | ||
| ) |
|
static |
|
static |
|
static |
| ctoon_val * unsafe_ctoon_ptr_getx | ( | ctoon_val * | val, |
| const char * | ptr, | ||
| size_t | len, | ||
| ctoon_ptr_err * | err | ||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| unsigned char unsafe_ctoon_str_pool_grow | ( | ctoon_str_pool * | pool, |
| const ctoon_alc * | alc, | ||
| size_t | len | ||
| ) |
|
static |
| unsigned char unsafe_ctoon_val_pool_grow | ( | ctoon_val_pool * | pool, |
| const ctoon_alc * | alc, | ||
| size_t | count | ||
| ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Allow extended escape sequences in strings (non-standard):
\a, \e, \v, \', \?, \0.\xNN, such as \x7B.\1-\9 will still trigger an error.
|
static |
|
static |
|
static |
|
static |
Allow reading invalid unicode when parsing string values (non-standard). Invalid characters will be allowed to appear in the string values, but invalid escape sequences will still be reported as errors. This flag does not affect the performance of correctly encoded strings.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Read the input data in-situ. This option allows the reader to modify and use input data to store string values, which can increase reading speed slightly. The caller should hold the input data before free the document. The input data must be padded by at least CTOON_PADDING_SIZE bytes. For example: [1,2] should be [1,2]\0\0\0\0, input length should be 5.
Definition at line 743 of file ctoon.h.
Referenced by ctoon_read_max_memory_usage().
|
static |
Default option (RFC 8259 compliant):
|
static |
|
static |
Stop when done instead of issuing an error if there's additional content after a TOON document. This option may be used to parse small pieces of TOON in larger data, such as NDTOON.
Definition at line 748 of file ctoon.h.
Referenced by ctoon_read_max_memory_usage().
|
static |
|
static |
Allow TOON5 format, see: [https://json5.org]. This flag supports all TOON5 features with some additional extensions:
\a, \e).NaN, Inf and Infinity literals.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |