yajl_parse.h
Go to the documentation of this file.
/*
* Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <yajl/yajl_common.h>
#ifndef __YAJL_PARSE_H__
#define __YAJL_PARSE_H__
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
yajl_status_ok,
yajl_status_client_canceled,
yajl_status_error
} yajl_status;
YAJL_API const char * yajl_status_to_string(yajl_status code);
typedef struct yajl_handle_t * yajl_handle;
typedef struct {
int (* yajl_null)(void * ctx);
int (* yajl_boolean)(void * ctx, int boolVal);
int (* yajl_integer)(void * ctx, long long integerVal);
int (* yajl_double)(void * ctx, double doubleVal);
int (* yajl_number)(void * ctx, const char * numberVal,
size_t numberLen);
int (* yajl_string)(void * ctx, const unsigned char * stringVal,
size_t stringLen);
int (* yajl_start_map)(void * ctx);
int (* yajl_map_key)(void * ctx, const unsigned char * key,
size_t stringLen);
int (* yajl_end_map)(void * ctx);
int (* yajl_start_array)(void * ctx);
int (* yajl_end_array)(void * ctx);
} yajl_callbacks;
YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks,
yajl_alloc_funcs * afs,
void * ctx);
typedef enum {
yajl_allow_comments = 0x01,
yajl_dont_validate_strings = 0x02,
yajl_allow_trailing_garbage = 0x04,
yajl_allow_multiple_values = 0x08,
yajl_allow_partial_values = 0x10
} yajl_option;
YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...);
YAJL_API void yajl_free(yajl_handle handle);
YAJL_API yajl_status yajl_parse(yajl_handle hand,
const unsigned char * jsonText,
size_t jsonTextLength);
YAJL_API yajl_status yajl_complete_parse(yajl_handle hand);
YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose,
const unsigned char * jsonText,
size_t jsonTextLength);
YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand);
YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str);
#ifdef __cplusplus
}
#endif
#endif
yajl_alloc_funcs
Definition yajl_common.h:59
yajl_callbacks
Definition yajl_parse.h:74
yajl_callbacks::yajl_number
int(* yajl_number)(void *ctx, const char *numberVal, size_t numberLen)
Definition yajl_parse.h:81
yajl_callbacks::yajl_integer
int(* yajl_integer)(void *ctx, long long integerVal)
Definition yajl_parse.h:77
yajl_callbacks::yajl_start_array
int(* yajl_start_array)(void *ctx)
Definition yajl_parse.h:94
yajl_callbacks::yajl_end_array
int(* yajl_end_array)(void *ctx)
Definition yajl_parse.h:95
yajl_callbacks::yajl_double
int(* yajl_double)(void *ctx, double doubleVal)
Definition yajl_parse.h:78
yajl_callbacks::yajl_boolean
int(* yajl_boolean)(void *ctx, int boolVal)
Definition yajl_parse.h:76
yajl_callbacks::yajl_map_key
int(* yajl_map_key)(void *ctx, const unsigned char *key, size_t stringLen)
Definition yajl_parse.h:90
yajl_callbacks::yajl_string
int(* yajl_string)(void *ctx, const unsigned char *stringVal, size_t stringLen)
Definition yajl_parse.h:86
yajl_callbacks::yajl_null
int(* yajl_null)(void *ctx)
Definition yajl_parse.h:75
yajl_callbacks::yajl_start_map
int(* yajl_start_map)(void *ctx)
Definition yajl_parse.h:89
yajl_callbacks::yajl_end_map
int(* yajl_end_map)(void *ctx)
Definition yajl_parse.h:92
YAJL_API
#define YAJL_API
Definition yajl_common.h:41
yajl_free_error
YAJL_API void yajl_free_error(yajl_handle hand, unsigned char *str)
yajl_status
yajl_status
Definition yajl_parse.h:33
yajl_status_client_canceled
@ yajl_status_client_canceled
Definition yajl_parse.h:37
yajl_status_ok
@ yajl_status_ok
Definition yajl_parse.h:35
yajl_status_error
@ yajl_status_error
Definition yajl_parse.h:40
yajl_status_to_string
YAJL_API const char * yajl_status_to_string(yajl_status code)
yajl_option
yajl_option
Definition yajl_parse.h:115
yajl_dont_validate_strings
@ yajl_dont_validate_strings
Definition yajl_parse.h:133
yajl_allow_multiple_values
@ yajl_allow_multiple_values
Definition yajl_parse.h:151
yajl_allow_trailing_garbage
@ yajl_allow_trailing_garbage
Definition yajl_parse.h:141
yajl_allow_comments
@ yajl_allow_comments
Definition yajl_parse.h:123
yajl_allow_partial_values
@ yajl_allow_partial_values
Definition yajl_parse.h:159
yajl_get_error
YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char *jsonText, size_t jsonTextLength)
yajl_parse
YAJL_API yajl_status yajl_parse(yajl_handle hand, const unsigned char *jsonText, size_t jsonTextLength)
yajl_get_bytes_consumed
YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand)
yajl_free
YAJL_API void yajl_free(yajl_handle handle)
yajl_handle
struct yajl_handle_t * yajl_handle
Definition yajl_parse.h:47
yajl_alloc
YAJL_API yajl_handle yajl_alloc(const yajl_callbacks *callbacks, yajl_alloc_funcs *afs, void *ctx)
yajl_complete_parse
YAJL_API yajl_status yajl_complete_parse(yajl_handle hand)
yajl_config
YAJL_API int yajl_config(yajl_handle h, yajl_option opt,...)