Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
BufPrint Struct Reference

Detailed Description

The BufPrint class, which implements a compact printf-style formatter, is a base class used by several other classes.

This class does not allocate memory for the buffer. Thus, any class using BufPrint must provide a buffer BufPrint can use. The output from printf is formatted in the buffer passed into the constructor. BufPrint calls the callback function BufPrint_Flush when the buffer is full. See BufPrint_Flush for additional details.

#include <BufPrint.h>

Inheritance diagram for BufPrint:

Public Member Functions

 BufPrint (void *userData=0, BufPrint_Flush flush=0)
 BufPrint constructor. More...
 
 BufPrint (char *buf, int size, void *userData=0, BufPrint_Flush flush=0)
 Initialize a writer using caller-owned storage. More...
 
void * getUserData ()
 
int vprintf (const char *fmt, va_list argList)
 Format arguments into this writer. More...
 
int printf (const char *fmt,...)
 Format values using the compact BAS formatter. More...
 
int baputc (int c)
 Append one byte (C function: BufPrint_putc). More...
 
int write (const void *data, int len)
 Append bytes, flushing or expanding through the callback as needed. More...
 
int write (const char *buf)
 Append a NUL-terminated string (C macro: BufPrint_write2). More...
 
void setBuf (char *buf, int size)
 Replace borrowed storage and reset the cursor, discarding pending data. More...
 
char * getBuf ()
 Returns a pointer to the internal buffer. More...
 
U32 getBufSize ()
 
void erase ()
 resets the cursor, thus erasing the data in the buffer More...
 
int flush ()
 Deliver pending bytes to the callback with sizeRequired zero. More...
 
int b64Encode (const void *data, S32 slen)
 Append standard Base64 with = padding, without a NUL terminator. More...
 
int b64urlEncode (const void *source, S32 slen, bool padding)
 Append Base64url using - and _, without a NUL terminator. More...
 
int jsonString (const char *str, size_t len)
 Append a complete quoted JSON string. More...