66 size_t sz,
size_t elem);
302 else if (!dev->
flags)
322 size_t sz,
size_t elem) {
378 size_t sz,
size_t elem) {
397 const void* buf,
size_t len) {
435 return dev->
vtable->
seek(dev, offset, whence);
450 else if (!dev->
flags)
814 virtual size_t read(CType dev,
void* buf,
815 size_t sz,
size_t elem) = 0;
830 virtual size_t write(CType dev,
const void* buf,
831 size_t sz,
size_t elem) = 0;
845 virtual int seek(CType dev,
off_t offset,
869 virtual int flush(CType dev) = 0;
884 virtual size_t setbufsz(CType dev,
size_t len) = 0;
896 virtual size_t getbufsz(CType dev)
const = 0;
907 virtual int dcntl(CType dev,
int cmd,
919 virtual int ioctl(CType dev,
int cmd,
949 inline Device(CType dev,
bool acquire=
true)
986 inline Device(
const Device& dev) : m_dev(dev.m_dev) {
1015 inline size_t read(
void* buf,
size_t sz,
size_t elem) {
1028 inline size_t read(
void* buf,
size_t len) {
1056 inline size_t write(
const void* buf,
size_t sz,
1072 inline size_t write(
const void* buf,
size_t len) {
1175 return bufsz() == 0;
1240 return m_dev->flags;
1248 return m_dev->ecode;
1259 m_dev->ecode = ecode;
1272 return m_dev != NULL;
1280 inline operator bool()
const throw() {
1304 WFIO_CXX_DLL Device& operator=(
const Device& rhs);
The root namespace for WFIO.
Definition: bin.h:879
Device(CType dev, IOShare ioshare)
Wrap a wfio:device_t using an IOShare.
Definition: device.h:964
size_t(* read)(struct wfio_device_t *dev, void *buf, size_t sz, size_t elem)
Read from this device.
Definition: device.h:59
const struct wfio_device_vtable_t * vtable
This device's virtual table.
Definition: device.h:168
The virtual table for a wfio_device_t.
Definition: device.h:50
WFIO_DLL wfio_device_t * wfio_device_from_voidp(const wfio_device_vtable_t *vtable, void *data, int *error)
Open a new device from a VTable and a void pointer representing the implementation.
size_t bufsz() const
Obtain the buffer size for this Device.
Definition: device.h:1160
#define WFIO_DLL
Mark the symbol as an element of the library.
Definition: host.h:397
WFIO_INLINE int wfio_device_dcntl(wfio_device_t *dev, wfio_dcntl_t cmd,...)
Perform device-independent I/O control on this device.
Definition: device.h:613
WFIO_C_BEGIN typedef long int wfio_off_t
An integer corresponding to a device offset.
Definition: iotype.h:48
#define WFIO_C_BEGIN
Definition: host.h:477
WFIO_INLINE size_t wfio_device_read(wfio_device_t *dev, void *buf, size_t sz, size_t elem)
Read from the supplied device.
Definition: device.h:321
#define WFIO_DLL_FASTCALL
Shorthand for WFIO_DLL WFIO_FASTCALL.
Definition: host.h:425
WFIO_INLINE int wfio_device_flush(wfio_device_t *dev)
Attempt to flush this device.
Definition: device.h:561
The device flags were set.
Definition: device.h:117
WFIO_DLL int wfio_device_vdcntl(wfio_device_t *dev, wfio_dcntl_t cmd, va_list va)
Perform device-independent I/O control on this device using a va_list.
wfio_device_flag_t
Flags applying to a device.
Definition: device.h:113
WFIO_ALWAYS_INLINE int wfio_device_isBuffered(wfio_device_t *dev)
Determine whether or not the device is buffered.
Definition: device.h:545
size_t(* getbufsz)(struct wfio_device_t *dev)
Obtain the size of the buffer associated this device.
Definition: device.h:97
The device is allowed to seek.
Definition: device.h:130
size_t refcount
This device's virtual count.
Definition: device.h:173
Obtain the file's current file descriptor.
Definition: iotype.h:193
The device is both readable and writable.
Definition: device.h:157
WFIO_DLL_FASTCALL size_t wfio_device_readbuf(wfio_device_t *dev, struct wfio_iobuf_t *buf)
Read the contents of the device dev into buf.
wfio_off_t(* tell)(struct wfio_device_t *dev)
Obtain the current stream position for this device.
Definition: device.h:77
WFIO_DLL_FASTCALL size_t wfio_device_writebuf(wfio_device_t *dev, struct wfio_iobuf_t *buf)
Write the contents of the buffer buf into dev.
#define WFIO_ALWAYS_INLINE
Mark this symbol to be forced inline.
Definition: host.h:447
WFIO_ALWAYS_INLINE int wfio_device_setflags(wfio_device_t *dev, int flags)
Set the flags for this device.
Definition: device.h:741
~Device()
Release this Device.
Definition: device.h:996
Device(CType dev, bool acquire=true)
Wrap a wfio_device_t.
Definition: device.h:949
WFIO_INLINE int wfio_device_seek(wfio_device_t *dev, wfio_off_t offset, wfio_whence_t whence)
Seek to a position in the stream.
Definition: device.h:432
wfio_whence_t
The type corresponding to the point of reference in a seek operation.
Definition: iotype.h:60
void(* close)(struct wfio_device_t *dev)
Close this device.
Definition: device.h:54
Device dup()
Duplicate this Device.
Definition: device.h:1121
int(* seek)(struct wfio_device_t *dev, wfio_off_t offset, wfio_whence_t whence)
Seek to a particular stream position in this device.
Definition: device.h:71
void ecode(int ecode)
Set the error code associated with this Device.
Definition: device.h:1257
WFIO_ALWAYS_INLINE int wfio_device_truncate(wfio_device_t *dev, size_t len)
Truncate the file to the specified length.
Definition: device.h:771
WFIO_INLINE int wfio_device_readb(wfio_device_t *dev)
Read a single byte from the supplied device.
Definition: device.h:356
WFIO_INLINE size_t wfio_device_getbufsz(wfio_device_t *dev)
Obtain the buffer size.
Definition: device.h:526
An IO sharing mode.
Definition: iotype.h:253
WFIO_DLL int wfio_device_vioctl(wfio_device_t *dev, int cmd, va_list va)
Perform device-dependent I/O control on this device.
int wfio_fd_t
The type corresponding a file descriptor.
Definition: iotype.h:108
size_t read(void *buf, size_t len)
Write a vector of bytes to this Device.
Definition: device.h:1028
WFIO_INLINE size_t wfio_device_setbufsz(wfio_device_t *dev, size_t sz)
Set the buffer size.
Definition: device.h:508
WFIO_DLL int wfio_device_sink(wfio_device_t *src, wfio_device_t *dest, size_t *copied)
Copy the contents of the device src into dest.
WFIO_INLINE size_t wfio_device_writeb(wfio_device_t *dev, char c)
Write a single byte to the supplied device.
Definition: device.h:413
::wfio_device_t * CType
The C type from which a Device is derived.
Definition: device.h:791
WFIO_INLINE int wfio_device_ioctl(wfio_device_t *dev, int cmd,...)
Perform device-dependent I/O control on this device.
Definition: device.h:666
wfio_dcntl_t
A command to be supplied to a device or similar stream.
Definition: iotype.h:175
WFIO_ALWAYS_INLINE int wfio_device_getflags(wfio_device_t *dev)
Obtain the flags for this device.
Definition: device.h:756
A C++ wrapper for a wfio_device_t.
Definition: device.h:783
bool seek(wfio_off_t offset, wfio_whence_t whence)
Seek to a position in this Device.
Definition: device.h:1099
WFIO_INLINE size_t wfio_device_write(wfio_device_t *dev, const void *buf, size_t sz, size_t elem)
Write to the supplied device.
Definition: device.h:377
const int flags
Flags associated with this buffer.
Definition: iobuf.h:126
A strategy for a device.
Definition: device.h:799
int ioctl(int cmd,...)
Perform device-dependent I/O control on this Device.
Definition: device.h:1224
WFIO_INLINE wfio_off_t wfio_device_tell(wfio_device_t *dev)
Determine the current stream position of this device.
Definition: device.h:465
The device may be read.
Definition: device.h:122
A stream intended for binary output.
Definition: bin.h:54
Device(const Device &dev)
Copy-construct a device.
Definition: device.h:986
size_t bufsz(size_t len)
Set the buffer size for this Device.
Definition: device.h:1149
size_t write(const void *buf, size_t sz, size_t elem)
Write a vector of elements to this Device.
Definition: device.h:1056
A constant indicating no position.
Definition: iotype.h:226
struct wfio_device_t wfio_device_t
A simple, byte-oriented channel.
WFIO_INLINE int wfio_device_classify(wfio_device_t *dev)
Conditionally classify a device.
Definition: device.h:298
Obtain the flags associated with this device.
Definition: iotype.h:205
The device is reserved by WFIO or some other library and should not have its device handle freed...
Definition: device.h:141
bool flush()
Attempt to flush this Device.
Definition: device.h:1132
size_t read(void *buf, size_t sz, size_t elem)
Write elements to this Device.
Definition: device.h:1015
#define WFIO_INLINE
Mark this symbol for inlining.
Definition: host.h:377
#define WFIO_C_END
Definition: host.h:485
WFIO_DLL wfio_device_t * wfio_device_from_int(const wfio_device_vtable_t *vtable, int data, int *error)
Open a new device from a VTable and an integral handle representing the implementation.
WFIO_DLL int wfio_device_forceClassify(wfio_device_t *dev)
Deduce the appropriate flags for this device if they have not already been set.
A simple, byte-oriented channel.
Definition: device.h:164
size_t(* write)(struct wfio_device_t *dev, const void *buf, size_t sz, size_t elem)
Write to this device.
Definition: device.h:65
WFIO_ALWAYS_INLINE int wfio_device_acquire(wfio_device_t *dev)
Share this device by acquiring it.
Definition: device.h:267
An IOShare mode indicating that the stream is acquired.
Definition: iotype.h:148
The device may be written.
Definition: device.h:126
int flags
This device's flags.
Definition: device.h:178
Set the length of a device's backing store.
Definition: iotype.h:219
int(* ioctl)(struct wfio_device_t *dev, int cmd, va_list args)
Perform device-specific I/O control on the underlying device.
Definition: device.h:107
int(* flush)(struct wfio_device_t *dev)
Flush the underlying buffer.
Definition: device.h:87
size_t(* setbufsz)(struct wfio_device_t *dev, size_t len)
Ensure that the buffer is exactly len bytes long.
Definition: device.h:92
WFIO_INLINE size_t wfio_device_readbV(wfio_device_t *dev, void *buf, size_t len)
Read a vector of bytes from the supplied device.
Definition: device.h:340
int ecode
This device's last error.
Definition: device.h:183
Device()
Construct the default Device.
Definition: device.h:936
Attempt to change the flags associated with this device.
Definition: iotype.h:200
WFIO_INLINE wfio_device_t * wfio_device_dup(wfio_device_t *dev)
Duplicate this device.
Definition: device.h:480
::wfio_off_t off_t
An integer corresponding to a device offset.
Definition: iotype.h:234
WFIO_DLL void wfio_device_close(wfio_device_t *dev)
Close the supplied device.
int ecode() const
Obtain the error code associated with this Device.
Definition: device.h:1247
WFIO_DLL_FASTCALL wfio_device_t * wfio_device_ioshare(wfio_device_t *dev, int ioshare)
Share this device with the supplied ioshare mode.
size_t write(const void *buf, size_t len)
Write a vector of bytes to this Device.
Definition: device.h:1072
A generic I/O buffer.
Definition: iobuf.h:122
struct wfio_device_t *(* dup)(struct wfio_device_t *dev)
Duplicate this device.
Definition: device.h:82
int flags() const
Obtain the flags vector associated with this Device.
Definition: device.h:1239
int dcntl(::wfio_dcntl_t cmd,...)
Perform device-independent I/O control on this Device.
Definition: device.h:1197
WFIO_INLINE size_t wfio_device_writebV(wfio_device_t *dev, const void *buf, size_t len)
Write a vector of bytes to the supplied device.
Definition: device.h:396
bool valid() const
Determine if this Device is valid.
Definition: device.h:1271
int read()
Read a single byte from this Device.
Definition: device.h:1038
WFIO_ALWAYS_INLINE wfio_fd_t wfio_device_getfd(wfio_device_t *dev)
Obtain the file descriptor for this device.
Definition: device.h:726
bool buffered() const
Determine whether or not the device is buffered.
Definition: device.h:1174
This device is nonblocking.
Definition: device.h:135
bool write(char c)
Write a single byte to this Device.
Definition: device.h:1085
wfio_off_t tell() const
Determine the current stream position of this Device.
Definition: device.h:1110
A device-specific flag.
Definition: device.h:150
WFIO_INLINE int wfio_device_canSeek(wfio_device_t *dev)
Determine whether or not this device is capable of seeking.
Definition: device.h:446
int(* dcntl)(struct wfio_device_t *dev, int cmd, va_list args)
Perform device-independent control on this device.
Definition: device.h:102
WFIO_C_BEGIN struct wfio_device_vtable_t wfio_device_vtable_t
The virtual table for a wfio_device_t.