81 JVal*
vget(
JErr* err,
const char** fmt, va_list* argList);
304 struct JVal* firstChild;
317 size_t memberNameLen;
326#define JVal_getType(o) (o)->type
327BA_API
JVal* JVal_vget(
JVal* o,
JErr* err,
const char** fmt, va_list* argList);
328BA_API
JVal* JVal_get(
JVal* o,
JErr* err,
const char* fmt, ...);
329BA_API S32 JVal_getInt(
JVal* o,
JErr* e);
330BA_API S64 JVal_getLong(
JVal* o,
JErr* e);
331BA_API
double JVal_getDouble(
JVal* o,
JErr* e);
332BA_API BaBool JVal_getBoolean(
JVal* o,
JErr* e);
333BA_API
const char* JVal_getString(
JVal* o,
JErr* e);
334#define JVal_getStringLen(o) (o)->stringLen
335BA_API
char* JVal_manageString(
JVal* o,
JErr* e);
336BA_API
const char* JVal_getName(
JVal* o);
337#define JVal_getNameLen(o) (o)->memberNameLen
338BA_API
char* JVal_manageName(
JVal* o);
339#define JVal_getNextElem(o) (o)->next
344BA_API S32 JVal_getLength(
struct JVal* o,
JErr* e);
345#define JVal_isObjectMember(o) ((o)->memberName != 0)
346BA_API
int JVal_unlink(
JVal* o,
JVal* child);
347BA_API
int JVal_addMember(
JVal* o,
JErr* e,
const char* memberName,
352#define JVal_setInt(o, e, v) JVal_setX(o, e, JVType_Int, &v)
353#define JVal_setLong(o, e, v) JVal_setX(o, e, JVType_Long, &v)
354#define JVal_setDouble(o, e, v) JVal_setX(o, e, JVType_Double, &v)
355#define JVal_setBoolean(o, e, v) JVal_setX(o, e, JVType_Boolean, &v)
356#define JVal_setNull(o, e) JVal_setX(o, e, JVType_Null, 0)
357#define JVal_setString(o, e, v) JVal_setX(o, e, JVType_String, v)
362 return JVal_getType(
this); }
364 return JVal_vget(
this,err,fmt, argList); }
366 JVal* retv; va_list argList;
367 va_start(argList, fmt);
368 retv = JVal_vget(
this,err,&fmt,&argList);
373 return JVal_getInt(
this, e); }
375 return JVal_getLong(
this, e); }
377 return JVal_getDouble(
this, e); }
379 return JVal_getBoolean(
this, e); }
381 return JVal_getString(
this, e); }
383 return JVal_getStringLen(
this); }
385 return JVal_manageString(
this, e); }
387 return JVal_getName(
this); }
389 return JVal_getNameLen(
this); }
391 return JVal_manageName(
this); }
393 return JVal_getNextElem(
this); }
395 return JVal_getObject(
this, e); }
397 return JVal_getArray(
this, e); }
399 return JVal_getJ(
this, e); }
401 return JVal_manageJ(
this, e); }
403 return JVal_getLength(
this, e); }
406 JVal_setInt(
this, e, val); }
408 JVal_setLong(
this, e, val); }
410 JVal_setDouble(
this, e, val); }
412 JVal_setBoolean(
this, e, val); }
414 JVal_setNull(
this, e); }
416 JVal_setString(
this, e, val); }
418 return JVal_isObjectMember(
this) ? true :
false; }
420 return JVal_unlink(
this, child); }
423 return JVal_addMember(
this, e, name, child, dAlloc); }
425 return JVal_add(
this, e, child); }
427 JVal_terminate(
this, vAlloc, dAlloc); }
438 JParserValFactStat_OK=0,
439 JParserValFactStat_DMemErr,
440 JParserValFactStat_VMemErr,
441 JParserValFactStat_MaxNodes
498 JParserValFactStat status;
503BA_API
void JParserValFact_constructor(
505#define JParserValFact_getFirstVal(o) \
506 ((o)->vStack && *(o)->vStack ? *(o)->vStack : 0)
514 JParserValFact_constructor(
this, vAlloc, dAlloc);}
516 return JParserValFact_getFirstVal(
this); }
518 return JParserValFact_manageFirstVal(
this); }
520 JParserValFact_termFirstVal(
this); }
522 JParserValFact_destructor(
this); }
548 JVal* mkString(
const char* v);
552 JVal* mkDouble(
double v);
564 JVal* mkBoolean(
bool v);
584#define JValFact_mkString(o, v) JValFact_mkVal(o, JVType_String, v)
585#define JValFact_mkDouble(o, v) JValFact_mkVal(o, JVType_Double, &v)
586#define JValFact_mkInt(o, v) JValFact_mkVal(o, JVType_Int, &v)
587#define JValFact_mkLong(o, v) JValFact_mkVal(o, JVType_Long, &v)
588#define JValFact_mkBoolean(o, v) JValFact_mkVal(o, JVType_Boolean, &v)
589#define JValFact_mkNull(o) JValFact_mkVal(o, JVType_Null, 0)
590#define JValFact_mkObject(o) JValFact_mkVal(o, JVType_Object, 0)
591#define JValFact_mkArray(o) JValFact_mkVal(o, JVType_Array, 0)
592BA_API
void JValFact_constructor(
598 JValFact_constructor(
this,vAlloc, dAlloc); }
600 return JValFact_mkString(
this, v); }
602 return JValFact_mkDouble(
this, v); }
604 return JValFact_mkInt(
this, v); }
606 return JValFact_mkLong(
this, v); }
608 BaBool b = v ? TRUE : FALSE;
609 return JValFact_mkBoolean(
this, b); }
611 return JValFact_mkNull(
this); }
613 return JValFact_mkObject(
this); }
615 return JValFact_mkArray(
this); }
JParserValFact(AllocatorIntf *vAlloc, AllocatorIntf *dAlloc)
create a JParserValFact JVal factory instance.
Definition: JVal.h:512
JVal * manageFirstVal()
Similar to getFirstVal, but you must manage the JVal tree as the value is detached from the JParserVa...
Definition: JVal.h:517
~JParserValFact()
The destructor terminates all nodes not managed.
Definition: JVal.h:521
void termFirstVal()
Terminate the syntax tree such that the JParserValFact instance can be reused when the JParser instan...
Definition: JVal.h:519
JVal * getFirstVal()
Returns the root of the JVal syntax tree.
Definition: JVal.h:515
const char * getName()
Returns the member name if this value is part of a JSON object.
Definition: JVal.h:386
void setLong(JErr *e, S64 v)
Sets a new integer value or changes the JSON type and sets the integer value.
Definition: JVal.h:407
JVal * mkDouble(double v)
Make a float.
Definition: JVal.h:601
char * manageString(JErr *e)
Similar to getString, but you must manage the value as the value is detached from the tree.
Definition: JVal.h:384
JVal * mkLong(S64 v)
Make a long integer.
Definition: JVal.h:605
JVal * mkInt(S32 v)
Make an integer.
Definition: JVal.h:603
JVal * mkBoolean(bool v)
Make a boolean.
Definition: JVal.h:607
int addMember(JErr *e, const char *memberName, JVal *child, AllocatorIntf *dAlloc)
Add a child to an object.
Definition: JVal.h:421
void setString(JErr *e, char *v)
Sets a string value and changes the JSON type if needed.
Definition: JVal.h:415
void terminate(AllocatorIntf *vAlloc, AllocatorIntf *dAlloc)
Terminate the node and all sub nodes.
Definition: JVal.h:426
S64 getLong(JErr *e)
Returns the integer as a long value for an integer JVal type or attempts to convert the value to a lo...
Definition: JVal.h:374
bool isObjectMember()
Returns true if this is a child element in an object.
Definition: JVal.h:417
JVal * getArray(JErr *e)
Returns the first child if an array.
Definition: JVal.h:396
JVal * getNextElem()
Returns the next element if the parent is an object or an array.
Definition: JVal.h:392
JVType
The JSON types.
Definition: JParser.h:103
JVal * mkNull()
Make a null value.
Definition: JVal.h:610
struct JValFact JValFact
The JValFact enables one to manually create a JVal syntax tree or add nodes to an existing syntax tre...
JVal * manageJ(JErr *e)
Similar to getJ, but you must manage the JVal as the value is detached from the tree.
Definition: JVal.h:400
JVal * getObject(JErr *e)
Returns the first child if an object.
Definition: JVal.h:394
JVal * getJ(JErr *e)
Returns the first child if an array or object.
Definition: JVal.h:398
size_t getNameLen()
Returns the member-name length.
Definition: JVal.h:388
double getDouble(JErr *e)
Returns the double value for a JVal float or attempts to convert the value to a float.
Definition: JVal.h:376
BaBool getBoolean(JErr *e)
Returns the boolean value for a boolean JVal type or false if the JVal is JVType_Null.
Definition: JVal.h:378
JVal * mkString(const char *v)
Make a string.
Definition: JVal.h:599
JVal * get(JErr *err, const char *fmt,...)
Get any type of value(s) from a JVal node or JVal tree.
Definition: JVal.h:365
JVal * mkArray()
Make a JSON array.
Definition: JVal.h:614
S32 getInt(JErr *e)
Returns the integer value for an integer JVal type or attempts to convert the value to an integer.
Definition: JVal.h:372
JVType getType()
Returns the JSON type.
Definition: JVal.h:361
JVal * mkObject()
Make a JSON object.
Definition: JVal.h:612
JVal * vget(JErr *err, const char **fmt, va_list *argList)
Equivalent to get with variable argument list replaced by argList.
Definition: JVal.h:363
size_t getStringLen()
Returns the string length.
Definition: JVal.h:382
char * manageName()
Similar to getName, but you must manage the value as the value is detached from the tree.
Definition: JVal.h:390
int add(JErr *e, JVal *child)
Add a child to an array.
Definition: JVal.h:424
S32 getLength(JErr *e)
Returns the elements left in the list.
Definition: JVal.h:402
void setBoolean(JErr *e, BaBool v)
Sets a new boolean value or changes the JSON type and sets the boolean value.
Definition: JVal.h:411
void setDouble(JErr *e, double v)
Sets a new float value or changes the JSON type to float and sets the float value.
Definition: JVal.h:409
int unlink(JVal *child)
Remove a child.
Definition: JVal.h:419
void setNull(JErr *e)
Changes the JSON type if not NULL.
Definition: JVal.h:413
const char * getString(JErr *e)
Returns the string as a const or returns NULL if the JVAL is a NULL type.
Definition: JVal.h:380
JValFact(AllocatorIntf *vAlloc, AllocatorIntf *dAlloc)
create a JValFact JVal factory instance.
Definition: JVal.h:597
void setInt(JErr *e, S32 v)
Sets a new integer value or changes the JSON type and sets the integer value.
Definition: JVal.h:405
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
JParserValFact is the JVal JSON parser factory class.
Definition: JVal.h:461
The JValFact enables one to manually create a JVal syntax tree or add nodes to an existing syntax tre...
Definition: JVal.h:537
JVal represents a value in a JSON tree.
Definition: JVal.h:73