123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- #ifndef cJSON__h
- #define cJSON__h
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
- #define __WINDOWS__
- #endif
- #ifdef __WINDOWS__
- #define CJSON_CDECL __cdecl
- #define CJSON_STDCALL __stdcall
- #if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS)
- #define CJSON_EXPORT_SYMBOLS
- #endif
- #if defined(CJSON_HIDE_SYMBOLS)
- #define CJSON_PUBLIC(type) type CJSON_STDCALL
- #elif defined(CJSON_EXPORT_SYMBOLS)
- #define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL
- #elif defined(CJSON_IMPORT_SYMBOLS)
- #define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL
- #endif
- #else /* !__WINDOWS__ */
- #define CJSON_CDECL
- #define CJSON_STDCALL
- #if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY)
- #define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type
- #else
- #define CJSON_PUBLIC(type) type
- #endif
- #endif
- #define CJSON_VERSION_MAJOR 1
- #define CJSON_VERSION_MINOR 7
- #define CJSON_VERSION_PATCH 15
- #include <stddef.h>
- #define cJSON_Invalid (0)
- #define cJSON_False (1 << 0)
- #define cJSON_True (1 << 1)
- #define cJSON_NULL (1 << 2)
- #define cJSON_Number (1 << 3)
- #define cJSON_String (1 << 4)
- #define cJSON_Array (1 << 5)
- #define cJSON_Object (1 << 6)
- #define cJSON_Raw (1 << 7) /* raw json */
- #define cJSON_IsReference 256
- #define cJSON_StringIsConst 512
- typedef struct cJSON
- {
-
- struct cJSON *next;
- struct cJSON *prev;
-
- struct cJSON *child;
-
- int type;
-
- char *valuestring;
-
- int valueint;
-
- double valuedouble;
-
- char *string;
- } cJSON;
- typedef struct cJSON_Hooks
- {
-
- void *(CJSON_CDECL *malloc_fn)(size_t sz);
- void (CJSON_CDECL *free_fn)(void *ptr);
- } cJSON_Hooks;
- typedef int cJSON_bool;
- #ifndef CJSON_NESTING_LIMIT
- #define CJSON_NESTING_LIMIT 1000
- #endif
- CJSON_PUBLIC(const char*) cJSON_Version(void);
- CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks);
- CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value);
- CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length);
- CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated);
- CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated);
- CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item);
- CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item);
- CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt);
- CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format);
- CJSON_PUBLIC(void) cJSON_Delete(cJSON *item);
- CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
- CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
- CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);
- CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string);
- CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string);
- CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
- CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
- CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item);
- CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item);
- CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void);
- CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void);
- CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void);
- CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean);
- CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num);
- CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string);
- CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw);
- CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void);
- CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void);
- CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string);
- CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child);
- CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child);
- CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count);
- CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count);
- CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count);
- CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count);
- CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item);
- CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item);
- CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item);
- CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
- CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item);
- CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item);
- CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which);
- CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which);
- CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string);
- CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string);
- CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string);
- CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string);
- CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem);
- CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement);
- CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
- CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
- CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem);
- CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse);
- CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive);
- CJSON_PUBLIC(void) cJSON_Minify(char *json);
- CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name);
- CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name);
- CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name);
- CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean);
- CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number);
- CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string);
- CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw);
- CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name);
- CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name);
- #define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
- CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number);
- #define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
- CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring);
- #define cJSON_SetBoolValue(object, boolValue) ( \
- (object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
- (object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
- cJSON_Invalid\
- )
- #define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
- CJSON_PUBLIC(void *) cJSON_malloc(size_t size);
- CJSON_PUBLIC(void) cJSON_free(void *object);
- #ifdef __cplusplus
- }
- #endif
- #endif
|