Wheefun I/O Library  0.0.5
Useful I/O Primitives.
Public Types | Public Member Functions | List of all members
wfio::BinStream Class Reference

Wrap a wfio_binstream_t. More...

#include <bin.h>

Public Types

typedef ::wfio_binstream_t CType
 The C type from which a BinStream is derived.
 

Public Member Functions

 BinStream ()
 Construct the default BinStream. More...
 
 BinStream (::wfio_binstream_t *bin, bool acquire=true)
 Wrap a wfio_binstream_t. More...
 
 BinStream (const BinStream &bin)
 Copy-construct a BinStream. More...
 
 BinStream (Device &dev, int *error=NULL)
 Construct a BinStream by supplying a Device. More...
 
 ~BinStream ()
 Release this BinStream. More...
 
endian_t endian () const throw ()
 
void endian (endian_t endian)
 
endian_t floatEndian () const throw ()
 
void floatEndian (endian_t endian)
 
size_t read (void *buf, size_t sz, size_t elem)
 Read elements from this BinStream. More...
 
size_t read (void *buf, size_t len)
 Read bytes from this BinStream. More...
 
int read ()
 Read a byte from the supplied binstream.
 
size_t write (const void *buf, size_t sz, size_t elem)
 Write elements to this BinStream. More...
 
size_t write (const void *buf, size_t len)
 Write a byte vector to this BinStream. More...
 
bool write (char c)
 Write a byte to the this BinStream. More...
 
size_t readSI16V (sint16_t *buf, size_t len)
 Read a vector of 16-bit signed integers. More...
 
size_t writeSI16V (const sint16_t *buf, size_t len)
 Write a vector of 16-bit signed integers. More...
 
bool writeSI16 (wfio_sint16_t si16)
 Write a single 16-bit signed integer. More...
 
size_t readUI16V (uint16_t *buf, size_t len)
 Read a vector of 16-bit unsigned integers. More...
 
size_t writeUI16V (const uint16_t *buf, size_t len)
 Write a vector of 16-bit unsigned integers. More...
 
bool writeUI16 (uint16_t ui16)
 Write a single 16-bit unsigned integer. More...
 
size_t readSI32V (sint32_t *buf, size_t len)
 Read a vector of 32-bit signed integers. More...
 
size_t writeSI32V (const sint32_t *buf, size_t len)
 Write a vector of 32-bit signed integers. More...
 
bool writeSI32 (sint32_t si32)
 Write a single 32-bit signed integer. More...
 
size_t readUI32V (uint32_t *buf, size_t len)
 Read a vector of 32-bit unsigned integers. More...
 
size_t writeUI32V (const uint32_t *buf, size_t len)
 Write a vector of 32-bit unsigned integers. More...
 
bool writeUI32 (uint32_t ui32)
 Write a single 32-bit unsigned integer. More...
 
size_t readSI64V (sint64_t *buf, size_t len)
 Read a vector of 64-bit signed integers. More...
 
size_t writeSI64V (const sint64_t *buf, size_t len)
 Write a vector of 64-bit signed integers. More...
 
bool writeSI64 (sint64_t si64)
 Write a single 64-bit signed integer. More...
 
size_t readUI64V (uint64_t *buf, size_t len)
 Read a vector of 64-bit unsigned integers. More...
 
size_t writeUI64V (const uint64_t *buf, size_t len)
 Write a vector of 64-bit unsigned integers. More...
 
bool writeUI64 (uint64_t ui64)
 Write a single 64-bit unsigned integer. More...
 
size_t readB32V (wfio_flt32_t *buf, size_t len)
 Read a vector of 32-bit IEEE 754 binary floats. More...
 
size_t writeB32V (const wfio_flt32_t *buf, size_t len)
 Write a vector of 32-bit IEEE 754 binary floats. More...
 
bool writeB32 (wfio_flt32_t f32)
 Write a single 32-bit IEEE 754 binary float. More...
 
size_t readB64V (wfio_flt64_t *buf, size_t len)
 Read a vector of 64-bit IEEE 754 binary floats. More...
 
