59#define CX_BUFFER_DEFAULT 0x00
67#define CX_BUFFER_FREE_CONTENTS 0x01
72#define CX_BUFFER_AUTO_EXTEND 0x02
80#define CX_BUFFER_COPY_ON_WRITE 0x04
89#define CX_BUFFER_COPY_ON_EXTEND 0x08
95#define cxBufferWriteFunc ((cx_write_func) cxBufferWrite)
100#define cxBufferReadFunc ((cx_read_func) cxBufferRead)
Interface for custom allocators.
int cxBufferEnableFlushing(CxBuffer *buffer, CxBufferFlushConfig config)
Configures the buffer for flushing.
void cxBufferReset(CxBuffer *buffer)
Resets the buffer by resetting the position and size to zero.
size_t cxBufferWrite(const void *ptr, size_t size, size_t nitems, CxBuffer *buffer)
Writes data to a CxBuffer.
bool cxBufferEof(const CxBuffer *buffer)
Tests, if the buffer position has exceeded the buffer size.
size_t cxBufferFlush(CxBuffer *buffer)
Performs a single flush-run on the specified buffer.
void cxBufferClear(CxBuffer *buffer)
Clears the buffer by resetting the position and deleting the data.
int cxBufferShift(CxBuffer *buffer, off_t shift)
Shifts the contents of the buffer by the given offset.
size_t cxBufferAppend(const void *ptr, size_t size, size_t nitems, CxBuffer *buffer)
Appends data to a CxBuffer.
void cxBufferFree(CxBuffer *buffer)
Deallocates the buffer.
int cxBufferShiftLeft(CxBuffer *buffer, size_t shift)
Shifts the buffer to the left.
int cxBufferGet(CxBuffer *buffer)
Gets a character from a buffer.
int cxBufferMinimumCapacity(CxBuffer *buffer, size_t capacity)
Ensures that the buffer has a minimum capacity.
void cxBufferDestroy(CxBuffer *buffer)
Destroys the buffer contents.
int cxBufferShiftRight(CxBuffer *buffer, size_t shift)
Shifts the buffer to the right.
int cxBufferTerminate(CxBuffer *buffer)
Writes a terminating zero to a buffer at the current position.
int cxBufferSeek(CxBuffer *buffer, off_t offset, int whence)
Moves the position of the buffer.
size_t cxBufferPutString(CxBuffer *buffer, const char *str)
Writes a string to a buffer.
int cxBufferPut(CxBuffer *buffer, int c)
Writes a character to a buffer.
size_t cxBufferRead(void *ptr, size_t size, size_t nitems, CxBuffer *buffer)
Reads data from a CxBuffer.
int cxBufferInit(CxBuffer *buffer, void *space, size_t capacity, const CxAllocator *allocator, int flags)
Initializes a fresh buffer.
CxBuffer * cxBufferCreate(void *space, size_t capacity, const CxAllocator *allocator, int flags)
Allocates and initializes a fresh buffer.
Common definitions and feature checks.
#define cx_attr_export
Only used for building Windows DLLs.
Definition common.h:285
#define cx_attr_nonnull
All pointer arguments must be non-NULL.
Definition common.h:136
size_t(* cx_write_func)(const void *, size_t, size_t, void *)
Function pointer compatible with fwrite-like functions.
Definition common.h:295
#define cx_attr_nodiscard
Warn about discarded return value.
Definition common.h:265
#define cx_attr_malloc
The attributed function always returns freshly allocated memory.
Definition common.h:151
#define cx_attr_nonnull_arg(...)
The specified pointer arguments must be non-NULL.
Definition common.h:141
#define cx_attr_cstr_arg(idx)
No support for null_terminated_string_arg in clang or GCC below 14.
Definition common.h:206
#define cx_attr_dealloc(...)
Not supported in clang.
Definition common.h:167
Structure holding the data for an allocator.
Definition allocator.h:84
Configuration for automatic flushing.
Definition buffer.h:105
cx_write_func wfunc
The write-function used for flushing.
Definition buffer.h:138
size_t blkmax
The maximum number of blocks to flush in one cycle.
Definition buffer.h:127
size_t threshold
The buffer may not extend beyond this threshold before starting to flush.
Definition buffer.h:113
void * target
The target for write function.
Definition buffer.h:132
size_t blksize
The block size for the elements to flush.
Definition buffer.h:117
Structure for the UCX buffer data.
Definition buffer.h:157
char * space
Data is interpreted as text.
Definition buffer.h:163
size_t capacity
Current capacity (i.e.
Definition buffer.h:180
unsigned char * bytes
Data is interpreted as binary.
Definition buffer.h:167
size_t pos
Current position of the buffer.
Definition buffer.h:178
int flags
Flag register for buffer features.
Definition buffer.h:190
size_t size
Current size of the buffer content.
Definition buffer.h:182
const CxAllocator * allocator
The allocator to use for automatic memory management.
Definition buffer.h:170
CxBufferFlushConfig * flush
Optional flush configuration.
Definition buffer.h:176