template class Poco::BasicBufferedBidirectionalStreamBuf

Overview

This is an implementation of a buffered bidirectional streambuf that greatly simplifies the implementation of custom streambufs of various kinds. Moreā€¦

#include <BufferedBidirectionalStreamBuf.h>

template <
    typename ch,
    typename tr,
    typename ba = BufferAllocator<ch>
    >
class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf< ch, tr >
{
public:
    // construction

    BasicBufferedBidirectionalStreamBuf(
        std::streamsize bufferSize,
        openmode mode
        );

    // methods

    virtual
    int_type
    overflow(int_type c);

    virtual
    int_type
    underflow();

    virtual
    int
    sync();

protected:
    // typedefs

    typedef std::basic_streambuf<ch, tr> Base;
    typedef std::basic_ios<ch, tr> IOS;
    typedef ch char_type;
    typedef tr char_traits;
    typedef ba Allocator;
    typedef Base::int_type int_type;
    typedef Base::pos_type pos_type;
    typedef Base::off_type off_type;
    typedef IOS::openmode openmode;

    // methods

    void
    setMode(openmode mode);

    openmode
    getMode() const;

    void
    resetBuffers();
};

// direct descendants

class FIFOBufferStreamBuf;
class FileStreamBuf;
class SocketStreamBuf;

Detailed Documentation

This is an implementation of a buffered bidirectional streambuf that greatly simplifies the implementation of custom streambufs of various kinds.

Derived classes only have to override the methods readFromDevice() or writeToDevice().

In contrast to BasicBufferedStreambuf, this class supports simultaneous read and write access, so in addition to istream and ostream this streambuf can also be used for implementing an iostream.