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

Public Types

enum  Type { UNKNOWN = ::WFIO_PEER_UNKNOWN, DEVICE = ::WFIO_PEER_DEVICE, BINSTREAM = ::WFIO_PEER_BINSTREAM }
 A type specification for a peer. More...
 
typedef ::wfio_peer_t CType
 The C type from which a Peer is derived.
 

Public Member Functions

 Peer ()
 Construct the default Peer. More...
 
 Peer (CType &ctype, int *error=0)
 Construct a peer from a CType. More...
 
 Peer (CType &ctype, IOShare share, int *error=0)
 Construct a peer from a CType using the specified IO sharing mode. More...
 
 Peer (CType *ctype, int *error=0)
 Construct a peer from a CType pointer. More...
 
 Peer (CType *ctype, IOShare share, int *error=0)
 Construct a peer from a CType pointer using the specified IO sharing mode. More...
 
 Peer (Device &device, int *error=0)
 Construct a peer from a Device. More...
 
 Peer (Device &device, IOShare share, int *error=0)
 Construct a Peer from a Device using the specified IO sharing mode. More...
 
 Peer (BinStream &bin, int *error=0)
 Construct a Peer from a BinsStream. More...
 
 Peer (BinStream &bin, IOShare share, int *error=0)
 Construct a Peer from a BinsStream using the specified IO sharing mode. More...
 
 ~Peer ()
 
Type type () const throw ()
 Obtain the type of this Peer.
 
size_t read (void *buf, size_t sz, size_t elem, int *error=0) throw ()
 Read elements from this Peer. More...
 
size_t read (void *buf, size_t len, int *error) throw ()
 Read bytes from this Peer. More...
 
int read (int *error=0)
 Read a single byte from this peer. More...
 
size_t write (const void *buf, size_t sz, size_t elem, int *error=0)
 Write elements to this Peer. More...
 
size_t write (const void *buf, size_t len, int *error=0)
 Write bytes to this peer. More...
 
int write (char c, int *error=0)
 Write a single byte to this peer. More...
 
bool seek (off_t offset, wfio_whence_t whence, int *error=0)
 Seek to a position in the stream. More...
 
bool canSeek () const throw ()
 Determine whether or not this Peer can seek. More...
 
off_t tell (int *error=0) throw ()
 Determine the current stream position of this peer. More...
 
bool flush (int *error=0)
 Attempt to flush this Peer. More...
 
size_t bufsz (int *error=0) const throw ()
 Obtain the buffer size for this Peer. More...
 
size_t bufsz (size_t sz, int *error=0) throw ()
 Set the buffer size for this Peer. More...
 
int vdcntl (DCntl cmd, va_list va)
 Perform device-independent I/O on this peer using a va_list. More...
 
int vdcntlEx (int *error, DCntl cmd, va_list va)
 Perform device-independent I/O on this peer using a va_list, capturing any errors in error. More...
 
int dcntl (DCntl cmd,...)
 Perform device-independent I/O on this Peer. More...
 
int dcntl (int *error, DCntl cmd,...)
 Perform device-independent I/O on this Peer, capturing any errors in error. More...
 
int vioctl (int cmd, va_list va)
 Perform device-dependent I/O on this peer using a va_list. More...
 
int vioctlEx (int *error, int cmd, va_list va)
 Perform device-dependent I/O on this peer using a va_list, capturing any errors in error. More...
 
int ioctl (int cmd,...)
 Perform device-dependent I/O on this Peer. More...
 
int ioctlExt (int *error, int cmd,...)
 Perform device-dependent I/O on this Peer, capturing any errors in error. More...
 
 operator::wfio_peer_t * ()
 Implicitly convert this Peer.
 
WFIO_DLL_FASTCALL Device toDevice (int *error=0)
 Convert this Peer to a Device. More...
 
 operator Device ()
 Implicitly convert this Peer to a Device. More...
 
WFIO_DLL_FASTCALL BinStream toBinStream (int *error=0)
 Convert this Peer to a BinStream. More...
 
 operator BinStream ()
 Implicitly convert this Peer to a BinStream. More...
 

Member Enumeration Documentation

◆ Type

A type specification for a peer.

Enumerator
UNKNOWN 

The peer type is unknown.

DEVICE 

The peer type is a device.

BINSTREAM 

The peer type is a binstream.

Constructor & Destructor Documentation

◆ Peer() [1/9]

wfio::Peer::Peer ( )
inline

Construct the default Peer.

This constructor creates an invalid peer.

