ZIStream Class Reference

#include <Pt/ZStream.h>

Input stream that inflates zlib or gzip data. More...

Inherits BasicIStream< char >.

Public Types

using Format = ZBuffer::Format
 Compression/decompression format.

Public Member Functions

 ZIStream (Format fmt=Format::Zlib)
 Construct with format.
 ZIStream (std::istream &is, Format fmt=Format::Zlib)
 Construct with target stream.
 ~ZIStream ()
 Destructor.
ZBufferzBuffer ()
 Returns the compression buffer.
void attach (std::istream &is)
 Attach to target stream.
void detach ()
 Detach from target stream.
void reset ()
 Reset to begin new compression/decompression.
void reset (std::istream &is)
 Reset to begin new compression/decompression.
void finish ()
 Finish and flush remaining data to the target stream.
std::size_t zcount () const
 Returns the total number of decompressed bytes produced so far.
std::streamsize peeksome (char *buffer, std::streamsize n)
 Peeks bytes in the stream buffer.
BasicStreamBuffer< char > * buffer ()
 Returns the buffer.
void setBuffer (BasicStreamBuffer< char > *sb)
 Sets the buffer.

Detailed Description

ZIStream owns a ZBuffer and reads uncompressed bytes from a compressed std::istream. Construct it with a format, or with a target stream and a format. attach(), detach(), reset() and finish() forward to the buffer. zBuffer() returns the owned buffer. The target is not owned.

Member Function Documentation

◆ peeksome()

std::streamsize peeksome ( char * buffer,
std::streamsize n )
inherited

The number of bytes that can be peeked depends on the current stream buffer get area and maybe less than requested, similar to istream::readsome().