Start working on c api
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
#ifndef WEASELJSON_H
|
||||
#define WEASELJSON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct WeaselJsonCallbacks {
|
||||
void (*on_begin_object)(void *data);
|
||||
void (*on_end_object)(void *data);
|
||||
@@ -17,4 +21,37 @@ struct WeaselJsonCallbacks {
|
||||
void (*on_null_literal)(void *data);
|
||||
};
|
||||
|
||||
enum WeaselJsonStatus {
|
||||
/** Accept input */
|
||||
WeaselJson_OK,
|
||||
/** Consumed all available input. Call WeaselJsonParser_parse with more data
|
||||
to provide more input, or call with length 0 to indicate end of data*/
|
||||
WeaselJson_AGAIN,
|
||||
/** Invalid json */
|
||||
WeaselJson_REJECT,
|
||||
/** json is too deeply nested */
|
||||
WeaselJson_OVERFLOW,
|
||||
};
|
||||
|
||||
typedef struct WeaselJsonParser WeaselJsonParser;
|
||||
|
||||
/** Increasing stack size increases memory usage but also increases the depth of
|
||||
* nested json accepted. */
|
||||
WeaselJsonParser *WeaselJsonParser_create(int stackSize);
|
||||
|
||||
/** Restore the parser to its newly-created state */
|
||||
void WeaselJsonParser_reset(WeaselJsonParser *parser);
|
||||
|
||||
/** Destroy the parser */
|
||||
void WeaselJsonParser_destroy(WeaselJsonParser *parser);
|
||||
|
||||
/** Incrementally parse `len` more bytes starting at `buf`. `buf` may be
|
||||
* modified. Call with `len` 0 to indicate end of data */
|
||||
WeaselJsonStatus WeaselJsonParser_parse(WeaselJsonParser *parser, char *buf,
|
||||
int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user