◆ Peer() [2/9]

wfio::Peer::Peer ( CType ctype,
int *  error = 0 
)
inline

Construct a peer from a CType.

Parameters
ctypeThe ctype to wrap.
errorAn optional error indicator.

◆ Peer() [3/9]

wfio::Peer::Peer ( CType ctype,
IOShare  share,
int *  error = 0 
)
inline

Construct a peer from a CType using the specified IO sharing mode.

Parameters
ctypeThe ctype to wrap.
shareThe IO sharing mode.
errorAn optional error indicator.

◆ Peer() [4/9]

wfio::Peer::Peer ( CType ctype,
int *  error = 0 
)
inline

Construct a peer from a CType pointer.

Parameters
ctypeThe ctype to wrap.
errorAn optional error indicator.

◆ Peer() [5/9]

wfio::Peer::Peer ( CType ctype,
IOShare  share,
int *  error = 0 
)
inline

Construct a peer from a CType pointer using the specified IO sharing mode.

Parameters
ctypeThe ctype to wrap.
shareThe IO sharing mode.
errorAn optional error indicator.

◆ Peer() [6/9]

wfio::Peer::Peer ( Device device,
int *  error = 0 
)
inline

Construct a peer from a Device.

Parameters
deviceThe device to create the Peer from.
errorAn optional error indicator.

◆ Peer() [7/9]

wfio::Peer::Peer ( Device device,
IOShare  share,
int *  error = 0 
)
inline

Construct a Peer from a Device using the specified IO sharing mode.

Parameters
deviceThe Device to create the Peer from.
shareThe IO sharing mode.
errorAn optional error indicator.

◆ Peer() [8/9]

wfio::Peer::Peer ( BinStream bin,
int *  error = 0 
)
inline

Construct a Peer from a BinsStream.

Parameters
binThe BinStream to create the Peer from.
errorAn optional error indicator.

◆ Peer() [9/9]

wfio::Peer::Peer ( BinStream bin,
IOShare  share,
int *  error = 0 
)
inline

Construct a Peer from a BinsStream using the specified IO sharing mode.

Parameters
binThe BinStream to create the Peer from.
shareThe IO sharing mode.
errorAn optional error indicator.

◆ ~Peer()

wfio::Peer::~Peer ( )
inline
Parameters
Releasethis Peer.

This destructor releases this Peer's underlying CType.

Member Function Documentation

◆ bufsz() [1/2]

size_t wfio::Peer::bufsz ( int *  error = 0) const
throw (
)
inline

Obtain the buffer size for this Peer.

Parameters
errorAn optional error indicator.
Returns
The size of the buffer associated with this Peer on success; otherwise, WFIO_NPOS. A return value of zero shall indicate that the device is unbuffered.

◆ bufsz() [2/2]

size_t wfio::Peer::bufsz ( size_t  sz,
int *  error = 0 
)
throw (
)
inline

Set the buffer size for this Peer.

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

◆ canSeek()

bool wfio::Peer::canSeek ( ) const
throw (
)
inline

Determine whether or not this Peer can seek.

Returns
Whether or not this Peer can seek.

◆ dcntl() [1/2]

int wfio::Peer::dcntl ( DCntl  cmd,
  ... 
)
inline

Perform device-independent I/O on this Peer.

Parameters
cmdThe command to send to the peer.
...Additional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ dcntl() [2/2]

int wfio::Peer::dcntl ( int *  error,
DCntl  cmd,
  ... 
)
inline

Perform device-independent I/O on this Peer, capturing any errors in error.

Parameters
errorAn error indicator.
cmdThe command to send to the peer.
...Additional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ flush()

bool wfio::Peer::flush ( int *  error = 0)
inline

Attempt to flush this Peer.

Parameters
errorAn optional error indicator.
Returns
True iff the flush operation is successful.

◆ ioctl()

int wfio::Peer::ioctl ( int  cmd,
  ... 
)
inline

Perform device-dependent I/O on this Peer.

Parameters
cmdThe command to send to the peer.
...Additional arguments to the ioctl.
See also
vioctl

◆ ioctlExt()

int wfio::Peer::ioctlExt ( int *  error,
int  cmd,
  ... 
)
inline

Perform device-dependent I/O on this Peer, capturing any errors in error.

Parameters
errorAn error indicator.
cmdThe command to send to the peer.
...Additional arguments to the ioctl.
See also
vioctl

◆ operator BinStream()

wfio::Peer::operator BinStream ( )
inline

Implicitly convert this Peer to a BinStream.

