jkii
jkii.h
Go to the documentation of this file.
1 
5 #ifndef JKII_H
6 #define JKII_H
7 
8 #include <jsmn.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
15 typedef jsmntok_t jkii_token_t;
16 
20 typedef struct jkii_resource_t {
21 
23  jkii_token_t *tokens;
24 
26  size_t tokens_num;
27 
29 
34 typedef jkii_resource_t*
35  (*JKII_CB_RESOURCE_ALLOC)(
36  size_t required_size);
37 
38 typedef void (*JKII_CB_RESOURCE_FREE)(
39  jkii_resource_t* resource);
40 
42 typedef enum jkii_boolean_t {
46 
49 typedef enum jkii_parse_err_t {
50 
56 
62 
71 
74 
77 
81 
83 typedef enum jkii_field_err_t {
86 
89 
92 
98 
106 
115 
118 typedef enum jkii_field_type_t {
119 
125 
129 
133 
136 
139 
142 
145 
148 
152 
169 typedef struct jkii_field_t {
170 
177  const char* name;
178 
224  const char* path;
225 
230  jkii_field_err_t result;
231 
254  jkii_field_type_t type;
255 
260  size_t start;
261 
266  size_t end;
267 
274  union {
275 
281  char* string;
282 
290 
297 
304  double double_value;
305 
309  jkii_boolean_t boolean_value;
310  } field_copy;
311 
319 
320 } jkii_field_t;
321 
329 jkii_parse_err_t jkii_parse(
330  const char* json_string,
331  size_t json_string_len,
332  jkii_field_t* fields,
333  jkii_resource_t* resource);
334 
343 jkii_parse_err_t jkii_parse_with_allocator(
344  const char* json_string,
345  size_t json_string_len,
346  jkii_field_t* fields,
347  JKII_CB_RESOURCE_ALLOC cb_alloc,
348  JKII_CB_RESOURCE_FREE cb_free);
349 
350 #ifdef __cplusplus
351 }
352 #endif
353 
354 #endif
Definition: jkii.h:91
jkii_field_type_t type
Definition: jkii.h:254
char * string
Definition: jkii.h:281
Definition: jkii.h:73
struct jkii_field_t jkii_field_t
jkii_parse_err_t jkii_parse_with_allocator(const char *json_string, size_t json_string_len, jkii_field_t *fields, JKII_CB_RESOURCE_ALLOC cb_alloc, JKII_CB_RESOURCE_FREE cb_free)
Definition: jkii.h:61
Definition: jkii.h:44
const char * path
Definition: jkii.h:224
Definition: jkii.h:70
size_t field_copy_buff_size
Definition: jkii.h:318
Definition: jkii.h:113
Definition: jkii.h:97
Definition: jkii.h:55
size_t tokens_num
Definition: jkii.h:26
Definition: jkii.h:150
Definition: jkii.h:169
long long_value
Definition: jkii.h:296
Definition: jkii.h:88
jsmntok_t jkii_token_t
Definition: jkii.h:15
Definition: jkii.h:141
jkii_token_t * tokens
Definition: jkii.h:23
Definition: jkii.h:43
Definition: jkii.h:124
jkii_field_err_t
Definition: jkii.h:83
int int_value
Definition: jkii.h:289
jkii_boolean_t
Definition: jkii.h:42
void(* JKII_CB_RESOURCE_FREE)(jkii_resource_t *resource)
Definition: jkii.h:38
jkii_field_err_t result
Definition: jkii.h:230
double double_value
Definition: jkii.h:304
size_t end
Definition: jkii.h:266
Definition: jkii.h:144
jkii_field_type_t
Definition: jkii.h:118
Definition: jkii.h:135
Definition: jkii.h:128
size_t start
Definition: jkii.h:260
Definition: jkii.h:85
jkii_parse_err_t jkii_parse(const char *json_string, size_t json_string_len, jkii_field_t *fields, jkii_resource_t *resource)
Definition: jkii.h:79
const char * name
Definition: jkii.h:177
Definition: jkii.h:147
Definition: jkii.h:132
Definition: jkii.h:20
Definition: jkii.h:138
jkii_parse_err_t
Definition: jkii.h:49
jkii_boolean_t boolean_value
Definition: jkii.h:309
jkii_resource_t *(* JKII_CB_RESOURCE_ALLOC)(size_t required_size)
Definition: jkii.h:35
struct jkii_resource_t jkii_resource_t
Definition: jkii.h:76
Definition: jkii.h:105