Barracuda Application Server C/C++ Reference
NO
|
Classes | |
struct | BufPrint |
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by several other classes. More... | |
Typedefs | |
typedef int(* | BufPrint_Flush) (struct BufPrint *o, int sizeRequired) |
BufPrint flush callback function. More... | |
typedef struct BufPrint | BufPrint |
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by several other classes. More... | |
Functions | |
void * | BufPrint::getUserData () |
Returns the user data pointer set in the constructor. | |
BufPrint::BufPrint (void *userData=0, BufPrint_Flush flush=0) | |
BufPrint constructor. More... | |
BufPrint::BufPrint (char *buf, int size, void *userData=0, BufPrint_Flush flush=0) | |
BufPrint constructor. More... | |
int | BufPrint::vprintf (const char *fmt, va_list argList) |
The printf function's format is identical to the standard ANSI vprintf function. More... | |
int | BufPrint::printf (const char *fmt,...) |
The printf function's format is identical to the standard ANSI printf function, but with the following extensions: More... | |
char * | BufPrint::getBuf () |
Returns a pointer to the internal buffer. More... | |
void | BufPrint::setBuf (char *buf, int size) |
Set the buffer used by BufPrint. More... | |
U32 | BufPrint::getBufSize () |
Returns current size of internal formatted data. | |
void | BufPrint::erase () |
resets the cursor, thus erasing the data in the buffer | |
int | BufPrint::baputc (int c) |
print character (wrapper for BufPrint_putc) | |
int | BufPrint::write (const void *data, int len) |
Write data to the buffer. More... | |
int | BufPrint::write (const char *buf) |
Used for sending a zero terminated string to the client. More... | |
int | BufPrint::flush () |
Flush buffer. | |
int | BufPrint::b64Encode (const void *data, S32 slen) |
Encode binary data as Base64. More... | |
int | BufPrint::b64urlEncode (const void *source, S32 slen, bool padding) |
Encode binary data as Base64url. More... | |
int | BufPrint::jsonString (const char *str) |
Print and escape a string such that a browser can run the JavaScript 'eval' function and produce a string identical to the string the 'str' argument points to. More... | |
The BufPrint class, which implements an ANSI compatible printf method, 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.
typedef int(* BufPrint_Flush) (struct BufPrint *o, int sizeRequired) |
BufPrint flush callback function.
A BufPrint instance calls the flush callback function when the buffer is full or when BufPrint::flush is called. The callback can either extend the buffer or flush and reset the buffer.
The following default callback is set if no callback is installed when calling the BufPrint constructor:
o | the object. BufPrint is typically upcasted to the derived object. |
sizeRequired | the minimum size the buffer must expand. Note that sizeRequired will be zero when the callback is called via BufPrint::flush |
int BufPrint::b64Encode | ( | const void * | data, |
S32 | slen | ||
) |
Encode binary data as Base64.
data | binary data or string to be encoded as B64. |
slen | the data size. |
int BufPrint::b64urlEncode | ( | const void * | source, |
S32 | slen, | ||
bool | padding | ||
) |
Encode binary data as Base64url.
source | binary data or string to be encoded as B64. |
slen | the data size. |
padding | add padding characters. |
BufPrint::BufPrint | ( | char * | buf, |
int | size, | ||
void * | userData = 0 , |
||
BufPrint_Flush | flush = 0 |
||
) |
BufPrint constructor.
When using this constructor, make sure to also call setBuf(). C constructor name: BufPrint_constructor2
buf | the buffer |
size | the buffer size |
userData | an optional argument stored in the BufPrint object and accessible in the flush callback. |
flush | a pointer to the flush callback function. See BufPrint_Flush for details. |
BufPrint::BufPrint | ( | void * | userData = 0 , |
BufPrint_Flush | flush = 0 |
||
) |
BufPrint constructor.
When using this constructor, make sure to also call setBuf(). C constructor name: BufPrint_constructor
userData | an optional argument stored in the BufPrint object and accessible in the flush callback. |
flush | a pointer to the flush callback function. See BufPrint_Flush for details. |
char * BufPrint::getBuf | ( | ) |
Returns a pointer to the internal buffer.
Please note that the buffer returned by this method is not zero terminated.
int BufPrint::jsonString | ( | const char * | str | ) |
Print and escape a string such that a browser can run the JavaScript 'eval' function and produce a string identical to the string the 'str' argument points to.
The string must be ASCII or UTF8. A UTF8 string is converted to JavaScript Unicode i.e. to \uxxxx.
The function can, for example, be used if the server generates a JSON response or generates dynamic JavaScript in a CSP page.
int BufPrint::printf | ( | const char * | fmt, |
... | |||
) |
The printf function's format is identical to the standard ANSI printf function, but with the following extensions:
fmt | See vprintf in the C Standard Library for more information. |
void BufPrint::setBuf | ( | char * | buf, |
int | size | ||
) |
Set the buffer used by BufPrint.
buf | the buffer |
size | the buffer size |
int BufPrint::vprintf | ( | const char * | fmt, |
va_list | argList | ||
) |
The printf function's format is identical to the standard ANSI vprintf function.
See BufPrint::printf for the format flags.
fmt | See vprintf in the C Standard Library for more information. |
argList | See vprintf in the C Standard Library for more information. |
int BufPrint::write | ( | const char * | buf | ) |
Used for sending a zero terminated string to the client.
C method name is BufPrint_write2.
buf | a reference to the string. |
int BufPrint::write | ( | const void * | data, |
int | len | ||
) |
Write data to the buffer.
data | pointer to data. |
len | size of data. |