Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
ubjson.h File Reference
#include <TargConfig.h>
#include <stdarg.h>
Include dependency graph for ubjson.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UBJVal
 UBJParser Value (passed into the parser callback interface UBJPIntf) More...
 
struct  UBJPStackNode
 The event based parser uses a stack instead of recursion and the UBJPStackNode type represent one entry in the stack. More...
 
struct  UBJPIntf
 The UBJPIntf interface class is the interface between the parser and an object that implements the UBJPIntf interface. More...
 
struct  UBJParser
 The UBJSON parser parses a binary UBJSON stream and calls the UBJPIntf callback interface for each parsed object/primitive type. More...
 
struct  UBJEBuf
 The UBJSON Encoder buffer is used by the encoder UBJEncoder. More...
 
struct  UBJEncoder
 UBJSON Encoder. More...
 

Macros

#define UBJParser_destructor(o)
 No-op destructor. More...
 
#define UBJParser_getIndex(o)   (o)->stack[(o)->stackIx].ix
 Query the current optimized-container position. More...
 
#define UBJParser_getCount(o)   (o)->stack[(o)->stackIx].count
 Query the current container's declared count. More...
 
#define UBJParser_getStatus(o)   (o)->status
 
#define UBJE_MEMBER(o, m)   #m, (o)->m
 UBJEncoder::set helper macro, used when setting a value for an object. More...
 
#define UBJEncoder_constructor(o, ubjsBuf)    memset(o,0,sizeof(UBJEncoder)),(o)->buf=ubjsBuf
 Initialize the encoder; no allocation, flush, or return value. More...
 
#define UBJEncoder_destructor(o)
 No-op; does not flush or free buffers. More...
 
#define UBJEncoder_reset(o)   ((o)->status=0,(o)->val.name=0,o->buf->cursor=0,0)
 Discard buffered bytes and clear status/name. More...
 
#define UBJEncoder_setName(o, v)   ((o)->val.name=(char*)v)
 Set the pending member name. More...
 
#define UBJEncoder_null(o)   ((o)->val.t=UBJT_Null,UBJEncoder_val(o))
 Encode null. More...
 
#define UBJEncoder_boolean(o, v)    ((o)->val.t=UBJT_Boolean,(o)->val.u.uint8=v,UBJEncoder_val(o))
 Encode a boolean. More...
 
#define UBJEncoder_uint8(o, v)    ((o)->val.t=UBJT_Uint8,(o)->val.u.uint8=v,UBJEncoder_val(o))
 Encode a U8 value. More...
 
#define UBJEncoder_int8(o, v)    ((o)->val.t=UBJT_Int8,(o)->val.u.int8=v,UBJEncoder_val(o))
 Encode a S8 value. More...
 
#define UBJEncoder_character(o, v)    ((o)->val.t=UBJT_Char,(o)->val.u.int8=v,UBJEncoder_val(o))
 Encode a char value. More...
 
#define UBJEncoder_int16(o, v)    ((o)->val.t=UBJT_Int16,(o)->val.u.int16=v,UBJEncoder_val(o))
 Encode a S16 value. More...
 
#define UBJEncoder_int32(o, v)    ((o)->val.t=UBJT_Int32,(o)->val.u.int32=v,UBJEncoder_val(o))
 Encode a S32 value. More...
 
#define UBJEncoder_int64(o, v)    ((o)->val.t=UBJT_Int64,(o)->val.u.int64=v,UBJEncoder_val(o))
 Encode a S64 value. More...
 
#define UBJEncoder_float64(o, v)    ((o)->val.t=UBJT_Float64,(o)->val.u.float64=v,UBJEncoder_val(o))
 Encode a double value. More...
 
#define UBJEncoder_float32(o, v)    ((o)->val.t=UBJT_Float32,(o)->val.u.float32=v,UBJEncoder_val(o))
 Encode a float value. More...
 
