# Poco

# class DeflatingOutputStream

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

## Description

This stream compresses all data passing through it using zlib's deflate algorithm. After all data has been written to the stream, close() must be called to ensure completion of compression. Example:

    std::ofstream ostr("data.gz", std::ios::binary);
    DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
    deflater << "Hello, world!" << std::endl;
    deflater.close();
    ostr.close();

## Inheritance

Direct Base Classes: DeflatingIOS, std::ostream

All Base Classes: DeflatingIOS, std::ios, std::ostream

## Member Summary

Member Functions: close, sync

Inherited Functions: rdbuf

## Constructors

### DeflatingOutputStream

DeflatingOutputStream(
std::ostream & ostr,
DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB,
int level = (- 1)
);

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

### DeflatingOutputStream

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

Creates a DeflatingOutputStream 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

### ~DeflatingOutputStream

~DeflatingOutputStream();

Destroys the DeflatingOutputStream.

## Member Functions

### close

int close();

Finishes up the stream.

Must be called when deflating to an output stream.

### sync

virtual int sync();