Barracuda Application Server C/C++ Reference
NO
|
44 #include <TargConfig.h>
53 #define UBJ_ALIGNMT uintptr_t
55 #define UBJ_POINTER_NOT_ALIGNED(p) \
56 (0 != ((uintptr_t)p & (sizeof(UBJ_ALIGNMT) - 1)))
59 #define UBJPARS_STACK_LEN 3
155 void UBJVal_setMinInteger(
UBJVal* o, S64 in);
201 #define UBJPIntf_constructor(o,serviceMA) (o)->service=serviceMA
202 #define UBJPIntf_destructor(o)
203 #define UBJPIntf_service(o,v,recLev) (o)->service(o,v,recLev)
207 UBJPIntf_constructor(
this, s);
209 inline UBJPIntf::~UBJPIntf() {
210 UBJPIntf_destructor(
this);
248 int parse(
const U8* buf, U32 size);
272 const U8* lxTokenPtr;
292 int memberNameLen,
int extraStackLen);
293 #define UBJParser_destructor(o)
294 int UBJParser_parse(
UBJParser* o,
const U8* buf, U32 size);
295 #define UBJParser_getIndex(o) (o)->stack[(o)->stackIx].ix
296 #define UBJParser_getCount(o) (o)->stack[(o)->stackIx].count
297 #define UBJParser_getStatus(o) (o)->status
301 UBJPIntf* intf,
char* name,
int memberNameLen,
int extraStackLen) {
302 UBJParser_constructor(
this, intf, name, memberNameLen, extraStackLen);
305 UBJParser_destructor(
this);
308 return UBJParser_parse(
this, buf, size);
311 return UBJParser_getIndex(
this);
314 return UBJParser_getCount(
this);
317 return UBJParser_getStatus(
this);
349 #define UBJEBuf_constructor(o, flushCBM, dataM, dlenM) \
350 (o)->flushCB=flushCBM,(o)->data=dataM,(o)->dlen=dlenM,(o)->cursor=0
351 #define UBJEBuf_destructor(o)
355 UBJEBuf_constructor(
this, cb,buf,bufLen);
357 inline UBJEBuf::~UBJEBuf() {
358 UBJEBuf_destructor(
this);
444 int string(
const char* s, S32 len);
484 int vset(
const char** fmt, va_list* argList,
bool isObj);
514 int set(
const char* fmt, ...);
532 #define UBJE_MEMBER(o, m) #m, (o)->m
534 #define UBJEncoder_constructor(o, ubjsBuf) \
535 memset(o,0,sizeof(UBJEncoder)),(o)->buf=ubjsBuf
536 #define UBJEncoder_destructor(o)
537 #define UBJEncoder_reset(o) ((o)->status=0,(o)->val.name=0,o->buf->cursor=0,0)
544 int UBJEncoder_vset(
UBJEncoder* o,
const char** fmt,va_list* argList,
int isObj);
545 int UBJEncoder_set(
UBJEncoder* o,
const char* fmt, ...);
550 #define UBJEncoder_setName(o,v) ((o)->val.name=(char*)v)
551 #define UBJEncoder_null(o) ((o)->val.t=UBJT_Null,UBJEncoder_val(o))
552 #define UBJEncoder_boolean(o,v) \
553 ((o)->val.t=UBJT_Boolean,(o)->val.u.uint8=v,UBJEncoder_val(o))
554 #define UBJEncoder_uint8(o,v) \
555 ((o)->val.t=UBJT_Uint8,(o)->val.u.uint8=v,UBJEncoder_val(o))
556 #define UBJEncoder_int8(o,v) \
557 ((o)->val.t=UBJT_Int8,(o)->val.u.int8=v,UBJEncoder_val(o))
558 #define UBJEncoder_character(o,v) \
559 ((o)->val.t=UBJT_Char,(o)->val.u.int8=v,UBJEncoder_val(o))
560 #define UBJEncoder_int16(o,v) \
561 ((o)->val.t=UBJT_Int16,(o)->val.u.int16=v,UBJEncoder_val(o))
562 #define UBJEncoder_int32(o,v) \
563 ((o)->val.t=UBJT_Int32,(o)->val.u.int32=v,UBJEncoder_val(o))
564 #define UBJEncoder_int64(o,v) \
565 ((o)->val.t=UBJT_Int64,(o)->val.u.int64=v,UBJEncoder_val(o))
566 #define UBJEncoder_float64(o,v) \
567 ((o)->val.t=UBJT_Float64,(o)->val.u.float64=v,UBJEncoder_val(o))
568 #define UBJEncoder_float32(o,v) \
569 ((o)->val.t=UBJT_Float32,(o)->val.u.float32=v,UBJEncoder_val(o))
570 #define UBJEncoder_string(o,v,l) \
571 ((o)->val.t=UBJT_String,(o)->val.u.string=v,(o)->val.len=l,UBJEncoder_val(o))
572 #define UBJEncoder_beginArray(o,count, sType) \
573 ((o)->val.t=UBJT_BeginArray,(o)->val.len=count, \
574 (o)->val.x=sType,UBJEncoder_val(o))
575 #define UBJEncoder_beginObject(o,count, sType) \
576 ((o)->val.t=UBJT_BeginObject,(o)->val.len=count, \
577 (o)->val.x=sType,UBJEncoder_val(o))
578 #define UBJEncoder_endArray(o) ((o)->val.t=UBJT_EndArray,UBJEncoder_val(o))
579 #define UBJEncoder_endObject(o) ((o)->val.t=UBJT_EndObject,UBJEncoder_val(o))
583 UBJEncoder_constructor(
this, b);
586 UBJEncoder_destructor(
this);
589 return UBJEncoder_setName(
this, n);
592 return UBJEncoder_null(
this);
595 return UBJEncoder_boolean(
this, b ? 1 : 0);
598 return UBJEncoder_uint8(
this, v);
601 return UBJEncoder_int8(
this, v);
604 return UBJEncoder_character(
this, v);
607 return UBJEncoder_int16(
this, v);
610 return UBJEncoder_int32(
this, v);
613 return UBJEncoder_int64(
this, v);
616 return UBJEncoder_float64(
this, v);
619 return UBJEncoder_float32(
this, v);
622 return UBJEncoder_string(
this, s, len);
625 return UBJEncoder_beginArray(
this, count, t);
628 return UBJEncoder_beginObject(
this, count, t);
631 return UBJEncoder_endArray(
this);
634 return UBJEncoder_endObject(
this);
637 UBJEncoder_reset(
this);
640 return UBJEncoder_vset(
this, fmt, argList, isObj ? 1 : 0);
646 status = UBJEncoder_vset(
this, &fmt, &varg, 0);
UBJT
UBJSON Value Type: See UBJVal::t and the UBJSON type reference for more information.
Definition: ubjson.h:65
int parse(const U8 *buf, U32 size)
Parse a UBJSON chunk.
Definition: ubjson.h:307
int beginObject(S32 count=-1, UBJT type=UBJT_InvalidType)
Begin formatting an object.
Definition: ubjson.h:627
@ UBJT_NoOp
Type UBJT_NoOp.
Definition: ubjson.h:68
UBJEBuf(UBJEBuf_FlushCB cb, U8 *buf, S32 bufLen)
Initialize the UBJSON Encoder buffer.
Definition: ubjson.h:354
@ UBJT_EndObject
Type UBJT_EndObject.
Definition: ubjson.h:83
@ UBJEStatus_TypeMismatch
The value set does not mach type set for Optimized Strongly Typed
Definition: ubjson.h:375
~UBJEncoder()
Destructor.
Definition: ubjson.h:585
@ UBJT_Int8
Type UBJT_Int8.
Definition: ubjson.h:70
The UBJSON parser parses a binary UBJSON stream and calls the UBJPIntf callback interface for each pa...
Definition: ubjson.h:221
~UBJParser()
Destructor.
Definition: ubjson.h:304
@ UBJT_String
Type UBJT_String.
Definition: ubjson.h:79
int getStatus()
Returns the parser status.
Definition: ubjson.h:316
int int8(S8 v)
Set int8.
Definition: ubjson.h:600
int getCount()
Returns the length of the optimized container when type (t) is UBJT_Count.
Definition: ubjson.h:313
UBJPIntf(UBJPIntf_Service s)
Create the callback interface object.
Definition: ubjson.h:206
int beginArray(S32 count=-1, UBJT type=UBJT_InvalidType)
Begin formatting an array.
Definition: ubjson.h:624
UBJParser(UBJPIntf *intf, char *name, int memberNameLen, int extraStackLen=0)
Create the callback interface object.
Definition: ubjson.h:300
UBJEStatus
UBJSON Encoder status.
Definition: ubjson.h:364
S16 int16
Use when 't' is UBJT_Int16.
Definition: ubjson.h:124
@ UBJPStatus_Done
The parser completed parsing a new UBJSON object, but found the start of a new object in the provided...
Definition: ubjson.h:99
S32 len
When t=UBJT_Count: container len, When t=UBJT_String: string chunk len.
Definition: ubjson.h:135
S8 int8
Use when 't' is UBJT_Uint8.
Definition: ubjson.h:122
int float64(double v)
Set float64.
Definition: ubjson.h:615
@ UBJT_Uint8
Type UBJT_Uint8.
Definition: ubjson.h:71
float float32
Use when 't' is UBJT_Float32.
Definition: ubjson.h:129
@ UBJPStatus_IntfErr
The UBJParserIntf interface reported a problem.
Definition: ubjson.h:110
@ UBJT_Null
Type UBJT_Null.
Definition: ubjson.h:67
int vset(const char **fmt, va_list *argList, bool isObj)
See UBJEncoder:set for details.
Definition: ubjson.h:639
const char * string
Use when 't' is UBJT_String.
Definition: ubjson.h:131
@ UBJT_Int16
Type UBJT_Int16.
Definition: ubjson.h:72
int boolean(bool b)
Set boolean.
Definition: ubjson.h:594
int endArray()
End of array.
Definition: ubjson.h:630
int float32(float v)
Set float32.
Definition: ubjson.h:618
void reset()
Resets the UBJEBuf cursor (the buffer provided in the constructor)
Definition: ubjson.h:636
U8 uint8
Use when 't' is UBJT_Uint8 or UBJT_Boolean.
Definition: ubjson.h:121
int int16(S16 v)
Set int16.
Definition: ubjson.h:606
The UBJSON Encoder buffer is used by the encoder UBJEncoder.
Definition: ubjson.h:333
UBJSON Encoder.
Definition: ubjson.h:394
The UBJPIntf interface class is the interface between the parser and an object that implements the UB...
Definition: ubjson.h:189
int uint8(U8 v)
Set uint8.
Definition: ubjson.h:597
int getIndex()
Returns the current container index position when parsing an optimized container.
Definition: ubjson.h:310
@ UBJT_InvalidType
Not a valid UBJSON type.
Definition: ubjson.h:66
@ UBJT_Int32
Type UBJT_Int32.
Definition: ubjson.h:73
struct UBJParser UBJParser
The UBJSON parser parses a binary UBJSON stream and calls the UBJPIntf callback interface for each pa...
@ UBJEStatus_Unknown
Unknown type (Must be a type from UBJT)
Definition: ubjson.h:381
int character(char v)
Set 'char'.
Definition: ubjson.h:603
@ UBJPStatus_DoneEOS
The parser completed parsing a new UBJSON object.
Definition: ubjson.h:94
@ UBJT_BeginArray
Type UBJT_BeginArray.
Definition: ubjson.h:81
@ UBJEStatus_LengthRequired
Length required for Optimized Strongly Typed Container.
Definition: ubjson.h:369
S64 int64
Use when 't' is UBJT_Int64.
Definition: ubjson.h:126
@ UBJPStatus_ParseErr
UBJSON Parse error.
Definition: ubjson.h:106
int string(const char *s, S32 len)
Set string.
Definition: ubjson.h:621
@ UBJPStatus_NeedMoreData
The parser requires more data to complete.
Definition: ubjson.h:102
char * name
Object member name: set when parent is an object.
Definition: ubjson.h:141
int(* UBJPIntf_Service)(struct UBJPIntf *o, UBJVal *v, int recLevel)
Parser callback function used by interface class UBJPIntf.
Definition: ubjson.h:181
@ UBJEStatus_FlushErr
UBJEBuf_FlushCB returned a non zero value.
Definition: ubjson.h:366
int setName(const char *n)
Set member name.
Definition: ubjson.h:588
S32 x
When t=UBJT_Count: type UBJT.
Definition: ubjson.h:138
S32 int32
Use when 't' is UBJT_Int32.
Definition: ubjson.h:125
int endObject()
End of object.
Definition: ubjson.h:633
int int32(S32 v)
Set int32.
Definition: ubjson.h:609
char ch
Use when 't' is UBJT_Char.
Definition: ubjson.h:123
@ UBJT_Int64
Type UBJT_Int64.
Definition: ubjson.h:74
@ UBJPStatus_Overflow
Parsed data/array/object too big.
Definition: ubjson.h:114
int int64(S64 v)
Set int64.
Definition: ubjson.h:612
@ UBJEStatus_ok
No error.
Definition: ubjson.h:384
struct UBJPIntf UBJPIntf
The UBJPIntf interface class is the interface between the parser and an object that implements the UB...
@ UBJT_BeginObject
Type UBJT_BeginObject.
Definition: ubjson.h:80
int(* UBJEBuf_FlushCB)(struct UBJEBuf *o, int sizeRequired)
UBJSON Encoder buffer callback can be used for flushing the buffer or for expanding the buffer.
Definition: ubjson.h:329
@ UBJT_Count
Type UBJT_Count.
Definition: ubjson.h:82
UBJParser Value (passed into the parser callback interface UBJPIntf)
Definition: ubjson.h:118
@ UBJEStatus_StackOverflow
Object depth exceeding internal stack.
Definition: ubjson.h:372
UBJPStatus
UBJSON Parser Status.
Definition: ubjson.h:90
@ UBJT_HNumber
Type UBJT_HNumber.
Definition: ubjson.h:77
UBJEncoder(UBJEBuf *buf)
Create/initialize an UBJEncoder instance.
Definition: ubjson.h:582
double float64
Use when 't' is UBJT_Float64.
Definition: ubjson.h:128
@ UBJT_Float64
Type UBJT_Float64.
Definition: ubjson.h:76
U8 t
UBJSON Type, t is set to one of the types in UBJT.
Definition: ubjson.h:144
@ UBJT_Char
Type UBJT_Char.
Definition: ubjson.h:78
@ UBJT_Boolean
Type UBJT_Boolean.
Definition: ubjson.h:69
struct UBJEBuf UBJEBuf
The UBJSON Encoder buffer is used by the encoder UBJEncoder.
@ UBJT_Float32
Type UBJT_Float32.
Definition: ubjson.h:75
int set(const char *fmt,...)
Encode/serialize C structs/data to UBJSON using formatted output.
Definition: ubjson.h:642
The event based parser uses a stack instead of recursion and the UBJPStackNode type represent one ent...
Definition: ubjson.h:166
struct UBJEncoder UBJEncoder
UBJSON Encoder.
@ UBJEStatus_Unbalanced
(curly) bracket start/end mismatch
Definition: ubjson.h:378
@ UBJT_EndArray
Type UBJT_EndArray.
Definition: ubjson.h:84
int null()
Set UBJSON NULL.
Definition: ubjson.h:591