A stream buffer for IODevices with linear buffer area. More...

#include <cxxtools/streambuffer.h>

Inheritance diagram for cxxtools::StreamBuffer:
cxxtools::BasicStreamBuffer< char > cxxtools::Connectable basic_streambuf

Public Member Functions

 StreamBuffer (IODevice &ioDevice, size_t bufferSize=8192, bool extend=false)
 Constructs an IOBuffer for an IODevice.
 StreamBuffer (size_t bufferSize=8192, bool extend=false)
 Default constructor.
 ~StreamBuffer ()
void attach (IODevice &ioDevice)
IODevicedevice ()
void beginRead ()
 Sets the stream buffer in reading mode.
void endRead ()
 Finalizes a read initiated with beginRead.
size_t beginWrite ()
 Sets the stream buffer in writing mode if data is available in output buffer.
size_t endWrite ()
 Finalizes the write operation.
bool reading () const
 Returns true if the underlying device is in reading mode.
bool writing () const
 Returns true if the underlying device is in writing mode.
void discard ()
 Empties the data in the buffer.
- Public Member Functions inherited from cxxtools::BasicStreamBuffer< char >
std::streamsize speekn (char *buffer, std::streamsize size)
std::streamsize out_avail ()
- Public Member Functions inherited from cxxtools::Connectable
 Connectable ()
 Default constructor.
virtual ~Connectable ()
 Closes all connections.
virtual void onConnectionOpen (const Connection &c)
 Registers a Connection with the Connectable.
virtual void onConnectionClose (const Connection &c)
 Unregisters a Connection from the Connectable.
size_t connectionCount () const

Public Attributes

Signal< StreamBuffer & > inputReady
 Signals, that the underlying I/O device has data to read.
Signal< StreamBuffer & > outputReady
 Signals, that the underlying I/O device can receive data without blocking.

Protected Member Functions

virtual int sync ()
virtual std::streamsize showfull ()
virtual std::streamsize xspeekn (char *buffer, std::streamsize size)
virtual int_type underflow ()
virtual int_type overflow (int_type ch)
virtual int_type pbackfail (int_type c)
virtual pos_type seekoff (off_type offset, std::ios::seekdir sd, std::ios::openmode mode)
 Alters the stream positions.
virtual pos_type seekpos (pos_type p, std::ios::openmode mode)
 Alters the stream positions.
- Protected Member Functions inherited from cxxtools::Connectable
 Connectable (const Connectable &)
 Copy constructor.
Connectableoperator= (const Connectable &)
 Assignment operator.
const std::list< Connection > & connections () const
 Returns a list of all current connections.
std::list< Connection > & connections ()
 Returns a list of all current connections.
void clear ()

Additional Inherited Members

- Protected Attributes inherited from cxxtools::Connectable
std::list< Connection_connections
 A list of all current connections.

Detailed Description

A stream buffer for IODevices with linear buffer area.

Constructor & Destructor Documentation

cxxtools::StreamBuffer::StreamBuffer ( IODevice ioDevice,
size_t  bufferSize = 8192,
bool  extend = false 
)
explicit

Constructs an IOBuffer for an IODevice.

cxxtools::StreamBuffer::StreamBuffer ( size_t  bufferSize = 8192,
bool  extend = false 
)
explicit

Default constructor.

cxxtools::StreamBuffer::~StreamBuffer ( )

Member Function Documentation

void cxxtools::StreamBuffer::attach ( IODevice ioDevice)
void cxxtools::StreamBuffer::beginRead ( )

Sets the stream buffer in reading mode.

This signals the cxxtools::Selector, that the streambuffer is interested in receiving data. When data is available the cxxtools::Selector will emit the inputReady signal. After that endRead can be called without blocking.

size_t cxxtools::StreamBuffer::beginWrite ( )

Sets the stream buffer in writing mode if data is available in output buffer.

The device will emit a outputReady signal when it will be ready to write without blocking. When there is no data to be written, the device mode is not changed.

The streambuffer tries to write data immediately. The number of bytes written is returned. When data is already written, the device is still changed to writing mode and a endWrite must be called to finalize the write.

When the device is already in writing mode, nothing is done.

IODevice* cxxtools::StreamBuffer::device ( )
inline
void cxxtools::StreamBuffer::discard ( )

Empties the data in the buffer.

The device must not be in reading or writing mode. A exception of type cxxtools::IOPending will be thrown otherwise.

void cxxtools::StreamBuffer::endRead ( )

Finalizes a read initiated with beginRead.

The call to endRead reads at least one byte from the underlying I/O device to the buffer. When no data is available, the call will block.

size_t cxxtools::StreamBuffer::endWrite ( )

Finalizes the write operation.

A write operation must be finalized with the call to endWrite. The method returns the number of bytes written either when beginWrite was called or here on endWrite.

virtual int_type cxxtools::StreamBuffer::overflow ( int_type  ch)
protectedvirtual
virtual int_type cxxtools::StreamBuffer::pbackfail ( int_type  c)
protectedvirtual
bool cxxtools::StreamBuffer::reading ( ) const
inline

Returns true if the underlying device is in reading mode.

The device is in reading mode, when beginRead has been called. The call of endRead finished the reading mode.

virtual pos_type cxxtools::StreamBuffer::seekoff ( off_type  offset,
std::ios::seekdir  sd,
std::ios::openmode  mode 
)
protectedvirtual

Alters the stream positions.

virtual pos_type cxxtools::StreamBuffer::seekpos ( pos_type  p,
std::ios::openmode  mode 
)
protectedvirtual

Alters the stream positions.

virtual std::streamsize cxxtools::StreamBuffer::showfull ( )
protectedvirtual
virtual int cxxtools::StreamBuffer::sync ( )
protectedvirtual
virtual int_type cxxtools::StreamBuffer::underflow ( )
protectedvirtual
bool cxxtools::StreamBuffer::writing ( ) const
inline

Returns true if the underlying device is in writing mode.

The device is in writing mode, when beginWrite has been called. The call of endWrite finished the writing mode.

virtual std::streamsize cxxtools::StreamBuffer::xspeekn ( char *  buffer,
std::streamsize  size 
)
protectedvirtual

Member Data Documentation

Signal<StreamBuffer&> cxxtools::StreamBuffer::inputReady

Signals, that the underlying I/O device has data to read.

Signal<StreamBuffer&> cxxtools::StreamBuffer::outputReady

Signals, that the underlying I/O device can receive data without blocking.


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