size_t writeB64V (const wfio_flt64_t *buf, size_t len)
 Write a vector of 64-bit IEEE 754 binary floats. More...
 
bool writeB64 (wfio_flt64_t f64)
 Write a single 64-bit IEEE 754 binary float. More...
 
bool flush ()
 Attempt to flush this BinStream. More...
 
size_t bufSz () const
 Obtain the buffer size for this BinStream. More...
 
size_t bufSz (size_t sz)
 Set the buffer size for this BinStream. More...
 
int vdcntl (wfio_dcntl_t cmd, va_list va)
 Perform device-independent I/O control on this binstream using a va_list. More...
 
int dcntl (wfio_dcntl_t cmd,...)
 Perform device-independent I/O control on this binstream. More...
 
int vioctl (int cmd, va_list va)
 Perform device-dependent I/O control on this binstream. More...
 
int ioctl (wfio_binstream_t *bin, int cmd,...)
 Perform device-dependent I/O control on this binstream. More...
 
int ecode () const throw ()
 Obtain the error code associated with this BinStream.
 
void ecode (int ecode) throw ()
 Set the error code associated with this BinStream. More...
 
bool valid () const throw ()
 Determine if this BinStream is valid. More...
 
 operator bool () const throw ()
 Synonymous with this->valid(). More...
 
 operator::wfio_binstream_t * () throw ()
 Implicitly convert this BinStream into it's C equivalent.
 

Detailed Description

Wrap a wfio_binstream_t.

Constructor & Destructor Documentation

◆ BinStream() [1/4]

wfio::BinStream::BinStream ( )
inline

Construct the default BinStream.

This constructor creates an invalid BinStream.

◆ BinStream() [2/4]

wfio::BinStream::BinStream ( ::wfio_binstream_t bin,
bool  acquire = true 
)
inline

Wrap a wfio_binstream_t.

Parameters
binThe binstream to wrap.
acquireWhether or not the binstream should be acquired as a consequence of constructing this object.
Note
If you want to disown the previous ownership of bin from the context in which it is called, then acquire should be false.

◆ BinStream() [3/4]

wfio::BinStream::BinStream ( const BinStream bin)
inline

Copy-construct a BinStream.

Thie constructor acquires the underlying CType and sets it as this BinStream's underyling CType.

◆ BinStream() [4/4]

wfio::BinStream::BinStream ( Device dev,
int *  error = NULL 
)
inline

Construct a BinStream by supplying a Device.

This consturctor acquires the Device so that it becomes the peer on which this BinStream is based.

◆ ~BinStream()

wfio::BinStream::~BinStream ( )
inline

Release this BinStream.

This method releases the underlying CType if this object is valid.

Member Function Documentation

◆ bufSz() [1/2]

size_t wfio::BinStream::bufSz ( ) const
inline

Obtain the buffer size for this BinStream.

Returns
The size of the buffer associated with this BinStream on success; otherwise, WFIO_NPOS. A return value of zero shall indicate that the device is unbuffered.

◆ bufSz() [2/2]

size_t wfio::BinStream::bufSz ( size_t  sz)
inline

Set the buffer size for this BinStream.

Parameters
szThe requested size to set.
Returns
The size of the buffer after this operation; otherwise, WFIO_NPOS. A return value of zero shall indicate that BinStream is unbuffered.
Note
When the buffer size is immutable or the BinStream cannot be buffered, but is otherwise known, then the size of the buffer is returned.

◆ dcntl()

int wfio::BinStream::dcntl ( wfio_dcntl_t  cmd,
  ... 
)
inline

Perform device-independent I/O control on this binstream.

Parameters
cmdThe command to send to the binstream.
...Additional arguments to the dcntl.
Returns
A return value peculiar to the command invoked.

◆ ecode()

void wfio::BinStream::ecode ( int  ecode)
throw (
)
inline

Set the error code associated with this BinStream.

Parameters
ecodethe new error code to set.

◆ flush()

