CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
jsonparse.h
Go to the documentation of this file.
1
3
4#pragma once
5
8
9typedef struct SSDNode SSDNode;
10typedef struct SSDTree SSDTree;
11
12CX_C_BEGIN
13
80
82
87typedef struct JSONParseState {
89 StreamBuffer* sb;
91 int line;
93 int depth;
94 // Internal error message
95 string errmsg;
99 sa_JSONParseEvent queued;
105
130bool jsonParseInit(_Out_ JSONParseState* state, _Inout_ StreamBuffer* sb);
131
145
159void jsonParsePush(_Inout_ JSONParseState* state, _In_ JSONParseEvent* ev);
160
170void jsonParseDestroy(_Inout_ JSONParseState* state);
171
185typedef void (*jsonParseCB)(_In_ JSONParseEvent* ev, _Inout_opt_ void* userdata);
186
223bool jsonParse(_Inout_ StreamBuffer* sb, _In_ jsonParseCB callback, _Inout_opt_ void* userdata);
224
252_Ret_opt_valid_ SSDNode* jsonParseTree(_Inout_ StreamBuffer* sb);
253
265_Ret_opt_valid_ SSDNode* jsonParseTreeCustom(_Inout_ StreamBuffer* sb, _In_opt_ SSDTree* tree);
266
288_Ret_opt_valid_ SSDNode* jsonTreeFromString(_In_opt_ strref str);
289
291
292CX_C_END
#define saDeclareType(name, typ)
Definition sarray.h:80
SSDNode * jsonParseTree(StreamBuffer *sb)
SSDNode * jsonTreeFromString(strref str)
bool jsonParseInit(JSONParseState *state, StreamBuffer *sb)
void jsonParseDestroy(JSONParseState *state)
SSDNode * jsonParseTreeCustom(StreamBuffer *sb, SSDTree *tree)
void jsonParsePush(JSONParseState *state, JSONParseEvent *ev)
void(* jsonParseCB)(JSONParseEvent *ev, void *userdata)
Definition jsonparse.h:185
bool jsonParse(StreamBuffer *sb, jsonParseCB callback, void *userdata)
JSONParseEvent * jsonParseNext(JSONParseState *state)
Common types for JSON parsing and output.
Dynamic arrays with type-safe generic programming.
JSONParseContext * ctx
Top of context stack.
Definition jsonparse.h:101
bool success
true if parsing completed without error
Definition jsonparse.h:103
int depth
Current nesting depth.
Definition jsonparse.h:93
int line
Current line number (starts at 1)
Definition jsonparse.h:91
JSONParseEvent ev
Current event (valid until next jsonParseNext call)
Definition jsonparse.h:97
StreamBuffer * sb
Stream buffer being parsed.
Definition jsonparse.h:89
sa_JSONParseEvent queued
Queue of events to deliver before parsing new ones.
Definition jsonparse.h:99