class Poco::StreamConverterBuf

Overview

A StreamConverter converts streams from one encoding (inEncoding) into another (outEncoding). Moreā€¦

#include <StreamConverter.h>

class StreamConverterBuf: public Poco::BasicUnbufferedStreamBuf
{
public:
    // construction

    StreamConverterBuf(
        std::istream& istr,
        const TextEncoding& inEncoding,
        const TextEncoding& outEncoding,
        int defaultChar = '?'
        );

    StreamConverterBuf(
        std::ostream& ostr,
        const TextEncoding& inEncoding,
        const TextEncoding& outEncoding,
        int defaultChar = '?'
        );

    // methods

    int
    errors() const;

protected:
    // methods

    virtual
    int
    readFromDevice();

    int
    writeToDevice(char c);
};

Inherited Members

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);

Detailed Documentation

A StreamConverter converts streams from one encoding (inEncoding) into another (outEncoding).

If a character cannot be represented in outEncoding, defaultChar is used instead. If a byte sequence is not valid in inEncoding, defaultChar is used instead and the encoding error count is incremented.

Construction

StreamConverterBuf(
    std::istream& istr,
    const TextEncoding& inEncoding,
    const TextEncoding& outEncoding,
    int defaultChar = '?'
    )

Creates the StreamConverterBuf and connects it to the given input stream.

StreamConverterBuf(
    std::ostream& ostr,
    const TextEncoding& inEncoding,
    const TextEncoding& outEncoding,
    int defaultChar = '?'
    )

Creates the StreamConverterBuf and connects it to the given output stream.

Methods

int
errors() const

Returns the number of encoding errors encountered.