134 int expand(
int sizeNeeded);
200#define DynBuffer_destructor(o) DynBuffer_release(o)
211#define DynBuffer_getBufSize(o) BufPrint_getBufSize((BufPrint*)(o))
215#define DynBuffer_getCurPtr(o) (((BufPrint*)(o))->buf+((BufPrint*)(o))->cursor)
219#define DynBuffer_incrementCursor(o,nBytes) ((BufPrint*)(o))->cursor+=nBytes
223#define DynBuffer_getECode(o) ((o)->expandSize < 0 ? (o)->expandSize : 0)
void(* DynBuffer_OnAllocError)(struct DynBuffer *o, int eCode)
Report an allocation error synchronously from a buffer operation.
Definition: DynBuffer.h:60
#define DynBuffer_getECode(o)
Read the allocation-error state.
Definition: DynBuffer.h:223
BA_API void DynBuffer_release(DynBuffer *o)
Release the current storage and invalidate borrowed pointers.
BA_API int DynBuffer_expand(DynBuffer *o, int sizeNeeded)
Reserve additional space without advancing the cursor.
#define DynBuffer_getBufSize(o)
Read the payload length.
Definition: DynBuffer.h:211
BA_API char * DynBuffer_getBuf(DynBuffer *o)
Terminate and obtain the current payload.
DynBuffer DynBuffer
A dynamic buffer.
BA_API void DynBuffer_constructor(DynBuffer *o, int startSize, int expandSize, AllocatorIntf *alloc, DynBuffer_OnAllocError onAllocError)
Initialize a dynamic buffer and optionally allocate its starting storage.
#define DynBuffer_incrementCursor(o, nBytes)
Advance after writing reserved storage.
Definition: DynBuffer.h:219
BA_API const char * DynBuffer_ecode2str(int eCode)
Translate an allocation error.
#define DynBuffer_getCurPtr(o)
Get the current write position.
Definition: DynBuffer.h:215
#define DynBuffer_destructor(o)
Release the current storage.
Definition: DynBuffer.h:200
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:98
The BufPrint class, which implements a compact printf-style formatter, is a base class used by severa...
Definition: BufPrint.h:132
A dynamic buffer.
Definition: DynBuffer.h:68
void release()
Free the current storage, reset the cursor and capacity, and invalidate all borrowed buffer pointers.
Definition: DynBuffer.h:242
~DynBuffer()
destructor.
Definition: DynBuffer.h:240
int getECode()
Returns the error code if memory allocation failed.
Definition: DynBuffer.h:248
U32 getBufSize()
Definition: DynBuffer.h:246
char * getBuf()
Returns a pointer to the internal buffer.
Definition: DynBuffer.h:244
int expand(int sizeNeeded)
force buffer to expand.
Definition: DynBuffer.h:250
void incrementCursor(int nBytes)
Increments the internal cursor position.
Definition: DynBuffer.h:254
char * getCurPtr()
Return a pointer to the internal cursor position in the internal dynamic buffer.
Definition: DynBuffer.h:252
static const char * ecode2str(int eCode)
Convert a recognized allocation error code to a static message.
Definition: DynBuffer.h:256
DynBuffer()
Leave storage uninitialized; call DynBuffer_constructor before use.
Definition: DynBuffer.h:70