Remove on_{begin,end}_{string,number}
And add `done` arg to data callback
This commit is contained in:
@@ -6,23 +6,20 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
struct WeaselJsonCallbacks {
|
||||
void (*on_begin_object)(void *data);
|
||||
void (*on_end_object)(void *data);
|
||||
void (*on_begin_string)(void *data);
|
||||
/** May be called multiple times per string if not all string data is
|
||||
* available yet. The string data provided is unescaped. */
|
||||
void (*on_string_data)(void *data, const char *buf, int len);
|
||||
void (*on_end_string)(void *data);
|
||||
void (*on_begin_array)(void *data);
|
||||
void (*on_end_array)(void *data);
|
||||
void (*on_begin_number)(void *data);
|
||||
/** May be called multiple times per number if not all number data is
|
||||
* available yet */
|
||||
void (*on_number_data)(void *data, const char *buf, int len);
|
||||
void (*on_end_number)(void *data);
|
||||
void (*on_true_literal)(void *data);
|
||||
void (*on_false_literal)(void *data);
|
||||
void (*on_null_literal)(void *data);
|
||||
void (*on_begin_object)(void *userdata);
|
||||
void (*on_end_object)(void *userdata);
|
||||
/** The string data provided has already been unescaped. If `done` is false,
|
||||
* this string may be incomplete and there will be another call with more data
|
||||
*/
|
||||
void (*on_string_data)(void *userdata, const char *buf, int len, int done);
|
||||
void (*on_begin_array)(void *userdata);
|
||||
void (*on_end_array)(void *userdata);
|
||||
/*If `done` is false, this number may be incomplete and there will be another
|
||||
* call with more data*/
|
||||
void (*on_number_data)(void *userdata, const char *buf, int len, int done);
|
||||
void (*on_true_literal)(void *userdata);
|
||||
void (*on_false_literal)(void *userdata);
|
||||
void (*on_null_literal)(void *userdata);
|
||||
};
|
||||
|
||||
enum WeaselJsonStatus {
|
||||
@@ -40,12 +37,12 @@ enum WeaselJsonStatus {
|
||||
typedef struct WeaselJsonParser WeaselJsonParser;
|
||||
|
||||
/** Create a parser. Increasing stack size increases memory usage but also
|
||||
* increases the depth of nested json accepted. `callbacks` and `data` must
|
||||
* increases the depth of nested json accepted. `callbacks` and `userdata` must
|
||||
* outlive the returned parser. Returns null if there's insufficient available
|
||||
* memory */
|
||||
WeaselJsonParser *WeaselJsonParser_create(int stackSize,
|
||||
const WeaselJsonCallbacks *callbacks,
|
||||
void *data);
|
||||
void *userdata);
|
||||
|
||||
/** Restore the parser to its newly-created state */
|
||||
void WeaselJsonParser_reset(WeaselJsonParser *parser);
|
||||
|
||||
Reference in New Issue
Block a user