# Poco

# class InflatingStreamBuf

Library: Foundation
Package: Streams
Header: Poco/InflatingStream.h

## Description

This is the streambuf class used by InflatingInputStream and InflatingOutputStream. 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 decompression.

## Inheritance

Direct Base Classes: BufferedStreamBuf

All Base Classes: BufferedStreamBuf

## Member Summary

Member Functions: close, readFromDevice, reset, writeToDevice

## Enumerations

### StreamType

STREAM_ZLIB

Expect a zlib header, use Adler-32 checksum.

STREAM_GZIP

Expect a gzip header, use CRC-32 checksum.

STREAM_ZIP

STREAM_ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by caller)

## Constructors

### InflatingStreamBuf

InflatingStreamBuf(
std::istream & istr,
StreamType type
);

Creates an InflatingStreamBuf for expanding the compressed data read from the give input stream.

### InflatingStreamBuf

InflatingStreamBuf(
std::istream & istr,
int windowBits
);

Creates an InflatingStreamBuf for expanding the compressed data read from the given input stream.

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

### InflatingStreamBuf

InflatingStreamBuf(
std::ostream & ostr,
StreamType type
);

Creates an InflatingStreamBuf for expanding the compressed data passed through and forwarding it to the given output stream.

### InflatingStreamBuf

InflatingStreamBuf(
std::ostream & ostr,
int windowBits
);

Creates an InflatingStreamBuf for expanding the compressed data passed through and forwarding it to the given output stream.

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

## Destructor

### ~InflatingStreamBuf

~InflatingStreamBuf();

Destroys the InflatingStreamBuf.

## Member Functions

### close

int close();

Finishes up the stream.

Must be called when inflating to an output stream.

### reset

void reset();

Resets the stream buffer.

### readFromDevice

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

### writeToDevice

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