2 * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
4 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
5 * Michael Clark <michael@metaparadigm.com>
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the MIT license. See COPYING for details.
12 #ifndef _json_tokener_h_
13 #define _json_tokener_h_
16 #include "json_object.h"
22 enum json_tokener_error {
24 json_tokener_continue,
25 json_tokener_error_depth,
26 json_tokener_error_parse_eof,
27 json_tokener_error_parse_unexpected,
28 json_tokener_error_parse_null,
29 json_tokener_error_parse_boolean,
30 json_tokener_error_parse_number,
31 json_tokener_error_parse_array,
32 json_tokener_error_parse_object_key_name,
33 json_tokener_error_parse_object_key_sep,
34 json_tokener_error_parse_object_value_sep,
35 json_tokener_error_parse_string,
36 json_tokener_error_parse_comment
39 enum json_tokener_state {
40 json_tokener_state_eatws,
41 json_tokener_state_start,
42 json_tokener_state_finish,
43 json_tokener_state_null,
44 json_tokener_state_comment_start,
45 json_tokener_state_comment,
46 json_tokener_state_comment_eol,
47 json_tokener_state_comment_end,
48 json_tokener_state_string,
49 json_tokener_state_string_escape,
50 json_tokener_state_escape_unicode,
51 json_tokener_state_boolean,
52 json_tokener_state_number,
53 json_tokener_state_array,
54 json_tokener_state_array_add,
55 json_tokener_state_array_sep,
56 json_tokener_state_object_field_start,
57 json_tokener_state_object_field,
58 json_tokener_state_object_field_end,
59 json_tokener_state_object_value,
60 json_tokener_state_object_value_add,
61 json_tokener_state_object_sep
64 struct json_tokener_srec
66 enum json_tokener_state state, saved_state;
67 struct json_object *obj;
68 struct json_object *current;
72 #define JSON_TOKENER_MAX_DEPTH 32
78 int depth, is_double, st_pos, char_offset;
80 unsigned int ucs_char;
82 struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
85 extern const char* json_tokener_errors[];
87 extern struct json_tokener* json_tokener_new(void);
88 extern void json_tokener_free(struct json_tokener *tok);
89 extern void json_tokener_reset(struct json_tokener *tok);
90 extern struct json_object* json_tokener_parse(const char *str);
91 extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
92 const char *str, int len);