class Poco::DeflatingStreamBuf

Overview

This is the streambuf class used by DeflatingInputStream and DeflatingOutputStream. Moreā€¦

#include <DeflatingStream.h>

class DeflatingStreamBuf: public Poco::BasicBufferedStreamBuf
{
public:
    // enums

    enum StreamType;

    // construction

    DeflatingStreamBuf(
        std::istream& istr,
        StreamType type,
        int level
        );

    DeflatingStreamBuf(
        std::istream& istr,
        int windowBits,
        int level
        );

    DeflatingStreamBuf(
        std::ostream& ostr,
        StreamType type,
        int level
        );

    DeflatingStreamBuf(
        std::ostream& ostr,
        int windowBits,
        int level
        );

    // methods

    int
    close();

protected:
    // methods

    int
    readFromDevice(
        char* buffer,
        std::streamsize length
        );

    int
    writeToDevice(
        const char* buffer,
        std::streamsize length
        );

    virtual
    int
    sync();
};

Inherited Members

public:
    // 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;

Detailed Documentation

This is the streambuf class used by DeflatingInputStream and DeflatingOutputStream.

The actual work is delegated to zlib (see http://zlib.net). Both zlib (deflate) streams and gzip streams are supported. Output streams should always call close() to ensure proper completion of compression. A compression level (0 to 9) can be specified in the constructor.

Construction

DeflatingStreamBuf(
    std::istream& istr,
    StreamType type,
    int level
    )

Creates a DeflatingStreamBuf for compressing data read from the given input stream.

DeflatingStreamBuf(
    std::istream& istr,
    int windowBits,
    int level
    )

Creates a DeflatingStreamBuf for compressing data read from the given input stream.

Please refer to the zlib documentation of deflateInit2() for a description of the windowBits parameter.

DeflatingStreamBuf(
    std::ostream& ostr,
    StreamType type,
    int level
    )

Creates a DeflatingStreamBuf for compressing data passed through and forwarding it to the given output stream.

DeflatingStreamBuf(
    std::ostream& ostr,
    int windowBits,
    int level
    )

Creates a DeflatingStreamBuf for compressing data passed through and forwarding it to the given output stream.

Please refer to the zlib documentation of deflateInit2() for a description of the windowBits parameter.

Methods

int
close()

Finishes up the stream.

Must be called when deflating to an output stream.