Barracuda Application Server C/C++ Reference
NO
|
JSON Parser Callback Interface.
Classes | |
struct | JParserValFact |
JParserValFact is the JVal JSON parser factory class. More... | |
struct | JParserIntf |
The JParserIntf interface class is the interface between the parser and an object that implements the JParserIntf interface. More... | |
struct | JDecoderStackNode |
Used internally in JDecoder for nested data structures. More... | |
struct | JDecoderV |
Used internally in JDecoder, where one instance represents one node in the pointer value tree. More... | |
struct | JDecoder |
JDecoder implements the parser callback API JParserIntf and builds a pointer value tree when JDecoder::get is called. More... | |
Macros | |
#define | JD_MNUM(o, m) #m, &(o)->m |
JDecoder::get helper macro, used when setting a number pointer in an object. More... | |
#define | JD_MSTR(o, m) #m, &(o)->m, sizeof((o)->m) |
JDecoder::get helper macro, used when setting a string pointer in an object. More... | |
#define | JD_ASTR(o, m) &(o)->m, sizeof((o)->m) |
JDecoder::get helper macro, used when setting a string pointer in an array. More... | |
Typedefs | |
typedef JParserValFact | JParserValFact |
JParserValFact is the JVal JSON parser factory class. More... | |
typedef int(* | JParserIntf_Service) (struct JParserIntf *o, struct JParserVal *v, int recLevel) |
The parser callback function. More... | |
typedef struct JParserIntf | JParserIntf |
The JParserIntf interface class is the interface between the parser and an object that implements the JParserIntf interface. | |
typedef JDecoder | JDecoder |
JDecoder implements the parser callback API JParserIntf and builds a pointer value tree when JDecoder::get is called. More... | |
Enumerations | |
enum | JDecoderS { JDecoderS_FormatErr = -100 , JDecoderS_NameNotFound , JDecoderS_Overflow , JDecoderS_StringOverflow , JDecoderS_Unbalanced , JDecoderS_Underflow , JDecoderS_Unknown , JDecoderS_BufNotAligned , JDecoderS_ChainedErr , JDecoderS_OK = 0 } |
JDecoder Status. More... | |
Functions | |
JParserValFact::JParserValFact (AllocatorIntf *vAlloc, AllocatorIntf *dAlloc) | |
create a JParserValFact JVal factory instance. More... | |
JVal * | JParserValFact::getFirstVal () |
Returns the root of the JVal syntax tree. | |
JVal * | JParserValFact::manageFirstVal () |
Similar to getFirstVal, but you must manage the JVal tree as the value is detached from the JParserValFact. | |
void | JParserValFact::termFirstVal () |
Terminate the syntax tree such that the JParserValFact instance can be reused when the JParser instance parses the next JSON object in a stream. | |
JParserValFact::~JParserValFact () | |
The destructor terminates all nodes not managed. | |
int | JParserIntf::serviceCB (JParserVal *v, int recLevel) |
Calling the JParserIntf service function is typically performed in a design using a chained parser callback interface. More... | |
int | JDecoder::vget (const char *fmt, va_list *argList) |
See JDecoder::get for details. | |
int | JDecoder::get (const char *fmt,...) |
Build a pointer value tree that is used by the integrated parser callback function when the parser feeds elements to the JDecoder instance. More... | |
JDecoder::JDecoder (U8 *buf, int bufSize, int extraStackLen=0) | |
Create/initialize a JDecoder instance. More... | |
#define JD_ASTR | ( | o, | |
m | |||
) | &(o)->m, sizeof((o)->m) |
JDecoder::get helper macro, used when setting a string pointer in an array.
encoder.set("[s]", JD_ASTR(structval, membername));
#define JD_MNUM | ( | o, | |
m | |||
) | #m, &(o)->m |
JDecoder::get helper macro, used when setting a number pointer in an object.
encoder.set("{d}", JD_MNUM(structval, membername));
#define JD_MSTR | ( | o, | |
m | |||
) | #m, &(o)->m, sizeof((o)->m) |
JDecoder::get helper macro, used when setting a string pointer in an object.
encoder.set("{s}", JD_MSTR(structval, membername));
JDecoder implements the parser callback API JParserIntf and builds a pointer value tree when JDecoder::get is called.
The pointer value tree is used by the parser callback when the parser feeds the callback with parsed data.
See the JSON and UBJSON tutorial for more information on using JDecoder.
typedef int(* JParserIntf_Service) (struct JParserIntf *o, struct JParserVal *v, int recLevel) |
The parser callback function.
o | the interface object |
v | the parsed value |
recLevel | goes from 0 to N and represents object nesting level |
typedef JParserValFact JParserValFact |
JParserValFact is the JVal JSON parser factory class.
An instance of this class is connected to an instance of the JParser. The JParser communicates with the JVal factory when parsing JSON, and the JVal factory creates JVal objects.
Method getFirstVal returns the first value in the syntax tree.
The class automatically manages the nodes allocated. The allocated nodes are automatically de-allocated when the destructor runs. You can manage the values by calling JParserValFact::manageFirstVal or by calling JVal::manageJ on any of the children.
enum JDecoderS |
JDecoder Status.
Enumerator | |
---|---|
JDecoderS_FormatErr | Parsed data does not match the value tree that was created when method JDecoder::get was called. |
JDecoderS_NameNotFound | Parsed data includes a member whose name is not in value tree. |
JDecoderS_Overflow | Received more array or object member values from parsed data than found in value tree. |
JDecoderS_StringOverflow | Parsed string longer than buffer provided. |
JDecoderS_Unbalanced | Incorrect use of '{', '}', '[', or '[' in JDecoder::get. |
JDecoderS_Underflow | Received less array or object member values from parsed data than found in value tree. |
JDecoderS_Unknown | Unkown error. |
JDecoderS_BufNotAligned | Memory buffer(s) provided in JDecoder constructor must be word aligned. |
JDecoderS_ChainedErr | A chained parser callback, provided via the 'X' format flag in JDecoder::get, reported an error. |
JDecoderS_OK | OK, no errors. |
int JDecoder::get | ( | const char * | fmt, |
... | |||
) |
Build a pointer value tree that is used by the integrated parser callback function when the parser feeds elements to the JDecoder instance.
fmt | format flags:
|
See the JSON and UBJSON tutorial for more information on using this method.
JDecoder::JDecoder | ( | U8 * | buf, |
int | bufSize, | ||
int | extraStackLen = 0 |
||
) |
Create/initialize a JDecoder instance.
buf | is a pointer to a buffer used internally for memory storage when building the pointer value tree. The minimum size must be sizeof(JDecoderV) * N, where N is the number of format flags minus the end of array/object flags (] or }). |
bufSize | the size of 'buf' |
extraStackLen | is a non documented value and must be set to 0. |
JParserValFact::JParserValFact | ( | AllocatorIntf * | vAlloc, |
AllocatorIntf * | dAlloc | ||
) |
create a JParserValFact JVal factory instance.
vAlloc | is used when allocating nodes. |
dAlloc | is used when allocating strings. The two allocators can be the same. |
int JParserIntf::serviceCB | ( | JParserVal * | v, |
int | recLevel | ||
) |
Calling the JParserIntf service function is typically performed in a design using a chained parser callback interface.
v | the parsed value provided by JParser |
recLevel | must be adjusted by the chained callback |