|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|
UBJSON Encoder.
The encoder performs limited error checking and you can produce incorrect UBJSON data if used incorrectly. Supply matching containers and exact optimized counts. Output is incremental, and an error can leave partial data. Final buffered bytes must be consumed/flushed by the application; the destructor does not flush. The current implementation has not been verified against the complete UBJSON specification. Supply UTF-8 strings and nonempty member names without embedded NUL bytes. UTF-8 is not validated. Empty member names return UBJEStatus_EmptyName. Native floating-point values must be finite; the caller must explicitly encode null for nonfinite values. H numeric text must follow JSON number syntax; the encoder does not validate that syntax.
#include <ubjson.h>
Public Member Functions | |
| UBJEncoder (UBJEBuf *buf) | |
| Create/initialize an UBJEncoder instance. More... | |
| ~UBJEncoder () | |
| No-op destructor; does not flush output or free the borrowed buffer. More... | |
| int | setName (const char *n) |
| Store a name for the next object value; do not use for array elements. More... | |
| int | null () |
| Emit UBJSON null. More... | |
| int | boolean (bool b) |
| Emit one boolean value. More... | |
| int | uint8 (U8 v) |
| Emit one uint8 value. More... | |
| int | int8 (S8 v) |
| Emit one int8 value. More... | |
| int | character (char v) |
| Emit one character value. More... | |
| int | int16 (S16 v) |
| Emit one int16 value. More... | |
| int | int32 (S32 v) |
| Emit one int32 value. More... | |
| int | int64 (S64 v) |
| Emit one int64 value. More... | |
| int | float64 (double v) |
| Emit one float64 value. More... | |
| int | float32 (float v) |
| Emit one float32 value. More... | |
| int | string (const char *s, S32 len) |
| Emit a length-delimited string. More... | |
| int | beginArray (S32 count=-1, UBJT type=UBJT_InvalidType) |
| Begin formatting an array. More... | |
| int | beginObject (S32 count=-1, UBJT type=UBJT_InvalidType) |
| Begin formatting an object. More... | |
| int | endArray () |
| Close the matching current container. More... | |
| int | endObject () |
| Close the matching current container. More... | |
| void | reset () |
| Discard buffered bytes and clear status and the pending member name. More... | |
| int | vset (const char **fmt, va_list *argList, bool isObj) |
| Emit formatted values as for set(), advancing the format cursor. More... | |
| int | set (const char *fmt,...) |
| Encode/serialize C structs/data to UBJSON using formatted output. More... | |