| 995:d3d4f245b843 | 996:333155f234c4 |
|---|---|
| 35 | 35 |
| 36 #ifndef UCX_JSON_H | 36 #ifndef UCX_JSON_H |
| 37 #define UCX_JSON_H | 37 #define UCX_JSON_H |
| 38 | 38 |
| 39 #include "common.h" | 39 #include "common.h" |
| 40 #include "allocator.h" | |
| 40 #include "string.h" | 41 #include "string.h" |
| 41 #include "array_list.h" | 42 #include "array_list.h" |
| 42 | 43 |
| 43 #ifdef __cplusplus | 44 #ifdef __cplusplus |
| 44 extern "C" { | 45 extern "C" { |
| 111 size_t length; | 112 size_t length; |
| 112 size_t alloc; | 113 size_t alloc; |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 struct cx_json_s { | 116 struct cx_json_s { |
| 117 const CxAllocator *allocator; | |
| 116 const char *buffer; | 118 const char *buffer; |
| 117 size_t size; | 119 size_t size; |
| 118 size_t pos; | 120 size_t pos; |
| 119 | 121 |
| 120 CxJsonToken uncompleted; | 122 CxJsonToken uncompleted; |
| 158 char *name; | 160 char *name; |
| 159 CxJsonValue *value; | 161 CxJsonValue *value; |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 struct cx_json_value_s { | 164 struct cx_json_value_s { |
| 165 const CxAllocator *allocator; | |
| 163 CxJsonValueType type; | 166 CxJsonValueType type; |
| 164 union { | 167 union { |
| 165 CxJsonArray array; | 168 CxJsonArray array; |
| 166 CxJsonObject object; | 169 CxJsonObject object; |
| 167 CxJsonString string; | 170 CxJsonString string; |
| 169 CxJsonNumber number; | 172 CxJsonNumber number; |
| 170 CxJsonLiteral literal; | 173 CxJsonLiteral literal; |
| 171 } value; | 174 } value; |
| 172 }; | 175 }; |
| 173 | 176 |
| 174 // TODO: add support for CxAllocator | 177 |
| 175 | 178 cx_attr_nonnull_arg(2) |
| 176 cx_attr_nonnull | 179 void cxJsonInit(const CxAllocator *allocator, CxJson *json); |
| 177 void cxJsonInit(CxJson *json); | |
| 178 | 180 |
| 179 cx_attr_nonnull | 181 cx_attr_nonnull |
| 180 void cxJsonDestroy(CxJson *json); | 182 void cxJsonDestroy(CxJson *json); |
| 181 | 183 |
| 182 cx_attr_nonnull | 184 cx_attr_nonnull |