43#include <AllocatorIntf.h>
85#define JParserIntf_constructor(o,serviceMA) (o)->service=serviceMA
87#define JParserIntf_serviceCB(o, v, recLev) (o)->service(o,v,recLev)
92 return JParserIntf_serviceCB(
this,v, recLevel); }
175 int setTooFewParams();
177 int setError(
JErrT err,
const char* msg);
187#define JErr_constructor(o) (o)->err=JErrT_NoErr
188#define JErr_reset(o) (o)->err=JErrT_NoErr, (o)->msg=0
189#define JErr_isError(o) ((o)->err!=JErrT_NoErr)
190#define JErr_noError(o) ((o)->err==JErrT_NoErr)
191#define JErr_getErrT(o) (o)->err
192#define JErr_getExpT(o) (o)->expType
193#define JErr_getRecT(o) (o)->recType
194BA_API
int JErr_setTooFewParams(
JErr* o);
196BA_API
int JErr_setError(
JErr* o,
JErrT err,
const char* msg);
200 JErr_constructor(
this); }
204 return JErr_isError(
this) ? true :
false;}
206 return JErr_noError(
this) ? true :
false;}
208 return JErr_getErrT(
this);}
210 return JErr_getExpT(
this);}
212 return JErr_getRecT(
this);}
213inline int JErr::setTooFewParams() {
214 return JErr_setTooFewParams(
this);}
216 return JErr_setTypeErr(
this, expT, recT);}
217inline int JErr::setError(
JErrT e,
const char* message) {
218 return JErr_setError(
this,e, message);}
247 JLexerT_NeedMoreData,
255 JLexerSt_StartComment,
258 JLexerSt_EatCppComment,
259 JLexerSt_TrueFalseNull,
261 JLexerSt_StringEscape,
262 JLexerSt_StringUnicode,
263 JLexerSt_StringSurrogateEscape,
264 JLexerSt_StringSurrogateU,
267 JLexerSt_GetNextToken
286 const U8* typeChkPtr;
394 JParserSt_BeginArray,
395 JParserSt_MemberName,
403#define JPARSER_STACK_LEN 8
443 int parse(
const U8* buf, U32 size);
478BA_API
int JParser_parse(
JParser* o,
const U8* buf, U32 size);
479BA_API
void JParser_destructor(
JParser* o);
480#define JParser_getStatus(o) ((JParsStat)(o)->status)
486 JParser_constructor(
this, intf, nameBuf, namebufSize, alloc, extraStackLen);
489 return JParser_parse(
this, buf, size);}
491 JParser_destructor(
this);}
493 return JParser_getStatus(
this);}
int serviceCB(JParserVal *v, int recLevel)
Calling the JParserIntf service function is typically performed in a design using a chained parser ca...
Definition: JParser.h:91
int(* JParserIntf_Service)(struct JParserIntf *o, struct JParserVal *v, int recLevel)
The parser callback function.
Definition: JParser.h:57
struct JParserIntf JParserIntf
The JParserIntf interface class is the interface between the parser and an object that implements the...
struct JParserVal JParserVal
The parser sets a JParserVal before calling the parser callback JParserIntf.
struct JErr JErr
The JSON error container object.
JParser(JParserIntf *intf, char *nameBuf, int namebufSize, AllocatorIntf *alloc, int extraStackLen=0)
Create a JSON parser object.
Definition: JParser.h:483
JParsStat getStatus()
Returns the parser status.
Definition: JParser.h:492
JParsStat
JSON Parser Status.
Definition: JParser.h:360
JVType getRecT()
Returns the parsed type if this is a parse error.
Definition: JParser.h:211
JErrT
JSON error codes.
Definition: JParser.h:132
~JParser()
Terminate and release the internal buffers.
Definition: JParser.h:490
void reset()
Reset – remove any error so the object can be reused.
Definition: JParser.h:201
bool noError()
Returns true if no error.
Definition: JParser.h:205
JErrT getErrT()
Returns the error type.
Definition: JParser.h:207
int parse(const U8 *buf, U32 size)
Parse a JSON text chunk.
Definition: JParser.h:488
JVType
The JSON types.
Definition: JParser.h:103
JParserT
Type 't' in JParserVal.
Definition: JParser.h:304
JVType getExpT()
Returns the expected type if this is a parse error.
Definition: JParser.h:209
U8 JParserStackNode
The stack used internally by JParser.
Definition: JParser.h:406
JErr()
Create a new object.
Definition: JParser.h:199
bool isError()
Returns true if the error flag is set.
Definition: JParser.h:203
@ JParsStat_ParseErr
JSON Parse error.
Definition: JParser.h:377
@ JParsStat_IntfErr
The JParserIntf interface reported a problem.
Definition: JParser.h:381
@ JParsStat_DoneEOS
The parser completed parsing a new JSON object.
Definition: JParser.h:364
@ JParsStat_NeedMoreData
The parser needs more data to complete.
Definition: JParser.h:373
@ JParsStat_StackOverflow
Object nested too deep.
Definition: JParser.h:388
@ JParsStat_Done
The parser completed parsing a new JSON object, but found the start of a new object in the provided b...
Definition: JParser.h:369
@ JParsStat_MemErr
Memory allocation error.
Definition: JParser.h:385
@ JErrT_InvalidMethodParams
Invalid RPC method parameters.
Definition: JParser.h:142
@ JErrT_NoErr
No error.
Definition: JParser.h:134
@ JErrT_MemErr
Memory allocation error.
Definition: JParser.h:147
@ JErrT_FmtValErr
A format error in JEncoder or JVal::get.
Definition: JParser.h:145
@ JErrT_WrongType
Unexpected JSON type when parsing.
Definition: JParser.h:140
@ JErrT_JsonErr
Generic error.
Definition: JParser.h:136
@ JErrT_IOErr
I/O error.
Definition: JParser.h:149
@ JVType_Null
JSON NULL value.
Definition: JParser.h:122
@ JVType_Int
JSON Number encoded as an integer.
Definition: JParser.h:115
@ JVType_Double
JSON Number encoded as a float.
Definition: JParser.h:112
@ JVType_Object
The JVAL is of type JSON object.
Definition: JParser.h:124
@ JVType_String
JSON string.
Definition: JParser.h:109
@ JVType_Long
JSON Number encoded as a long integer.
Definition: JParser.h:118
@ JVType_Array
The JVAL is of type JSON array.
Definition: JParser.h:126
@ JVType_Boolean
JSON boolean.
Definition: JParser.h:120
@ JVType_InvalidType
Invalid JSON type.
Definition: JParser.h:106
@ JParserT_BeginObject
BeginObject.
Definition: JParser.h:312
@ JParserT_Long
64-bit (long long)
Definition: JParser.h:310
@ JParserT_String
String.
Definition: JParser.h:307
@ JParserT_EndArray
EndArray.
Definition: JParser.h:315
@ JParserT_EndObject
EndObject.
Definition: JParser.h:314
@ JParserT_Boolean
Boolean.
Definition: JParser.h:311
@ JParserT_InvalidType
InvalidType.
Definition: JParser.h:305
@ JParserT_BeginArray
BeginArray.
Definition: JParser.h:313
@ JParserT_Null
Null.
Definition: JParser.h:306
@ JParserT_Double
Double.
Definition: JParser.h:308
@ JParserT_Int
Int.
Definition: JParser.h:309
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:83
The JSON error container object.
Definition: JParser.h:155
The JParserIntf interface class is the interface between the parser and an object that implements the...
Definition: JParser.h:65
JParserIntf(JParserIntf_Service s)
Create the callback interface object.
Definition: JParser.h:70
The parser sets a JParserVal before calling the parser callback JParserIntf.
Definition: JParser.h:322
union JParserVal::@1 v
A union controlled by the type 't'.
size_t memberNameLen
Object member-name length.
Definition: JParser.h:352
JParserT t
The type controlling 'v'.
Definition: JParser.h:354
S32 d
If integer.
Definition: JParser.h:331
BaBool memberNameSet
True when this value is an object member.
Definition: JParser.h:353
char * memberName
object member name is set for objects.
Definition: JParser.h:350
size_t stringLen
String length when t is JParserT_String.
Definition: JParser.h:351
U64 l
If long integer.
Definition: JParser.h:332
double f
If number of type double.
Definition: JParser.h:329
char * s
If string.
Definition: JParser.h:327
The JSON parser parses a JSON stream and calls the JParserIntf callback interface for each parsed obj...
Definition: JParser.h:414