00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00038 #include <yajl/yajl_common.h>
00039
00040 #ifndef __YAJL_PARSE_H__
00041 #define __YAJL_PARSE_H__
00042
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046
00047 typedef enum {
00049 yajl_status_ok,
00051 yajl_status_client_canceled,
00055 yajl_status_insufficient_data,
00058 yajl_status_error
00059 } yajl_status;
00060
00062 YAJL_API const char * yajl_status_to_string(yajl_status code);
00063
00065 typedef struct yajl_handle_t * yajl_handle;
00066
00088 typedef struct {
00089 int (* yajl_null)(void * ctx);
00090 int (* yajl_boolean)(void * ctx, int boolVal);
00091 int (* yajl_integer)(void * ctx, long integerVal);
00092 int (* yajl_double)(void * ctx, double doubleVal);
00095 int (* yajl_number)(void * ctx, const char * numberVal,
00096 unsigned int numberLen);
00097
00100 int (* yajl_string)(void * ctx, const unsigned char * stringVal,
00101 unsigned int stringLen);
00102
00103 int (* yajl_start_map)(void * ctx);
00104 int (* yajl_map_key)(void * ctx, const unsigned char * key,
00105 unsigned int stringLen);
00106 int (* yajl_end_map)(void * ctx);
00107
00108 int (* yajl_start_array)(void * ctx);
00109 int (* yajl_end_array)(void * ctx);
00110 } yajl_callbacks;
00111
00113 typedef struct {
00116 unsigned int allowComments;
00119 unsigned int checkUTF8;
00120 } yajl_parser_config;
00121
00130 YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks,
00131 const yajl_parser_config * config,
00132 const yajl_alloc_funcs * allocFuncs,
00133 void * ctx);
00134
00136 YAJL_API void yajl_free(yajl_handle handle);
00137
00143 YAJL_API yajl_status yajl_parse(yajl_handle hand,
00144 const unsigned char * jsonText,
00145 unsigned int jsonTextLength);
00146
00156 YAJL_API yajl_status yajl_parse_complete(yajl_handle hand);
00157
00168 YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose,
00169 const unsigned char * jsonText,
00170 unsigned int jsonTextLength);
00171
00184 YAJL_API unsigned int yajl_get_bytes_consumed(yajl_handle hand);
00185
00187 YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str);
00188
00189 #ifdef __cplusplus
00190 }
00191 #endif
00192
00193 #endif