40#include <TargConfig.h>
62BA_API
int basprintf(
char* buf,
const char* fmt, ...);
73BA_API
int basnprintf(
char* buf,
int len,
const char* fmt, ...);
163 int vprintf(
const char* fmt, va_list argList);
177 int printf(
const char* fmt, ...);
186 int write(
const void* data,
int len);
192 int write(
const char* buf);
199 void setBuf(
char* buf,
int size);
223 int b64Encode(
const void* data, S32 slen);
231 int b64urlEncode(
const void* source, S32 slen,
bool padding);
253#define BufPrint_putcMacro(o, c) do { \
254 if((o)->cursor == (o)->bufSize) \
256 if((o)->flushCB(o, 1)) \
259 (o)->buf[(o)->cursor++] = c; \
265#define BufPrint_getUserData(o) (o)->userData
266#define BufPrint_erase(o) (o)->cursor=0
267#define BufPrint_getBuf(o) (o)->buf
268#define BufPrint_setBuf(o, b, size) (o)->buf=b,(o)->bufSize=size,(o)->cursor=0
269#define BufPrint_getBufSize(o) (o)->cursor
270BA_API
void BufPrint_constructor(
272BA_API
void BufPrint_constructor2(
274#define BufPrint_destructor(o)
275BA_API
int BufPrint_vprintf(
BufPrint* o,
const char* fmt, va_list argList);
276BA_API
int BufPrint_printf(
BufPrint* o,
const char* fmt, ...);
277BA_API
int BufPrint_write(
BufPrint* o,
const void* data,
int len);
278BA_API
int BufPrint_putc(
BufPrint* o,
int c);
279BA_API
int BufPrint_flush(
BufPrint* o);
280#define BufPrint_write2(o, data) BufPrint_write(o, data, -1)
281BA_API
int BufPrint_b64Encode(
BufPrint* o,
const void* source, S32 slen);
282BA_API
int BufPrint_b64urlEncode(
283 BufPrint* o,
const void* source, S32 slen, BaBool padding);
285BA_API
int BufPrint_jsonString(
BufPrint* o,
const char* str);
289 return BufPrint_getUserData(
this);
292 BufPrint_constructor(
this, userData,
flush); }
295 BufPrint_constructor2(
this,buf,size,userData,
flush); }
297 return BufPrint_vprintf(
this, fmt, argList); }
299 int retv; va_list varg;
301 retv = BufPrint_vprintf(
this, fmt, varg);
306 return BufPrint_getBuf(
this); }
308 BufPrint_setBuf(
this, buffer, size); }
310 return BufPrint_getBufSize(
this); }
312 BufPrint_erase(
this); }
314 return BufPrint_putc(
this, c); }
316 return BufPrint_write(
this, data, len); }
318 return BufPrint_write2(
this, data); }
320 return BufPrint_flush(
this);
323 return BufPrint_b64Encode(
this, source, slen);
326 return BufPrint_b64urlEncode(
this, source, slen, padding?TRUE:FALSE);
329 return BufPrint_jsonString(
this, str);
void erase()
resets the cursor, thus erasing the data in the buffer
Definition: BufPrint.h:311
U32 getBufSize()
Returns current size of internal formatted data.
Definition: BufPrint.h:309
void * getUserData()
Returns the user data pointer set in the constructor.
Definition: BufPrint.h:288
char * getBuf()
Returns a pointer to the internal buffer.
Definition: BufPrint.h:305
BufPrint(void *userData=0, BufPrint_Flush flush=0)
BufPrint constructor.
Definition: BufPrint.h:291
int baputc(int c)
print character (wrapper for BufPrint_putc)
Definition: BufPrint.h:313
int write(const void *data, int len)
Write data to the buffer.
Definition: BufPrint.h:315
int vprintf(const char *fmt, va_list argList)
The printf function's format is identical to the standard ANSI vprintf function.
Definition: BufPrint.h:296
int jsonString(const char *str)
Print and escape a string such that a browser can run the JavaScript 'eval' function and produce a st...
Definition: BufPrint.h:328
int flush()
Flush buffer.
Definition: BufPrint.h:319
int b64urlEncode(const void *source, S32 slen, bool padding)
Encode binary data as Base64url.
Definition: BufPrint.h:325
int(* BufPrint_Flush)(struct BufPrint *o, int sizeRequired)
BufPrint flush callback function.
Definition: BufPrint.h:110
int printf(const char *fmt,...)
The printf function's format is identical to the standard ANSI printf function, but with the followin...
Definition: BufPrint.h:298
struct BufPrint BufPrint
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
void setBuf(char *buf, int size)
Set the buffer used by BufPrint.
Definition: BufPrint.h:307
int b64Encode(const void *data, S32 slen)
Encode binary data as Base64.
Definition: BufPrint.h:322
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
Definition: BufPrint.h:122