bool wfio::BinStream::flush ( )
inline

Attempt to flush this BinStream.

Returns
True iff the flush operation is successful.

◆ ioctl()

int wfio::BinStream::ioctl ( wfio_binstream_t bin,
int  cmd,
  ... 
)
inline

Perform device-dependent I/O control on this binstream.

Parameters
cmdThe command to send to the binstream.
...Additional arguments to the ioctl.
Returns
A return value peculiar to the command invoked.

◆ operator bool()

wfio::BinStream::operator bool ( ) const
throw (
)
inline

Synonymous with this->valid().

Returns
True if this object is valid.

◆ read() [1/2]

size_t wfio::BinStream::read ( void *  buf,
size_t  sz,
size_t  elem 
)
inline

Read elements from this BinStream.

Parameters
bufThe buffer to read into.
szThe size of each element to read.
elemThe number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ read() [2/2]

size_t wfio::BinStream::read ( void *  buf,
size_t  len 
)
inline

Read bytes from this BinStream.

Parameters
bufThe buffer to read into.
lenThe number of bytes to write.
Note
This method may set ecode.

◆ readB32V()

size_t wfio::BinStream::readB32V ( wfio_flt32_t buf,
size_t  len 
)
inline

Read a vector of 32-bit IEEE 754 binary floats.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ readB64V()

size_t wfio::BinStream::readB64V ( wfio_flt64_t buf,
size_t  len 
)
inline

Read a vector of 64-bit IEEE 754 binary floats.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ readSI16V()

size_t wfio::BinStream::readSI16V ( sint16_t buf,
size_t  len 
)
inline

Read a vector of 16-bit signed integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ readSI32V()

size_t wfio::BinStream::readSI32V ( sint32_t buf,
size_t  len 
)
inline

Read a vector of 32-bit signed integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ readSI64V()

size_t wfio::BinStream::readSI64V ( sint64_t buf,
size_t  len 
)
inline

Read a vector of 64-bit signed integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ readUI16V()

size_t wfio::BinStream::readUI16V ( uint16_t buf,
size_t  len 
)
inline

Read a vector of 16-bit unsigned integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ readUI32V()

size_t wfio::BinStream::readUI32V ( uint32_t buf,
size_t  len 
)
inline

Read a vector of 32-bit unsigned integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ readUI64V()

size_t wfio::BinStream::readUI64V ( uint64_t buf,
size_t  len 
)
inline

Read a vector of 64-bit unsigned integers.

Parameters
bufThe buffer to read into.
lenThe maximum number of elements to read.
Returns
The number of elements actually read on success; otherwise, WFIO_NPOS.

◆ valid()

bool wfio::BinStream::valid ( ) const
throw (
)
inline

Determine if this BinStream is valid.

This function determines whether or not this BinSTream can be operated on. It is valid iff its underlying pointer is not null.

Returns
True if this object is valid.

◆ vdcntl()

int wfio::BinStream::vdcntl ( wfio_dcntl_t  cmd,
va_list  va 
)
inline

Perform device-independent I/O control on this binstream using a va_list.

Parameters
cmdThe command to send to the binstream.
vaAdditional arguments to the ioctl.

◆ vioctl()

int wfio::BinStream::vioctl ( int  cmd,
va_list  va 
)
inline

Perform device-dependent I/O control on this binstream.

Parameters
cmdThe command to send to the binstream.
...Additional arguments to the ioctl.
Returns
A return value peculiar to the command invoked.

◆ write() [1/3]

size_t wfio::BinStream::write ( const void *  buf,
size_t  sz,
size_t  elem 
)
inline

Write elements to this BinStream.

Parameters
bufThe buffer to write from.
szThe size of each elements.
lenThe maximum number of elements to write.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

◆ write() [2/3]

size_t wfio::BinStream::write ( const void *  buf,
size_t  len 
)
inline

Write a byte vector to this BinStream.

Parameters
bufThe buffer to write from.
lenThe maximum number of bytes to write.
Returns
The number of bytes actually written on success; otherwise, WFIO_NPOS.

