ZIOStream Class Reference

#include <Pt/ZStream.h>

Bidirectional stream for zlib or gzip. More...

Inherits BasicIOStream< char >.

Public Types

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

Public Member Functions

 ZIOStream ()
 Construct with target stream.
 ZIOStream (std::iostream &ios)
 Construct with target stream.
 ~ZIOStream ()
 Destructor.
ZBufferzBuffer ()
 Returns the compression buffer.
void attach (std::iostream &ios)
 Attach to target stream.
void detach ()
 Detach from target stream.
void reset ()
 Reset to begin new compression/decompression.
void reset (std::iostream &ios)
 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.
std::streamsize writesome (char *buffer, std::streamsize n)
 Write as much data as fits in buffer.
BasicStreamBuffer< char > * buffer ()
 Returns the buffer.
void setBuffer (BasicStreamBuffer< char > *sb)
 Sets the buffer.

Detailed Description

ZIOStream owns a ZBuffer and reads and writes uncompressed bytes on a compressed std::iostream. attach(), detach(), reset() and finish() forward to the buffer. zcount() is inflate output so far. 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().