template class Poco::BasicUnbufferedStreamBuf

Overview

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

#include <UnbufferedStreamBuf.h>

template <
    typename ch,
    typename tr
    >
class BasicUnbufferedStreamBuf: public std::basic_streambuf< ch, tr >
{
public:
    // methods

    virtual
    int_type
    overflow(int_type c);

    virtual
    int_type
    underflow();

    virtual
    int_type
    uflow();

    virtual
    int_type
    pbackfail(int_type c);

    virtual
    std::streamsize
    xsgetn(
        char_type* p,
        std::streamsize count
        );

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 Base::int_type int_type;
    typedef Base::pos_type pos_type;
    typedef Base::off_type off_type;
    typedef IOS::openmode openmode;

    // methods

    static
    int_type
    charToInt(char_type c);
};

// direct descendants

class Base32DecoderBuf;
class Base32EncoderBuf;
class Base64DecoderBuf;
class Base64EncoderBuf;
class CountingStreamBuf;
class HexBinaryDecoderBuf;
class HexBinaryEncoderBuf;
class LineEndingConverterStreamBuf;
class LogStreamBuf;
class HTTPResponseStreamBuf;
class MailStreamBuf;
class QuotedPrintableDecoderBuf;
class QuotedPrintableEncoderBuf;
class NullStreamBuf;
class StreamConverterBuf;
class TeeStreamBuf;

Detailed Documentation

This is an implementation of an unbuffered streambuf that greatly simplifies the implementation of custom streambufs of various kinds.

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

Methods

virtual
std::streamsize
xsgetn(
    char_type* p,
    std::streamsize count
    )

Some platforms (for example, Compaq C++) have buggy implementations of xsgetn that handle null buffers incorrectly.

Anyway, it does not hurt to provide an optimized implementation of xsgetn for this streambuf implementation.