#include <cxxtools/iodevice.h>

Public Types | |
|
typedef std::char_traits< char > ::pos_type | pos_type |
|
typedef std::char_traits< char > ::off_type | off_type |
| typedef std::ios_base::seekdir | SeekDir |
| typedef IOS_OpenMode | OpenMode |
Public Member Functions | |
| virtual | ~IODevice () |
| Destructor. | |
| void | beginRead (char *buffer, size_t n) |
| size_t | endRead () |
| size_t | read (char *buffer, size_t n) |
| Read data from I/O device. | |
| void | beginWrite (const char *buffer, size_t n) |
| size_t | endWrite () |
| size_t | write (const char *buffer, size_t n) |
| Write data to I/O device. | |
| bool | seekable () const |
| Returns true if device is seekable. | |
| pos_type | seek (off_type offset, std::ios::seekdir sd) |
| Move the next read position to the given offset. | |
| size_t | peek (char *buffer, size_t n) |
| Read data from I/O device without consuming them. | |
| void | sync () |
| Synchronize device. | |
| pos_type | position () |
| Returns the current I/O position. | |
| bool | eof () const |
| Returns if the device has reached EOF. | |
| bool | async () const |
| Returns true if the device operates in asynchronous mode. | |
| virtual IODeviceImpl & | ioimpl ()=0 |
| bool | reading () const |
| bool | writing () const |
| char * | rbuf () const |
| size_t | rbuflen () const |
| const char * | wbuf () const |
| size_t | wbuflen () const |
Public Attributes | |
| Signal< IODevice & > | inputReady |
| Notifies about availavle data. | |
| Signal< IODevice & > | outputReady |
| Notifies when data can be written. | |
| Signal< IODevice & > | errorOccured |
| Notifies when an error occured. | |
Static Public Attributes | |
| static const OpenMode | Sync = IOS_Sync |
| static const OpenMode | Async = IOS_Async |
| static const OpenMode | Read = IOS_Read |
| static const OpenMode | Write = IOS_Write |
| static const OpenMode | AtEnd = IOS_AtEnd |
| static const OpenMode | Append = IOS_Append |
| static const OpenMode | Trunc = IOS_Trunc |
Protected Member Functions | |
| IODevice () | |
| Default Constructor. | |
| virtual size_t | onBeginRead (char *buffer, size_t n, bool &eof)=0 |
| virtual size_t | onEndRead (bool &eof)=0 |
| virtual size_t | onRead (char *buffer, size_t count, bool &eof)=0 |
| Read bytes from device. | |
| virtual size_t | onBeginWrite (const char *buffer, size_t n)=0 |
| virtual size_t | onEndWrite ()=0 |
| virtual size_t | onWrite (const char *buffer, size_t count)=0 |
| Write bytes to device. | |
| virtual size_t | onPeek (char *, size_t) |
| Read data from I/O device without consuming them. | |
| virtual bool | onSeekable () const |
| Returns true if device is seekable. | |
| virtual pos_type | onSeek (off_type, std::ios::seekdir) |
| Move the next read position to the given offset. | |
| virtual void | onSync () const |
| Synchronize device. | |
| virtual size_t | onSize () const |
| Returns the size of the device. | |
| void | setEof (bool eof) |
| Sets or unsets the device to eof. | |
| void | setAsync (bool async) |
| Sets or unsets the device to async. | |
Protected Attributes | |
| char * | _rbuf |
| size_t | _rbuflen |
| size_t | _ravail |
| const char * | _wbuf |
| size_t | _wbuflen |
| size_t | _wavail |
| void * | _reserved |
| size_t read | ( | char * | buffer, | |
| size_t | n | |||
| ) |
Reads up to n bytes and stores them in buffer. Returns the number of bytes read, which may be less than requested and even 0 if the device operates in asynchronous (non-blocking) mode. In case of EOF the IODevice is set to eof.
| buffer | buffer where to place the data to be read. | |
| n | number of bytes to read |
| IOError |
| size_t write | ( | const char * | buffer, | |
| size_t | n | |||
| ) |
Writes n bytes from buffer to this I/O device. Returns the number of bytes written, which may be less than requested and even 0 if the device operates in asynchronous (non-blocking) mode. In case of EOF the IODevice is set to eof.
| buffer | buffer containing the data to be written. | |
| n | number of bytes that should be written. |
| IOError |
| bool seekable | ( | ) | const |
Tests if the device is seekable.
| pos_type seek | ( | off_type | offset, | |
| std::ios::seekdir | sd | |||
| ) |
Tries to move the current read position to the given offset. SeekMode determines the relative starting point of offset.
| offset | the offset the pointer should be moved by. | |
| mode | determines the relative starting offset. |
| IOError |
| size_t peek | ( | char * | buffer, | |
| size_t | n | |||
| ) |
Tries to extract up to n bytes from this object without consuming them. The bytes are stored in buffer, and the number of bytes peeked is returned.
| buffer | buffer where to place the data to be read. | |
| n | number of bytes to peek |
| IOError |
| void sync | ( | ) |
Commits written data to physical device.
| IOError |
| pos_type position | ( | ) |
The current I/O position is returned or an IOError is thrown if the device is not seekable. Seekability can be tested with BasicIODevice::seekable().
| IOError |
| bool eof | ( | ) | const |
Test if the I/O device has reached eof.
| Signal<IODevice&> inputReady |
| Signal<IODevice&> outputReady |
| Signal<IODevice&> errorOccured |
This signal is send when the device is monitored in a Selector or EventLoop and an error occured on the device.