| 1 | #ifndef PDJSON_H |
| 2 | #define PDJSON_H |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | enum json_type { |
| 7 | JSON_ERROR = 1, JSON_DONE, |
| 8 | JSON_OBJECT, JSON_OBJECT_END, JSON_ARRAY, JSON_ARRAY_END, |
| 9 | JSON_STRING, JSON_NUMBER, JSON_TRUE, JSON_FALSE, JSON_NULL |
| 10 | }; |
| 11 | |
| 12 | struct json_allocator { |
| 13 | void *(*malloc)(size_t); |
| 14 | void *(*realloc)(void *, size_t); |
| 15 | void (*free)(void *); |
| 16 | }; |
| 17 | |
| 18 | #include "pd_json_private.h" |
| 19 | |
| 20 | typedef struct json_stream json_stream; |
| 21 | typedef struct json_allocator json_allocator; |
| 22 | |
| 23 | void json_open_buffer(json_stream *json, const void *buffer, size_t size); |
| 24 | void json_open_string(json_stream *json, const char *string); |
| 25 | void json_open_stream(json_stream *json, FILE *stream); |
| 26 | void json_close(json_stream *json); |
| 27 | |
| 28 | void json_set_allocator(json_stream *json, json_allocator *a); |
| 29 | void json_set_streaming(json_stream *json, bool strict); |
| 30 | |
| 31 | enum json_type json_next(json_stream *json); |
| 32 | enum json_type json_peek(json_stream *json); |
| 33 | void json_reset(json_stream *json); |
| 34 | const char *json_get_string(json_stream *json, size_t *length); |
| 35 | double json_get_number(json_stream *json); |
| 36 | |
| 37 | size_t json_get_lineno(json_stream *json); |
| 38 | size_t json_get_position(json_stream *json); |
| 39 | size_t json_get_depth(json_stream *json); |
| 40 | const char *json_get_error(json_stream *json); |
| 41 | |
| 42 | #endif |
| 43 | |