3#if !defined(WANDERINGHORSE_NET_CSON_H_INCLUDED)
4#define WANDERINGHORSE_NET_CSON_H_INCLUDED 1
36#if defined(__cplusplus)
40#if defined(_WIN32) || defined(_WIN64)
41# define CSON_ENABLE_UNIX 0
43# define CSON_ENABLE_UNIX 1
53typedef __int64 cson_int_t;
54#define CSON_INT_T_SFMT "I64d"
55#define CSON_INT_T_PFMT "I64d"
56#elif (__STDC_VERSION__ >= 199901L) || (HAVE_LONG_LONG == 1)
57typedef long long cson_int_t;
58#define CSON_INT_T_SFMT "lld"
59#define CSON_INT_T_PFMT "lld"
61typedef long cson_int_t;
62#define CSON_INT_T_SFMT "ld"
63#define CSON_INT_T_PFMT "ld"
89#if defined(HAVE_LONG_DOUBLE)
90 typedef long double cson_double_t;
91# ifndef CSON_DOUBLE_T_SFMT
92# define CSON_DOUBLE_T_SFMT "Lf"
94# ifndef CSON_DOUBLE_T_PFMT
95# define CSON_DOUBLE_T_PFMT "Lf"
98 typedef double cson_double_t;
99# ifndef CSON_DOUBLE_T_SFMT
100# define CSON_DOUBLE_T_SFMT "f"
102# ifndef CSON_DOUBLE_T_PFMT
103# define CSON_DOUBLE_T_PFMT "f"
124#if !defined(CSON_VOID_PTR_IS_BIG)
130# if defined(_WIN64) || defined(__LP64__) \
131 || defined(_M_X64) || defined(__amd64__) || defined(__amd64) \
132 || defined(__x86_64__) || defined(__x86_64) \
133 || defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) \
134 || defined(_M_IA64) \
135 || defined(__sparc_v9__) || defined(__sparcv9) || defined(_ADDR64) \
136 || defined(__64BIT__)
137# define CSON_VOID_PTR_IS_BIG 1
139# define CSON_VOID_PTR_IS_BIG 0
189 CSON_TYPE_INTEGER = 3,
194 CSON_TYPE_DOUBLE = 4,
198 CSON_TYPE_STRING = 5,
207typedef enum cson_type_id cson_type_id;
324static const struct cson_rc_
331 const int RangeError;
337 const int AllocError;
341 const int InternalError;
346 const int UnsupportedError;
350 const int NotFoundError;
356 const int UnknownError;
360 const int Parse_INVALID_CHAR;
365 const int Parse_INVALID_KEYWORD;
369 const int Parse_INVALID_ESCAPE_SEQUENCE;
374 const int Parse_INVALID_UNICODE_SEQUENCE;
378 const int Parse_INVALID_NUMBER;
383 const int Parse_NESTING_DEPTH_REACHED;
387 const int Parse_UNBALANCED_COLLECTION;
391 const int Parse_EXPECTED_KEY;
396 const int Parse_EXPECTED_COLON;
427char const * cson_rc_string(
int rc);
451#define cson_parse_opt_empty_m { 25, 0}
496#define cson_parse_info_empty_m {1,\
579#define cson_output_opt_empty_m { 0,\
616typedef int (*cson_data_source_f)(
void * state,
void * dest,
unsigned int * n );
639typedef int (*cson_data_dest_f)(
void * state,
void const * src,
unsigned int n );
730int cson_parse(
cson_value ** tgt, cson_data_source_f src,
void * srcState,
736int cson_data_source_FILE(
void * state,
void * dest,
unsigned int * n );
743int cson_parse_FILE(
cson_value ** tgt, FILE * src,
753int cson_parse_filename(
cson_value ** tgt,
char const * src,
766int cson_parse_string(
cson_value ** tgt,
char const * src,
unsigned int len,
804int cson_data_dest_FILE(
void * state,
void const * src,
unsigned int n );
826cson_type_id cson_value_type_id(
cson_value const * v );
830char cson_value_is_undef(
cson_value const * v );
832char cson_value_is_null(
cson_value const * v );
834char cson_value_is_bool(
cson_value const * v );
836char cson_value_is_integer(
cson_value const * v );
838char cson_value_is_double(
cson_value const * v );
840char cson_value_is_number(
cson_value const * v );
842char cson_value_is_string(
cson_value const * v );
844char cson_value_is_array(
cson_value const * v );
846char cson_value_is_object(
cson_value const * v );
938int cson_value_fetch_bool(
cson_value const * val,
char * v );
956int cson_value_fetch_integer(
cson_value const * val, cson_int_t * v );
963int cson_value_fetch_double(
cson_value const * val, cson_double_t * v );
1027char cson_value_get_bool(
cson_value const * val );
1033cson_int_t cson_value_get_integer(
cson_value const * val );
1039cson_double_t cson_value_get_double(
cson_value const * val );
1058char const * cson_string_cstr(
cson_string const * str );
1068char const * cson_value_get_cstr(
cson_value const * val );
1098int cson_string_cmp_cstr_n(
cson_string const * lhs,
char const * rhs,
unsigned int rhsLen );
1103int cson_string_cmp_cstr(
cson_string const * lhs,
char const * rhs );
1114unsigned int cson_string_length_bytes(
cson_string const * str );
1123unsigned int cson_string_length_utf8(
cson_string const * str );
1130char * cson_value_get_string_copy(
cson_value const * val );
1183int cson_array_reserve(
cson_array * ar,
unsigned int size );
1189int cson_array_length_fetch(
cson_array const * ar,
unsigned int * v );
1195unsigned int cson_array_length_get(
cson_array const * ar );
1303cson_value * cson_value_new_integer( cson_int_t v );
1313cson_value * cson_value_new_double( cson_double_t v );
1318cson_value * cson_new_double(cson_double_t v);
1333cson_value * cson_value_new_string(
char const * str,
unsigned int n );
1374cson_string * cson_new_string(
char const * val,
unsigned int len);
1622int cson_object_fetch_sub(
cson_object const * obj,
cson_value ** tgt,
char const * path,
char separator );
1652enum CSON_MERGE_FLAGS {
1653 CSON_MERGE_DEFAULT = 0,
1654 CSON_MERGE_REPLACE = 0x01,
1655 CSON_MERGE_NO_RECURSE = 0x02
1716#define cson_object_iterator_empty_m {NULL,0}
1798typedef unsigned int cson_size_t;
1874#define cson_buffer_empty_m {0,0,0,NULL}
1965int cson_buffer_reserve(
cson_buffer * buf, cson_size_t n );
1972cson_size_t cson_buffer_fill(
cson_buffer * buf,
char c );
2045int cson_buffer_fill_from(
cson_buffer * dest, cson_data_source_f src,
void * state );
2145int cson_value_add_reference(
cson_value * v );
2159int cson_value_refcount_set(
cson_value * v,
unsigned short rc );
2264unsigned int cson_value_msize(
cson_value const * v);
2316int cson_parse_argv_flags(
int argc,
char const *
const * argv,
2387#if defined(__cplusplus)
cson_array is an opaque handle to an Array value.
unsigned char * mem
The memory allocated for and owned by this buffer.
cson_size_t used
The number of bytes "used" by this object.
cson_size_t timesExpanded
This is a debugging/metric-counting value intended to help certain malloc()-conscious clients tweak t...
cson_size_t capacity
The number of bytes allocated for this object.
A key/value pair collection.
An iterator type for traversing object properties.
cson_object is an opaque handle to an Object value.
Client-configurable options for the cson_output() family of functions.
unsigned short maxDepth
Maximum object/array depth to traverse.
char addSpaceAfterColon
If true, a space will be added after the colon operator in objects' key/value pairs.
char addNewline
If true, a newline will be added to generated output, else not.
char indentSingleMemberValues
If set to 1 then objects/arrays containing only a single value will not indent an extra level for tha...
char escapeForwardSlashes
The JSON format allows, but does not require, JSON generators to backslash-escape forward slashes.
unsigned char indentation
Specifies how to indent (or not) output.
A class for holding JSON parser information.
unsigned int length
Length, in bytes.
unsigned int totalValueCount
The total number of object/array values successfully processed by the parser, including the root node...
unsigned int col
0-based column number.
int errorCode
Error code of the parse run (0 for no error).
unsigned int line
1-based line number.
unsigned int totalKeyCount
The total number of object keys successfully processed by the parser.
Client-configurable options for the cson_parse() family of functions.
char allowComments
Whether or not to allow C-style comments.
unsigned short maxDepth
Maximum object/array depth to traverse.
Strings are allocated as an instances of this class with N+1 trailing bytes, where N is the length of...
The core value type of this API.