◆ write() [3/3]

bool wfio::BinStream::write ( char  c)
inline

Write a byte to the this BinStream.

Parameters
cThe byte to write.
Returns
Nonzero if the byte was written; otherwise, zero.

◆ writeB32()

bool wfio::BinStream::writeB32 ( wfio_flt32_t  f32)
inline

Write a single 32-bit IEEE 754 binary float.

Parameters
ui64The float to write.
Returns
Nonzero on success; otherwiser, zero.
Note
This method may set ecode.

◆ writeB32V()

size_t wfio::BinStream::writeB32V ( const wfio_flt32_t buf,
size_t  len 
)
inline

Write a vector of 32-bit IEEE 754 binary floats.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ writeB64()

bool wfio::BinStream::writeB64 ( wfio_flt64_t  f64)
inline

Write a single 64-bit IEEE 754 binary float.

Parameters
ui64The float to write.
Returns
Nonzero on success; otherwiser, zero.
Note
This method may set ecode.

◆ writeB64V()

size_t wfio::BinStream::writeB64V ( const wfio_flt64_t buf,
size_t  len 
)
inline

Write a vector of 64-bit IEEE 754 binary floats.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ writeSI16()

bool wfio::BinStream::writeSI16 ( wfio_sint16_t  si16)
inline

Write a single 16-bit signed integer.

Parameters
si16The integer to write.
Returns
Nonzero on success; otherwiser, zero.

◆ writeSI16V()

size_t wfio::BinStream::writeSI16V ( const sint16_t buf,
size_t  len 
)
inline

Write a vector of 16-bit signed integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

◆ writeSI32()

bool wfio::BinStream::writeSI32 ( sint32_t  si32)
inline

Write a single 32-bit signed integer.

Parameters
si32The integer to write.
Returns
Nonzero on success; otherwiser, zero.

◆ writeSI32V()

size_t wfio::BinStream::writeSI32V ( const sint32_t buf,
size_t  len 
)
inline

Write a vector of 32-bit signed integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

◆ writeSI64()

bool wfio::BinStream::writeSI64 ( sint64_t  si64)
inline

Write a single 64-bit signed integer.

Parameters
si64The integer to write.
Returns
Nonzero on success; otherwiser, zero..

◆ writeSI64V()

size_t wfio::BinStream::writeSI64V ( const sint64_t buf,
size_t  len 
)
inline

Write a vector of 64-bit signed integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.
Note
This method may set ecode.

◆ writeUI16()

bool wfio::BinStream::writeUI16 ( uint16_t  ui16)
inline

Write a single 16-bit unsigned integer.

Parameters
ui16The integer to write.
Returns
Nonzero on success; otherwiser, zero.

◆ writeUI16V()

size_t wfio::BinStream::writeUI16V ( const uint16_t buf,
size_t  len 
)
inline

Write a vector of 16-bit unsigned integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

◆ writeUI32()

bool wfio::BinStream::writeUI32 ( uint32_t  ui32)
inline

Write a single 32-bit unsigned integer.

Parameters
ui32The integer to write.
Returns
Nonzero on success; otherwiser, zero.

◆ writeUI32V()

size_t wfio::BinStream::writeUI32V ( const uint32_t buf,
size_t  len 
)
inline

Write a vector of 32-bit unsigned integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

◆ writeUI64()

bool wfio::BinStream::writeUI64 ( uint64_t  ui64)
inline

Write a single 64-bit unsigned integer.

Parameters
ui64The integer to write.
Returns
Nonzero on success; otherwiser, zero.

◆ writeUI64V()

size_t wfio::BinStream::writeUI64V ( const uint64_t buf,
size_t  len 
)
inline

Write a vector of 64-bit unsigned integers.

Parameters
bufThe buffer to write from.
lenThe maximum number of elements to read.
Returns
The number of elements actually written on success; otherwise, WFIO_NPOS.

The documentation for this class was generated from the following file: