40#include <HttpServer.h>
41#include <BaServerLib.h>
52typedef void (*DynBuffer_OnAllocError)(
struct DynBuffer* o,
int eCode);
71 DynBuffer_OnAllocError onAllocError=0);
110 int expand(
int sizeNeeded);
146 DynBuffer_OnAllocError onAllocError;
154BA_API
void DynBuffer_constructor(
DynBuffer* o,
int startSize,
int expandSize,
156 DynBuffer_OnAllocError onAllocError);
157#define DynBuffer_destructor(o) DynBuffer_release(o)
158BA_API
void DynBuffer_release(
DynBuffer* o);
159BA_API
char* DynBuffer_getBuf(
DynBuffer* o);
160#define DynBuffer_getBufSize(o) BufPrint_getBufSize((BufPrint*)(o))
161#define DynBuffer_getCurPtr(o) (((BufPrint*)(o))->buf+((BufPrint*)(o))->cursor)
162#define DynBuffer_incrementCursor(o,nBytes) ((BufPrint*)(o))->cursor+=nBytes
163#define DynBuffer_getECode(o) ((o)->expandSize < 0 ? (o)->expandSize : 0)
164BA_API
int DynBuffer_expand(
DynBuffer* o,
int sizeNeeded);
165BA_API
const char* DynBuffer_ecode2str(
int eCode);
169inline DynBuffer::DynBuffer(
171 DynBuffer_OnAllocError onAllocError) {
172 DynBuffer_constructor(
this, startSize, expandSize, alloc, onAllocError); }
174 DynBuffer_destructor(
this); }
176 DynBuffer_release(
this); }
178 return DynBuffer_getBuf(
this); }
180 return DynBuffer_getBufSize(
this); }
182 return DynBuffer_getECode(
this); }
184 return DynBuffer_expand(
this, sizeNeeded); }
186 return DynBuffer_getCurPtr(
this); }
188 DynBuffer_incrementCursor(
this, nBytes); }
190 return DynBuffer_ecode2str(eCode); }
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:83
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
Definition: BufPrint.h:122
A dynamic buffer.
Definition: DynBuffer.h:60
void release()
terminate the internal dynamic buffer by calling free
Definition: DynBuffer.h:175
~DynBuffer()
destructor.
Definition: DynBuffer.h:173
int getECode()
Returns the error code if memory allocation failed.
Definition: DynBuffer.h:181
U32 getBufSize()
Returns current size of internal formatted data.
Definition: DynBuffer.h:179
char * getBuf()
Returns a pointer to the internal buffer.
Definition: DynBuffer.h:177
int expand(int sizeNeeded)
force buffer to expand.
Definition: DynBuffer.h:183
void incrementCursor(int nBytes)
Increments the internal cursor position.
Definition: DynBuffer.h:187
char * getCurPtr()
Return a pointer to the internal cursor position in the internal dynamic buffer.
Definition: DynBuffer.h:185
static const char * ecode2str(int eCode)
Convert error code to string.
Definition: DynBuffer.h:189