60#define CX_BUFFER_DEFAULT 0x00
65#define CX_BUFFER_FREE_CONTENTS 0x01
70#define CX_BUFFER_AUTO_EXTEND 0x02
Interface for custom allocators.
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.
void cxBufferFree(CxBuffer *buffer)
Deallocates the buffer.
int cxBufferEof(CxBuffer const *buffer)
Tests, if the buffer position has exceeded the buffer capacity.
CxBuffer * cxBufferCreate(void *space, size_t capacity, CxAllocator const *allocator, int flags)
Allocates and initializes a fresh 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 cxBufferSeek(CxBuffer *buffer, off_t offset, int whence)
Moves the position of the buffer.
cx_buffer_s CxBuffer
UCX buffer.
Definition: buffer.h:139
int cxBufferInit(CxBuffer *buffer, void *space, size_t capacity, CxAllocator const *allocator, int flags)
Initializes a fresh buffer.
size_t cxBufferWrite(void const *ptr, size_t size, size_t nitems, CxBuffer *buffer)
Writes data to a CxBuffer.
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.
Common definitions and feature checks.
#define __attribute__(x)
Removes GNU C attributes where they are not supported.
Definition: common.h:127
size_t(* cx_write_func)(void const *, size_t, size_t, void *)
Function pointer compatible with fwrite-like functions.
Definition: common.h:103
Structure holding the data for an allocator.
Definition: allocator.h:86
Structure for the UCX buffer data.
Definition: buffer.h:73
size_t flush_threshold
The buffer may not extend beyond this threshold before starting to flush.
Definition: buffer.h:97
void * flush_target
The target for flush_func.
Definition: buffer.h:125
size_t flush_blksize
The block size for the elements to flush.
Definition: buffer.h:102
size_t flush_blkmax
The maximum number of blocks to flush in one cycle.
Definition: buffer.h:114
char * space
Data is interpreted as text.
Definition: buffer.h:79
size_t capacity
Current capacity (i.e.
Definition: buffer.h:90
unsigned char * bytes
Data is interpreted as binary.
Definition: buffer.h:83
size_t pos
Current position of the buffer.
Definition: buffer.h:88
int flags
Flag register for buffer features.
Definition: buffer.h:133
CxAllocator const * allocator
The allocator to use for automatic memory management.
Definition: buffer.h:86
size_t size
Current size of the buffer content.
Definition: buffer.h:92
cx_write_func flush_func
The write function used for flushing.
Definition: buffer.h:120