Class Poco::DeflatingStreamBuf
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco

# class DeflatingStreamBuf

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

## Description

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.

## Inheritance

Direct Base Classes: BufferedStreamBuf

All Base Classes: BufferedStreamBuf

## Member Summary

Member Functions: close, readFromDevice, sync, writeToDevice

## Enumerations

### StreamType

STREAM_ZLIB

Create a zlib header, use Adler-32 checksum.

STREAM_GZIP

Create a gzip header, use CRC-32 checksum.

## Constructors

### DeflatingStreamBuf

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

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

### DeflatingStreamBuf

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

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

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.

## Destructor

### ~DeflatingStreamBuf

~DeflatingStreamBuf();

Destroys the DeflatingStreamBuf.

## Member Functions

### close

int close();

Finishes up the stream.

Must be called when deflating to an output stream.

### readFromDevice

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

### sync

virtual int sync();

### writeToDevice

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