See also
toBinStream()

◆ operator Device()

wfio::Peer::operator Device ( )
inline

Implicitly convert this Peer to a Device.

See also
toDevice()

◆ read() [1/3]

size_t wfio::Peer::read ( void *  buf,
size_t  sz,
size_t  elem,
int *  error = 0 
)
throw (
)
inline

Read elements from this Peer.

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

◆ read() [2/3]

size_t wfio::Peer::read ( void *  buf,
size_t  len,
int *  error 
)
throw (
)
inline

Read bytes from this Peer.

Parameters
bufThe buffer to read into.
lenThe number of bytes to read.
errorAn optional error indicator.
Returns
The number of bytes read on success; otherwise, WFIO_NPOS.

◆ read() [3/3]

int wfio::Peer::read ( int *  error = 0)
inline

Read a single byte from this peer.

Parameters
errorAn optional error indicator.
Returns
The byte read on success; otherwise, WFIO_NPOS.

◆ seek()

bool wfio::Peer::seek ( off_t  offset,
wfio_whence_t  whence,
int *  error = 0 
)
inline

Seek to a position in the stream.

This method attempts to seek the peer to the specified position. This is only successful if the peer is open and seekable.

Parameters
offsetThe offset relative to whence to seek to.
whenceThe origin added to whence to seek to.
errorAn optional error indicator.
Returns
True only if the seek was successful..

◆ tell()

off_t wfio::Peer::tell ( int *  error = 0)
throw (
)
inline

Determine the current stream position of this peer.

Parameters
peerThe peer to interrogate.
errorAn optional error indicator.
Returns
The current stream position of the peer on success; otherwise, WFIO_NPOS.

◆ toBinStream()

WFIO_DLL_FASTCALL BinStream wfio::Peer::toBinStream ( int *  error = 0)

Convert this Peer to a BinStream.

This method creates a BinStream from this peer. The BinStream shall be valid if this peer represents a valid binstream; otherwise, it shall return an invalid device and error shall be set if it is not NULL.

Parameters
errorAn optional error indicator.
Returns
A Binstream.

◆ toDevice()

WFIO_DLL_FASTCALL Device wfio::Peer::toDevice ( int *  error = 0)

Convert this Peer to a Device.

This method creates a Device from this peer. The device shall be valid if this peer represents a valid device; otherwise, it shall return an invalid device and error shall be set if it is not NULL.

Parameters
errorAn optional error indicator.
Returns
A Device.

◆ vdcntl()

int wfio::Peer::vdcntl ( DCntl  cmd,
va_list  va 
)
inline

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

Parameters
cmdThe command to send to the peer.
vaAdditional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ vdcntlEx()

int wfio::Peer::vdcntlEx ( int *  error,
DCntl  cmd,
va_list  va 
)
inline

Perform device-independent I/O on this peer using a va_list, capturing any errors in error.

Parameters
errorAn error indicator.
cmdThe command to send to the peer.
vaAdditional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ vioctl()

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

Perform device-dependent I/O on this peer using a va_list.

Parameters
cmdThe command to send to the peer.
vaAdditional arguments to the dcntl.
See also
wfio_device_vdcntl

◆ vioctlEx()

int wfio::Peer::vioctlEx ( int *  error,
int  cmd,
va_list  va 
)
inline

Perform device-dependent I/O on this peer using a va_list, capturing any errors in error.

Parameters
errorAn error indicator.
cmdThe command to send to the peer.
vaAdditional arguments to the ioctl.
See also
wfio_device_vioctl

◆ write() [1/3]

size_t wfio::Peer::write ( const void *  buf,
size_t  sz,
size_t  elem,
int *  error = 0 
)
inline

Write elements to this Peer.

Parameters
bufThe buffer to write from.
szThe size of each element.
elemThe number of elements to write.
errorAn optional error indicator.
Returns
The number of elements written on success; otherwise, WFIO_NPOS.

◆ write() [2/3]

size_t wfio::Peer::write ( const void *  buf,
size_t  len,
int *  error = 0 
)
inline

Write bytes to this peer.

Parameters
bufThe buffer to write from.
lenThe number of bytes to write.
errorAn optional error indicator.
Returns
The number of bytes written on success; otherwise, WFIO_NPOS.

◆ write() [3/3]

int wfio::Peer::write ( char  c,
int *  error = 0 
)
inline

Write a single byte to this peer.

Parameters
cThe byte to write.
errorAn optional error indicator.
Returns
Nonzero on success; otherwise, zero.

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