84 size_t len,
int* error);
98 size_t len,
int* error);
172 return buf ? (buf->
base) : NULL;
196 return buf ? (buf->
facet - buf->
avail)/sz : 0;
344 size_t sz,
size_t elem,
int* error);
357 size_t len,
int* error);
368 unsigned char ret = 0;
387 size_t sz,
size_t elem,
int* error);
400 size_t len,
int* error);
618 inline IOBuf(
size_t size,
int* error = NULL) :
631 inline IOBuf(
size_t read,
size_t write,
int* error = NULL) :
668 return m_buf ? m_buf->flags : 0;
675 return m_buf ? m_buf->capacity : 0;
682 inline size_t facet()
const throw() {
683 return m_buf ? m_buf->facet : 0;
690 inline size_t avail()
const throw() {
691 return m_buf ? m_buf->avail : 0;
728 inline size_t start()
const throw() {
729 return m_buf ? m_buf->start : 0;
742 inline size_t end()
const throw() {
743 return m_buf ? m_buf->end : 0;
757 return m_buf ? m_buf->base : 0;
770 inline const void*
base()
const throw() {
771 return m_buf ? m_buf->base : 0;
787 inline size_t read(
void* dest,
size_t sz,
size_t elem,
788 int* error = NULL)
throw() {
803 inline size_t readbV(
void* dest,
size_t len,
804 int* error = NULL)
throw() {
818 inline int readb(
int* error = NULL)
throw() {
838 inline size_t write(
const void* src,
size_t sz,
839 size_t elem,
int* error = NULL)
throw() {
854 inline size_t writebV(
const void* src,
size_t len,
855 int* error = NULL)
throw() {
869 inline size_t writeb(
char c,
int* error = NULL)
throw() {
888 inline size_t source(
size_t sz,
size_t elem,
889 void* src, SourceCallback cb,
890 int* error = NULL)
throw() {
906 inline size_t fill(
void* src, SourceCallback cb,
907 int* error = NULL)
throw() {
923 inline size_t sink(
size_t sz,
size_t elem,
924 void* src, SinkCallback cb,
925 int* error = NULL)
throw() {
940 inline size_t empty(
void* src, SinkCallback cb,
941 int* error = NULL)
throw() {
959 inline bool flip(
int* error = NULL)
throw() {
1027 inline int clear(
int* error = NULL)
throw() {
1041 return m_buf != NULL;
1049 inline operator bool ()
const {
1050 return m_buf != NULL;
1073 WFIO_CXX_DLL
IOBuf& operator=(
const IOBuf& rhs);
IOBuf(size_t size, int *error=NULL)
Construct a new exclusive buffer of length size.
Definition: iobuf.h:618
size_t empty(void *src, SinkCallback cb, int *error=NULL)
Empty this buffer into src.
Definition: iobuf.h:940
The root namespace for WFIO.
Definition: bin.h:879
wfio_iobuf_flags_t
A type representing a wfio_iobuf_t's flags.
Definition: iobuf.h:40
WFIO_DLL wfio_iobuf_t * wfio_iobuf_alloc(size_t capacity, int *error)
Create a new exclusive IO buffer.
const size_t start
The starting index of this buffer.
Definition: iobuf.h:150
size_t write(const void *src, size_t sz, size_t elem, int *error=NULL)
Emplace elements into this IOBuf.
Definition: iobuf.h:838
WFIO_INLINE void * wfio_iobuf_rawdata(wfio_iobuf_t *buf)
Obtain access to the raw data memory associated with this buffer.
Definition: iobuf.h:171
WFIO_DLL wfio_iobuf_t * wfio_iobuf_allocSplit(size_t f0, size_t f1, int *error)
Create a new shared IO buffer with split facet sizes.
const size_t end
The end index of this buffer.
Definition: iobuf.h:154
The IO buffer has been flipped.
Definition: iobuf.h:44
~IOBuf()
Release this IOBuf.
Definition: iobuf.h:641
#define WFIO_DLL
Mark the symbol as an element of the library.
Definition: host.h:397
#define WFIO_C_BEGIN
Definition: host.h:477
bool flip(int *error=NULL)
Flip this IOBuf.
Definition: iobuf.h:959
bool notRead() const
Whether or not this IOBuf is shared and not using the read facet.
Definition: iobuf.h:970
WFIO_INLINE int wfio_iobuf_readb(wfio_iobuf_t *buf, int *error)
Consume a single from the buffer buf.
Definition: iobuf.h:367
WFIO_DLL int wfio_iobuf_flip(wfio_iobuf_t *buf, int *error)
Flip the buffer buf.
size_t writeb(char c, int *error=NULL)
Emplace bytes into this IOBuf.
Definition: iobuf.h:869
WFIO_ALWAYS_INLINE int wfio_iobuf_notRead(const wfio_iobuf_t *buf)
Determine if the buf is shared and not using the read buffer.
Definition: iobuf.h:287
bool notWrite() const
Whether or not this IOBuf is shared and not using the write facet.
Definition: iobuf.h:981
IOBuf(::wfio_iobuf_t *buf, bool acquire=true)
Wrap a wfio_iobuf_t.
Definition: iobuf.h:591
WFIO_DLL int wfio_iobuf_acquire(wfio_iobuf_t *buf)
Acquire the buffer buf.
WFIO_ALWAYS_INLINE size_t wfio_iobuf_empty(wfio_iobuf_t *buf, void *dest, wfio_iobuf_sink_callback_t cb, int *error)
Empty this buffer into src.
Definition: iobuf.h:539
WFIO_DLL size_t wfio_iobuf_source(wfio_iobuf_t *buf, size_t sz, size_t elem, void *src, wfio_iobuf_source_callback_t cb, int *error)
Source new elements into buf from src.
const size_t facet
The capacity of this facet of the buffer.
Definition: iobuf.h:139
#define WFIO_ALWAYS_INLINE
Mark this symbol to be forced inline.
Definition: host.h:447
WFIO_ALWAYS_INLINE size_t wfio_iobuf_remain(wfio_iobuf_t *buf)
Obtain the number of bytes left in the buffer.
Definition: iobuf.h:182
WFIO_INLINE int wfio_iobuf_ensureWrite(wfio_iobuf_t *buf, int *error)
Ensure that buf is using the write buffer.
Definition: iobuf.h:325
size_t writebV(const void *src, size_t len, int *error=NULL)
Emplace bytes into this IOBuf.
Definition: iobuf.h:854
WFIO_DLL void wfio_iobuf_free(wfio_iobuf_t *buf)
Release the buffer buf.
bool ensureWrite(int *error=NULL)
Ensure that this IOBuf is using the write buffer.
Definition: iobuf.h:1005
int flags() const
Obtain this IOBuf's flags.
Definition: iobuf.h:667
int readb(int *error=NULL)
Consume bytes from this IOBuf.
Definition: iobuf.h:818
void * base()
Obtain the base address of this IOBuf's current facet.
Definition: iobuf.h:756
The IO buffer is shared.
Definition: iobuf.h:49
size_t remainElem(size_t sz) const
Obtain the space remaining in the current facet of this buffer for elements of size sz...
Definition: iobuf.h:714
size_t read(void *dest, size_t sz, size_t elem, int *error=NULL)
Consume elements from this IOBuf.
Definition: iobuf.h:787
WFIO_ALWAYS_INLINE size_t wfio_iobuf_fill(wfio_iobuf_t *buf, void *dest, wfio_iobuf_source_callback_t cb, int *error)
Fill this buffer from src.
Definition: iobuf.h:480
size_t(* wfio_iobuf_source_callback_t)(void *src, void *buf, size_t len, int *error)
A callback for wfio_iobuf_source().
Definition: iobuf.h:83
bool forceReorganize(int *error=NULL)
Force the reorganization of this IOBuf.
Definition: iobuf.h:1018
size_t sink(size_t sz, size_t elem, void *src, SinkCallback cb, int *error=NULL)
Sink new elements from this IOBuf into dest.
Definition: iobuf.h:923
size_t source(size_t sz, size_t elem, void *src, SourceCallback cb, int *error=NULL)
Source new elements into this IOBuf from src.
Definition: iobuf.h:888
size_t end() const
Obtain the end index for this IOBuf's current facet.
Definition: iobuf.h:742
WFIO_DLL size_t wfio_iobuf_sourcebV(wfio_iobuf_t *buf, size_t len, void *src, wfio_iobuf_source_callback_t cb, int *error)
Source new bytes into buf from src.
::wfio_iobuf_t * CType
The C type from which an IOBuf is derived.
Definition: iobuf.h:559
const int flags
Flags associated with this buffer.
Definition: iobuf.h:126
static IOBuf allocShared(size_t capacity, int *error=NULL)
Allocate a new shared IOBuf.
Definition: iobuf.h:656
The buffer is shared but not yet flipped.
Definition: iobuf.h:60
The buffer is shared and has been flipped.
Definition: iobuf.h:69
size_t(* wfio_iobuf_sink_callback_t)(void *dest, const void *buf, size_t len, int *error)
A callback for wfio_iobuf_sink().
Definition: iobuf.h:97
A C++ wrapper for a wfio_iobuf_t.
Definition: iobuf.h:551
WFIO_DLL size_t wfio_iobuf_sinkbV(wfio_iobuf_t *buf, size_t len, void *dest, wfio_iobuf_sink_callback_t cb, int *error)
Sink new bytes from buf into dest.
size_t remain() const
Obtain the space remaining in the current facet of this buffer.
Definition: iobuf.h:701
WFIO_DLL size_t wfio_iobuf_write(wfio_iobuf_t *buf, const void *src, size_t sz, size_t elem, int *error)
Emplace bytes into the buffer buf.
IOBuf(const IOBuf &buf)
Copy-construct an IOBuf.
Definition: iobuf.h:606
A constant indicating no position.
Definition: iotype.h:226
struct wfio_iobuf_t wfio_iobuf_t
A generic I/O buffer.
WFIO_ALWAYS_INLINE int wfio_iobuf_notWrite(const wfio_iobuf_t *buf)
Determine if the buf is shared and not using the write buffer.
Definition: iobuf.h:298
#define WFIO_INLINE
Mark this symbol for inlining.
Definition: host.h:377
size_t start() const
Obtain the starting index for this IOBuf's current facet.
Definition: iobuf.h:728
WFIO_DLL int wfio_iobuf_forceReorganize(wfio_iobuf_t *buf, int *error)
Force reoganization of this buffer.
#define WFIO_C_END
Definition: host.h:485
IOBuf()
Construct the default IOBuf.
Definition: iobuf.h:578
int clear(int *error=NULL)
Clear the contents of this IOBuf's current facet.
Definition: iobuf.h:1027
IOBuf(size_t read, size_t write, int *error=NULL)
Construct a new split buffer.
Definition: iobuf.h:631
WFIO_INLINE int wfio_iobuf_ensureRead(wfio_iobuf_t *buf, int *error)
Ensure that buf is using the read buffer.
Definition: iobuf.h:310
const size_t capacity
The maximum capacity of this buffer.
Definition: iobuf.h:131
size_t avail() const
The number of characters available for consumption in this IOBuf.
Definition: iobuf.h:690
size_t fill(void *src, SourceCallback cb, int *error=NULL)
Fill this IOBuf from src.
Definition: iobuf.h:906
size_t readbV(void *dest, size_t len, int *error=NULL)
Consume bytes from this IOBuf.
Definition: iobuf.h:803
WFIO_DLL size_t wfio_iobuf_sink(wfio_iobuf_t *buf, size_t sz, size_t elem, void *dest, wfio_iobuf_sink_callback_t cb, int *error)
Sink new elements from buf into dest.
WFIO_DLL size_t wfio_iobuf_writebV(wfio_iobuf_t *buf, const void *src, size_t len, int *error)
Emplace bytes into the buffer buf.
const void * base() const
Obtain the base address of this IOBuf's current facet in a constant context.
Definition: iobuf.h:770
WFIO_DLL size_t wfio_iobuf_readbV(wfio_iobuf_t *buf, void *dest, size_t len, int *error)
Consume bytes from the buffer buf.
void *const base
The base address of this buffer's data.
Definition: iobuf.h:159
bool valid() const
Determine if this IOBuf is valid.
Definition: iobuf.h:1040
WFIO_INLINE int wfio_iobuf_writeb(wfio_iobuf_t *buf, char c, int *error)
Consume a single from the buffer buf.
Definition: iobuf.h:410
size_t capacity() const
Obtain this IOBuf's total capacity.
Definition: iobuf.h:674
::wfio_iobuf_sink_callback_t SinkCallback
A callback used to implement a sink operation.
Definition: iobuf.h:569
A generic I/O buffer.
Definition: iobuf.h:122
const size_t avail
The number of available characters for consumption in this buffer.
Definition: iobuf.h:145
WFIO_DLL size_t wfio_iobuf_read(wfio_iobuf_t *buf, void *dest, size_t sz, size_t elem, int *error)
Consume elements from the buffer buf.
WFIO_DLL wfio_iobuf_t * wfio_iobuf_allocShared(size_t capacity, int *error)
Create a new shared IO buffer with evenly-split facet sizes.
WFIO_DLL int wfio_iobuf_clear(wfio_iobuf_t *buf, int *error)
Discard all data currently in current facet of this buffer.
bool ensureRead(int *error=NULL)
Ensure that this IOBuf is using the read buffer.
Definition: iobuf.h:993
WFIO_ALWAYS_INLINE size_t wfio_iobuf_remainElem(wfio_iobuf_t *buf, size_t sz)
Obtain the number of elements left in the buffer.
Definition: iobuf.h:194
size_t facet() const
Obtain the capacity of this IOBuf's current facet.
Definition: iobuf.h:682
::wfio_iobuf_source_callback_t SourceCallback
A callback used to implement a source operation.
Definition: iobuf.h:564