OSDN Git Service

リスナー情報編集機能追加
[nlite/nlite.git] / JSONParser / json.h
1 #pragma once
2
3 //
4 //\83C\83\93\83N\83\8b\81[\83h
5 /////////////////////////////////////////////////////////////
6
7 #include <stdlib.h>
8 #include <stdint.h>
9
10 //
11 //\8c^\92è\8b`
12 /////////////////////////////////////////////////////////////
13
14
15 ///
16 ///json\89ð\90Í\83I\83u\83W\83F\83N\83g\83|\83C\83\93\83^
17 ///
18 typedef struct jsonparser_t *JSONParser_P;
19
20
21 ///
22 ///json\95\8e\9a\8c^
23 ///
24 typedef wchar_t JSONChar;
25
26 ///
27 ///json\95\8e\9a\97ñ\83|\83C\83\93\83^
28 ///
29 typedef JSONChar *JSONChar_P;
30
31
32
33
34
35 ///
36 ///\90®\90\94\8c^
37 ///
38 typedef intptr_t JSONInt;
39 typedef uintptr_t JSONUInt;
40
41 ///
42 ///\8f­\90\94\8c^
43 ///
44 typedef double JSONDouble;
45
46 ///
47 ///\90^\8bU\8c^
48 ///
49 typedef JSONUInt JSONBool;
50
51
52
53 ///
54 ///json void\8c^
55 ///
56 typedef void JSONVoid;
57
58
59 ///
60 ///\83R\81[\83\8b\83o\83b\83N\83p\83\89\81[\83\81\81[\83^\8c^
61 ///
62 typedef JSONUInt JSONParameter;
63
64
65 ///
66 ///\96ß\82è\92l
67 ///
68 typedef JSONUInt JSONResult;
69
70
71 ///
72 ///\8d\\91¢\91Ì\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
73 ///
74 typedef JSONVoid (*JSONStructEventHandler)(JSONVoid *,JSONUInt,JSONUInt,JSONChar_P);
75
76
77 ///
78 ///\8d\\91¢\91Ì\83f\81[\83^\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
79 ///
80 typedef JSONVoid (*JSONDataEventHandler)(JSONVoid *,JSONUInt,JSONUInt,JSONChar_P,JSONParameter);
81
82 ///
83 ///\8d\\91¢\91Ì\8fI\92[\89ð\90Í\8e\9e\83R\81[\83\8b\83o\83b\83N
84 ///
85 typedef JSONVoid (*JSONStructEndEventHandler)(JSONVoid *,JSONUInt,JSONUInt,JSONChar_P);
86
87
88
89
90
91
92 //
93 //define
94 /////////////////////////////////////////////////////////////////////////
95
96 //
97 //\83G\83\89\81[
98 //
99
100 ///\90³\8fí\8fI\97¹
101 #define JSON_ERR_OK                                                                             ((JSONResult)0)
102
103 ///\8ew\92è\82µ\82½\83G\83\93\83R\81[\83h\83^\83C\83v\82ª\92è\8b`\82³\82ê\82Ä\82¢\82È\82¢
104 #define JSON_ERR_ENCODE_UNKNOWN                                                 ((JSONResult)1)
105
106 ///json\8d\\95\83G\83\89\81[
107 #define JSON_ERR_SYNTAX                                                                 ((JSONResult)2)
108
109 ///\95Ï\8a·\83G\83\89\81[
110 #define JSON_ERR_CONVERT                                                                ((JSONResult)3)                                                                 
111
112
113
114 ///rslt\82ª\8f\89\8aú\89»\82³\82ê\82Ä\82¢\82È\82¢
115 #define JSON_ERR_NOTINIT                                                                ((JSONResult)UINTPTR_MAX)
116
117
118
119
120
121
122
123
124
125
126
127 //
128 //\83G\83\93\83R\81[\83h\83\82\81[\83h
129 //\8c»\8dÝ\82ÍUTF8\82Ì\82Ý
130 //
131
132 #define JSON_ENCODE_UTF8                ((JSONParameter)0)
133
134
135
136
137 //
138 //\90^\8bU\92l
139 //
140
141 ///true
142 #define JSONTrue                                ((JSONBool)1)
143
144
145 ///false
146 #define JSONFalse                               ((JSONBool)0)
147
148
149
150
151 //
152 //\92l\83^\83C\83v
153 //
154 #define JSONTypeRoot                    ((JSONUInt)0)
155
156 ///\83I\83u\83W\83F\83N\83g
157 #define JSONTypeObject                  ((JSONUInt)1)
158
159 ///\94z\97ñ
160 #define JSONTypeArray                   ((JSONUInt)2)
161
162 ///\90^\8bU\92l
163 #define JSONTypeBool                    ((JSONUInt)3)
164
165 ///\95\8e\9a\97ñ
166 #define JSONTypeString                  ((JSONUInt)4)
167
168 ///10\90i\90\94
169 #define JSONTypeDecimal                 ((JSONUInt)5)
170
171 ///null
172 #define JSONNull                                ((JSONUInt)6)
173
174
175
176
177
178
179
180
181 //
182 //\8aÖ\90\94
183 //////////////////////////////////////////////////////////////////////////
184
185
186 #ifdef __cplusplus
187 extern "C" {
188 #endif
189
190
191         ///
192         ///\83p\81[\83T\83I\83u\83W\83F\83N\83g\90\90¬
193         ///
194         extern JSONParser_P JSONParser_new();
195
196         ///
197         ///\83p\81[\83T\83I\83u\83W\83F\83N\83g\94j\8aü
198         ///
199         extern JSONVoid JSONParser_delete(JSONParser_P *parser);
200
201         ///
202         ///\8d\\91¢\91Ì\83C\83x\83\93\83g\83n\83\93\83h\83\89
203         ///
204         extern JSONVoid JSONParser_setStructHandler(JSONParser_P parser,JSONStructEventHandler handler);
205
206         ///
207         ///\83I\83u\83W\83F\83N\83g\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
208         ///
209         extern JSONVoid JSONParser_setDataEventHandler(JSONParser_P parser,JSONDataEventHandler handler);
210
211
212
213         ///
214         ///\83I\83u\83W\83F\83N\83g\8fI\92[\83C\83x\83\93\83g\83n\83\93\83h\83\89\82ð\83Z\83b\83g
215         ///
216         extern JSONVoid JSONParser_setDataEndEventHandler(JSONParser_P parser,JSONStructEndEventHandler handler);
217
218
219         ///
220         ///\83I\83u\83W\83F\83N\83g\8aJ\8en\81E\8fI\92[\83n\83\93\83h\83\89\82ð\83Z\83b\83g
221         ///
222         extern JSONVoid JSONParser_setEventHandler(JSONParser_P parser,JSONStructEventHandler structHandler,JSONDataEventHandler dataHandler,JSONStructEndEventHandler endHandler);
223
224
225         ///
226         ///\89ð\90Í\8aJ\8en
227         ///
228         extern JSONResult JSONParser_Parse(JSONParser_P parser,const JSONVoid *jsontext,JSONParameter encode,JSONVoid *option);
229
230
231
232
233
234
235
236
237
238
239 #ifdef __cplusplus
240 }
241 #endif