94 int b64enc(
const void* source, S32 slen);
106 int vFmtString(
const char* fmt,va_list argList);
118 int setJV(
struct JVal* val,
bool iterateNext=
false);
161 int set(
const char* fmt, ...);
226#define JEncoder_destructor(o) JEncoder_flush(o)
227BA_API
int JEncoder_flush(
JEncoder* o);
228BA_API
int JEncoder_commit(
JEncoder* o);
229#define JEncoder_getErr(o) (o)->err
230BA_API
int JEncoder_setInt(
JEncoder* o, S32 val);
231BA_API
int JEncoder_setLong(
JEncoder* o, S64 val);
233#define JEncoder_setDouble JEncoder_setInt
235BA_API
int JEncoder_setDouble(
JEncoder* o,
double val);
238BA_API
int JEncoder_fmtString(
JEncoder* o,
const char* fmt,...);
239BA_API
int JEncoder_vFmtString(
240 JEncoder* o,
const char* fmt,va_list argList);
241BA_API
int JEncoder_setString(
JEncoder* o,
const char* val);
242BA_API
int JEncoder_b64enc(
JEncoder* o,
const void* source, S32 slen);
243BA_API
int JEncoder_setBoolean(
JEncoder* o, BaBool val);
244BA_API
int JEncoder_setNull(
JEncoder* o);
245BA_API
int JEncoder_setJV(
247BA_API
int JEncoder_vSetJV(
248 JEncoder* o,
const char** fmt,va_list* argList);
249BA_API
int JEncoder_set(
JEncoder* o,
const char* fmt, ...);
250BA_API
int JEncoder_setName(
JEncoder* o,
const char* name);
251BA_API
int JEncoder_beginObject(
JEncoder* o);
252BA_API
int JEncoder_endObject(
JEncoder* o);
253BA_API
int JEncoder_beginArray(
JEncoder* o);
254BA_API
int JEncoder_endArray(
JEncoder* o);
255#define JEncoder_getBufPrint(o) (o)->out
259 JEncoder_constructor(
this,err, out); }
260inline JEncoder::~JEncoder() {
261 JEncoder_destructor(
this); }
263 return JEncoder_setInt(
this, val); }
265 return JEncoder_setLong(
this, val); }
268 return JEncoder_setDouble(
this, val); }
271 int retv; va_list argList;
272 va_start(argList, fmt);
273 retv = JEncoder_fmtString(
this, fmt, argList);
278 return JEncoder_vFmtString(
this, fmt, argList); }
280 return JEncoder_setString(
this, val); }
282 return JEncoder_b64enc(
this, source, slen); }
284 return JEncoder_setBoolean(
this, val ? TRUE : FALSE); }
286 return JEncoder_setNull(
this); }
288 return JEncoder_setJV(
this,val,iterateNext?TRUE:FALSE); }
290 int retv; va_list argList;
291 va_start(argList, fmt);
292 retv=JEncoder_vSetJV(
this,&fmt,&argList);
297 return JEncoder_setName(
this, name); }
299 return JEncoder_beginObject(
this); }
301 return JEncoder_endObject(
this); }
303 return JEncoder_beginArray(
this); }
305 return JEncoder_endArray(
this); }
307 return JEncoder_getErr(
this); }
309 return JEncoder_flush(
this); }
311 return JEncoder_commit(
this); }
313 return JEncoder_getBufPrint(
this); }
319#define JE_MEMBER(o, m) #m, (o)->m
int setJV(struct JVal *val, bool iterateNext=false)
Format a node or a tree of JVal nodes.
Definition: JEncoder.h:287
JEncoder(JErr *err, BufPrint *out)
Create an instance of the JEncoder class.
Definition: JEncoder.h:258
int fmtString(const char *fmt,...)
Converts (according to format 'fmt') and writes to stream.
Definition: JEncoder.h:270
int setLong(S64 val)
Format a long integer value.
Definition: JEncoder.h:264
int setName(const char *name)
Set the member name before calling any of the set<value> members if formatting an object.
Definition: JEncoder.h:296
int setBoolean(bool val)
Format a boolean value.
Definition: JEncoder.h:283
int beginObject()
Begin object formatting.
Definition: JEncoder.h:298
int flush()
Flush JEncoder data to the output stream.
Definition: JEncoder.h:308
int b64enc(const void *source, S32 slen)
Encode and emit (binary) data using B64 encoding.
Definition: JEncoder.h:281
int beginArray()
Begin array formatting.
Definition: JEncoder.h:302
BufPrint * getBufPrint()
Fetch the internal BufPrint object.
Definition: JEncoder.h:312
int setString(const char *val)
Format a string value.
Definition: JEncoder.h:279
int vFmtString(const char *fmt, va_list argList)
Equivalent to fmtString with variable argument list replaced by argList.
Definition: JEncoder.h:277
int setNull()
Set a JSON null value.
Definition: JEncoder.h:285
int endArray()
End array formatting.
Definition: JEncoder.h:304
int endObject()
End object formatting.
Definition: JEncoder.h:300
int setDouble(double val)
Format a double value.
Definition: JEncoder.h:267
int set(const char *fmt,...)
Encode/serialize C structs/data to JSON using formatted output.
Definition: JEncoder.h:289
JErr * getErr()
Returns the JErr object.
Definition: JEncoder.h:306
int commit()
Calls flush and enables the construction of a new object.
Definition: JEncoder.h:310
int setInt(S32 val)
Format an integer value.
Definition: JEncoder.h:262
struct JEncoder JEncoder
The JEncoder can serialize a JSON JVAL syntax tree to the JSON text format.
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
Definition: BufPrint.h:122
The JEncoder can serialize a JSON JVAL syntax tree to the JSON text format.
Definition: JEncoder.h:66
The JSON error container object.
Definition: JParser.h:155
JVal represents a value in a JSON tree.
Definition: JVal.h:73