libsheepy
laxjson.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Andrew Kelley
3  *
4  * This file is part of liblaxjson, which is MIT licensed.
5  * See http://opensource.org/licenses/MIT
6  */
7 
8 #pragma once
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif /* __cplusplus */
14 
24 };
25 
45 };
46 
59 };
60 
61 /* All callbacks must be provided. Return nonzero to abort the ongoing feed operation. */
63  void *userdata;
64  /* type can be property or string */
65  int (*string)(struct LaxJsonContext *, enum LaxJsonType type, const char *value, int length);
66  /* type is always number */
67  int (*number)(struct LaxJsonContext *, char* x);
68  /* type can be true, false, or null */
69  int (*primitive)(struct LaxJsonContext *, enum LaxJsonType type);
70  /* type can be array or object */
71  int (*begin)(struct LaxJsonContext *, enum LaxJsonType type);
72  /* type can be array or object */
73  int (*end)(struct LaxJsonContext *, enum LaxJsonType type);
74 
75  int line;
76  int column;
77 
80 
81  /* private members */
86 
87  char *value_buffer;
90 
91  unsigned int unicode_point;
92  unsigned int unicode_digit_index;
93 
94  char *expected;
95  char delim;
97 };
98 
99 struct LaxJsonContext *lax_json_create(void);
100 void lax_json_destroy(struct LaxJsonContext *context);
101 
102 enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const char *data);
103 enum LaxJsonError lax_json_eof(struct LaxJsonContext *context);
104 
105 const char *lax_json_str_err(enum LaxJsonError err);
106 
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
LaxJsonType
Definition: laxjson.h:15
int(* begin)(struct LaxJsonContext *, enum LaxJsonType type)
Definition: laxjson.h:71
int state_stack_size
Definition: laxjson.h:85
void * userdata
Definition: laxjson.h:63
enum LaxJsonType string_type
Definition: laxjson.h:96
int value_buffer_size
Definition: laxjson.h:89
char * value_buffer
Definition: laxjson.h:87
int(* end)(struct LaxJsonContext *, enum LaxJsonType type)
Definition: laxjson.h:73
int value_buffer_index
Definition: laxjson.h:88
char data[7]
Definition: libsheepy.c:19690
enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const char *data)
Definition: laxjson.c:219
#define err(str)
Definition: tpool.c:35
struct LaxJsonContext * lax_json_create(void)
Definition: laxjson.c:161
void lax_json_destroy(struct LaxJsonContext *context)
Definition: laxjson.c:191
unsigned int unicode_point
Definition: laxjson.h:91
int state_stack_index
Definition: laxjson.h:84
enum LaxJsonError lax_json_eof(struct LaxJsonContext *context)
Definition: laxjson.c:737
LaxJsonError
Definition: laxjson.h:47
char delim
Definition: laxjson.h:95
char * expected
Definition: laxjson.h:94
int max_state_stack_size
Definition: laxjson.h:78
int(* primitive)(struct LaxJsonContext *, enum LaxJsonType type)
Definition: laxjson.h:69
in value value
enum LaxJsonState state
Definition: laxjson.h:82
LaxJsonState
Definition: laxjson.h:26
int(* number)(struct LaxJsonContext *, char *x)
Definition: laxjson.h:67
const char * lax_json_str_err(enum LaxJsonError err)
Definition: laxjson.c:751
int max_value_buffer_size
Definition: laxjson.h:79
enum LaxJsonState * state_stack
Definition: laxjson.h:83
unsigned int unicode_digit_index
Definition: laxjson.h:92