#define UBJEncoder_string(o, v, l)    ((o)->val.t=UBJT_String,(o)->val.u.string=v,(o)->val.len=l,UBJEncoder_val(o))
 Encode string bytes without requiring NUL termination. More...
 
#define UBJEncoder_beginArray(o, count, sType)
 Begin an array; emit exactly count children when count is nonnegative. More...
 
#define UBJEncoder_beginObject(o, count, sType)
 Begin an object; emit exactly count named members when count is nonnegative. More...
 
#define UBJEncoder_endArray(o)   ((o)->val.t=UBJT_EndArray,UBJEncoder_val(o))
 End the current array. More...
 
#define UBJEncoder_endObject(o)   ((o)->val.t=UBJT_EndObject,UBJEncoder_val(o))
 End the current object. More...
 

Typedefs

typedef int(* UBJPIntf_Service) (struct UBJPIntf *o, UBJVal *v, int recLevel)
 Receive a parsed UBJSON event synchronously. More...
 
typedef struct UBJPIntf UBJPIntf
 The UBJPIntf interface class is the interface between the parser and an object that implements the UBJPIntf interface. More...
 
typedef struct UBJParser UBJParser
 The UBJSON parser parses a binary UBJSON stream and calls the UBJPIntf callback interface for each parsed object/primitive type. More...
 
typedef int(* UBJEBuf_FlushCB) (struct UBJEBuf *o, int sizeRequired)
 Make room in an encoder buffer by flushing or expanding it. More...
 
typedef struct UBJEBuf UBJEBuf
 The UBJSON Encoder buffer is used by the encoder UBJEncoder. More...
 
typedef struct UBJEncoder UBJEncoder
 UBJSON Encoder. More...
 

Enumerations

enum  UBJT {
  UBJT_InvalidType =0 , UBJT_Null ='Z' , UBJT_NoOp ='N' , UBJT_Boolean ,
  UBJT_Int8 ='i' , UBJT_Uint8 ='U' , UBJT_Int16 ='I' , UBJT_Int32 ='l' ,
  UBJT_Int64 ='L' , UBJT_Float32 ='d' , UBJT_Float64 ='D' , UBJT_HNumber ='H' ,
  UBJT_Char ='C' , UBJT_String ='S' , UBJT_BeginObject ='{' , UBJT_BeginArray ='[' ,
  UBJT_Count ='#' , UBJT_EndObject ='}' , UBJT_EndArray =']'
}
 UBJSON Value Type: See UBJVal::t and the UBJSON type reference for more information. More...
 
enum  UBJPStatus {
  UBJPStatus_DoneEOS =1 , UBJPStatus_Done , UBJPStatus_NeedMoreData = 100 , UBJPStatus_ParseErr = 200 ,
  UBJPStatus_IntfErr , UBJPStatus_Overflow
}
 UBJSON Parser Status. More...
 
enum  UBJEStatus {
  UBJEStatus_FlushErr = -100 , UBJEStatus_LengthRequired , UBJEStatus_StackOverflow , UBJEStatus_TypeMismatch ,
  UBJEStatus_Unbalanced , UBJEStatus_Unknown , UBJEStatus_EmptyName , UBJEStatus_ok =0
}
 UBJSON Encoder status. More...
 

Functions

void UBJVal_setMinInteger (UBJVal *o, S64 in)
 Choose the smallest supported integer representation. More...
 
void UBJParser_constructor (UBJParser *o, UBJPIntf *intf, char *name, int memberNameLen, int extraStackLen)
 Create the callback interface object. More...
 
int UBJParser_parse (UBJParser *o, const U8 *buf, U32 size)
 Feed or resume parsing a top-level UBJSON object/array. More...
 
int UBJEncoder_vset (UBJEncoder *o, const char **fmt, va_list *argList, int isObj)
 Emit formatted values as for set(), advancing the format cursor. More...
 
int UBJEncoder_set (UBJEncoder *o, const char *fmt,...)
 Encode/serialize C structs/data to UBJSON using formatted output. More...