Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
gzfilebuf Class Reference

Gzipped file stream buffer class. More...

#include <zfstream.h>

Inheritance diagram for gzfilebuf:
Inheritance graph
[legend]

Public Member Functions

gzfilebufattach (int fd, std::ios_base::openmode mode)
 Attach to already open gzipped file. More...
 
gzfilebufattach (int fd, std::ios_base::openmode mode)
 Attach to already open gzipped file. More...
 
gzfilebufattach (int file_descriptor, int io_mode)
 
gzfilebufattach (int file_descriptor, int io_mode)
 
gzfilebufclose ()
 
gzfilebufclose ()
 
gzfilebufclose ()
 Close gzipped file. More...
 
gzfilebufclose ()
 Close gzipped file. More...
 
 gzfilebuf ()
 
 gzfilebuf ()
 
 gzfilebuf ()
 
 gzfilebuf ()
 
int is_open () const
 
int is_open () const
 
bool is_open () const
 Check if file is open. More...
 
bool is_open () const
 Check if file is open. More...
 
gzfilebufopen (const char *name, int io_mode)
 
gzfilebufopen (const char *name, int io_mode)
 
gzfilebufopen (const char *name, std::ios_base::openmode mode)
 Open gzipped file. More...
 
gzfilebufopen (const char *name, std::ios_base::openmode mode)
 Open gzipped file. More...
 
virtual streampos seekoff (streamoff, ios::seek_dir, int)
 
virtual streampos seekoff (streamoff, ios::seek_dir, int)
 
int setcompression (int comp_level, int comp_strategy=Z_DEFAULT_STRATEGY)
 Set compression level and strategy on the fly. More...
 
int setcompression (int comp_level, int comp_strategy=Z_DEFAULT_STRATEGY)
 Set compression level and strategy on the fly. More...
 
int setcompressionlevel (int comp_level)
 
int setcompressionlevel (int comp_level)
 
int setcompressionstrategy (int comp_strategy)
 
int setcompressionstrategy (int comp_strategy)
 
virtual int sync ()
 
virtual int sync ()
 
virtual ~gzfilebuf ()
 
virtual ~gzfilebuf ()
 
virtual ~gzfilebuf ()
 
virtual ~gzfilebuf ()
 

Protected Member Functions

bool open_mode (std::ios_base::openmode mode, char *c_mode) const
 Convert ios open mode int to mode string used by zlib. More...
 
bool open_mode (std::ios_base::openmode mode, char *c_mode) const
 Convert ios open mode int to mode string used by zlib. More...
 
virtual int overflow (int=EOF)
 
virtual int overflow (int=EOF)
 
virtual int_type overflow (int_type c=traits_type::eof())
 Write put area to gzipped file. More...
 
virtual int_type overflow (int_type c=traits_type::eof())
 Write put area to gzipped file. More...
 
virtual std::streambuf * setbuf (char_type *p, std::streamsize n)
 Installs external stream buffer. More...
 
virtual std::streambuf * setbuf (char_type *p, std::streamsize n)
 Installs external stream buffer. More...
 
virtual std::streamsize showmanyc ()
 Number of characters available in stream buffer. More...
 
virtual std::streamsize showmanyc ()
 Number of characters available in stream buffer. More...
 
virtual int sync ()
 Flush stream buffer to file. More...
 
virtual int sync ()
 Flush stream buffer to file. More...
 
virtual int underflow ()
 
virtual int underflow ()
 
virtual int_type underflow ()
 Fill get area from gzipped file. More...
 
virtual int_type underflow ()
 Fill get area from gzipped file. More...
 

Private Member Functions

void disable_buffer ()
 Destroy internal buffer. More...
 
void disable_buffer ()
 Destroy internal buffer. More...
 
void enable_buffer ()
 Allocate internal buffer. More...
 
void enable_buffer ()
 Allocate internal buffer. More...
 
int fillbuf ()
 
int fillbuf ()
 
int flushbuf ()
 
int flushbuf ()
 

Private Attributes

char_typebuffer
 Stream buffer. More...
 
std::streamsize buffer_size
 Stream buffer size. More...
 
gzFile file
 
std::ios_base::openmode io_mode
 
short mode
 
bool own_buffer
 True if this object owns stream buffer. More...
 
bool own_fd
 True if this object owns file descriptor. More...
 
short own_file_descriptor
 

Detailed Description

Gzipped file stream buffer class.

This class implements basic_filebuf for gzipped files. It doesn't yet support seeking (allowed by zlib but slow/limited), putback and read/write access (tricky). Otherwise, it attempts to be a drop-in replacement for the standard file streambuf.

Definition at line 8 of file bloaty/third_party/zlib/contrib/iostream/zfstream.h.

Constructor & Destructor Documentation

◆ gzfilebuf() [1/4]

gzfilebuf::gzfilebuf ( )

◆ ~gzfilebuf() [1/4]

gzfilebuf::~gzfilebuf ( )
virtual

◆ gzfilebuf() [2/4]

gzfilebuf::gzfilebuf ( )

◆ ~gzfilebuf() [2/4]

virtual gzfilebuf::~gzfilebuf ( )
virtual

◆ gzfilebuf() [3/4]

gzfilebuf::gzfilebuf ( )

◆ ~gzfilebuf() [3/4]

virtual gzfilebuf::~gzfilebuf ( )
virtual

◆ gzfilebuf() [4/4]

gzfilebuf::gzfilebuf ( )

◆ ~gzfilebuf() [4/4]

virtual gzfilebuf::~gzfilebuf ( )
virtual

Member Function Documentation

◆ attach() [1/4]

gzfilebuf * gzfilebuf::attach ( int  fd,
std::ios_base::openmode  mode 
)

Attach to already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags.
Returns
this on success, NULL on failure.

Definition at line 79 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ attach() [2/4]

gzfilebuf* gzfilebuf::attach ( int  fd,
std::ios_base::openmode  mode 
)

Attach to already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags.
Returns
this on success, NULL on failure.

◆ attach() [3/4]

gzfilebuf * gzfilebuf::attach ( int  file_descriptor,
int  io_mode 
)

◆ attach() [4/4]

gzfilebuf* gzfilebuf::attach ( int  file_descriptor,
int  io_mode 
)

◆ close() [1/4]

gzfilebuf * gzfilebuf::close ( )

◆ close() [2/4]

gzfilebuf* gzfilebuf::close ( )

◆ close() [3/4]

gzfilebuf* gzfilebuf::close ( )

Close gzipped file.

Returns
this on success, NULL on failure.

◆ close() [4/4]

gzfilebuf* gzfilebuf::close ( )

Close gzipped file.

Returns
this on success, NULL on failure.

◆ disable_buffer() [1/2]

void gzfilebuf::disable_buffer ( )
private

Destroy internal buffer.

This function is safe to call multiple times. It will ensure that the internal buffer is deallocated if it exists. In any case, it will also reset the buffer pointers.

◆ disable_buffer() [2/2]

void gzfilebuf::disable_buffer ( )
private

Destroy internal buffer.

This function is safe to call multiple times. It will ensure that the internal buffer is deallocated if it exists. In any case, it will also reset the buffer pointers.

Definition at line 347 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ enable_buffer() [1/2]

void gzfilebuf::enable_buffer ( )
private

Allocate internal buffer.

This function is safe to call multiple times. It will ensure that a proper internal buffer exists if it is required. If the buffer already exists or is external, the buffer pointers will be reset to their original state.

◆ enable_buffer() [2/2]

void gzfilebuf::enable_buffer ( )
private

Allocate internal buffer.

This function is safe to call multiple times. It will ensure that a proper internal buffer exists if it is required. If the buffer already exists or is external, the buffer pointers will be reset to their original state.

Definition at line 308 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ fillbuf() [1/2]

int gzfilebuf::fillbuf ( )
private

◆ fillbuf() [2/2]

int gzfilebuf::fillbuf ( )
private

◆ flushbuf() [1/2]

int gzfilebuf::flushbuf ( )
private

◆ flushbuf() [2/2]

int gzfilebuf::flushbuf ( )
private

◆ is_open() [1/4]

int gzfilebuf::is_open ( ) const
inline

◆ is_open() [2/4]

int gzfilebuf::is_open ( ) const
inline

Definition at line 22 of file zlib/contrib/iostream/zfstream.h.

◆ is_open() [3/4]

bool gzfilebuf::is_open ( ) const
inline

Check if file is open.

Returns
True if file is open.

Definition at line 57 of file zlib/contrib/iostream3/zfstream.h.

◆ is_open() [4/4]

bool gzfilebuf::is_open ( ) const
inline

Check if file is open.

Returns
True if file is open.

Definition at line 57 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ open() [1/4]

gzfilebuf * gzfilebuf::open ( const char *  name,
int  io_mode 
)

◆ open() [2/4]

gzfilebuf* gzfilebuf::open ( const char *  name,
int  io_mode 
)

◆ open() [3/4]

gzfilebuf* gzfilebuf::open ( const char *  name,
std::ios_base::openmode  mode 
)

Open gzipped file.

Parameters
nameFile name.
modeOpen mode flags.
Returns
this on success, NULL on failure.

◆ open() [4/4]

gzfilebuf * gzfilebuf::open ( const char *  name,
std::ios_base::openmode  mode 
)

Open gzipped file.

Parameters
nameFile name.
modeOpen mode flags.
Returns
this on success, NULL on failure.

Definition at line 51 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ open_mode() [1/2]

bool gzfilebuf::open_mode ( std::ios_base::openmode  mode,
char *  c_mode 
) const
protected

Convert ios open mode int to mode string used by zlib.

Returns
True if valid mode flag combination.

Definition at line 131 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ open_mode() [2/2]

bool gzfilebuf::open_mode ( std::ios_base::openmode  mode,
char *  c_mode 
) const
protected

Convert ios open mode int to mode string used by zlib.

Returns
True if valid mode flag combination.

◆ overflow() [1/4]

virtual int gzfilebuf::overflow ( int  = EOF)
protectedvirtual

◆ overflow() [2/4]

int gzfilebuf::overflow ( int  c = EOF)
protectedvirtual

◆ overflow() [3/4]

virtual int_type gzfilebuf::overflow ( int_type  c = traits_type::eof())
protectedvirtual

Write put area to gzipped file.

Parameters
cExtra character to add to buffer contents.
Returns
Non-EOF on success, EOF on error.

This actually writes characters in stream buffer to gzipped file. With unbuffered output this is done one character at a time.

◆ overflow() [4/4]

gzfilebuf::int_type gzfilebuf::overflow ( int_type  c = traits_type::eof())
protectedvirtual

Write put area to gzipped file.

Parameters
cExtra character to add to buffer contents.
Returns
Non-EOF on success, EOF on error.

This actually writes characters in stream buffer to gzipped file. With unbuffered output this is done one character at a time.

Definition at line 214 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ seekoff() [1/2]

virtual streampos gzfilebuf::seekoff ( streamoff  ,
ios::seek_dir  ,
int   
)
virtual

◆ seekoff() [2/2]

streampos gzfilebuf::seekoff ( streamoff  off,
ios::seek_dir  dir,
int  which 
)
virtual

◆ setbuf() [1/2]

std::streambuf * gzfilebuf::setbuf ( char_type p,
std::streamsize  n 
)
protectedvirtual

Installs external stream buffer.

Parameters
pPointer to char buffer.
nSize of external buffer.
Returns
this on success, NULL on failure.

Call setbuf(0,0) to enable unbuffered output.

Definition at line 266 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ setbuf() [2/2]

virtual std::streambuf* gzfilebuf::setbuf ( char_type p,
std::streamsize  n 
)
protectedvirtual

Installs external stream buffer.

Parameters
pPointer to char buffer.
nSize of external buffer.
Returns
this on success, NULL on failure.

Call setbuf(0,0) to enable unbuffered output.

◆ setcompression() [1/2]

int gzfilebuf::setcompression ( int  comp_level,
int  comp_strategy = Z_DEFAULT_STRATEGY 
)

Set compression level and strategy on the fly.

Parameters
comp_levelCompression level (see zlib.h for allowed values)
comp_strategyCompression strategy (see zlib.h for allowed values)
Returns
Z_OK on success, Z_STREAM_ERROR otherwise.

Unfortunately, these parameters cannot be modified separately, as the previous zfstream version assumed. Since the strategy is seldom changed, it can default and setcompression(level) then becomes like the old setcompressionlevel(level).

◆ setcompression() [2/2]

int gzfilebuf::setcompression ( int  comp_level,
int  comp_strategy = Z_DEFAULT_STRATEGY 
)

Set compression level and strategy on the fly.

Parameters
comp_levelCompression level (see zlib.h for allowed values)
comp_strategyCompression strategy (see zlib.h for allowed values)
Returns
Z_OK on success, Z_STREAM_ERROR otherwise.

Unfortunately, these parameters cannot be modified separately, as the previous zfstream version assumed. Since the strategy is seldom changed, it can default and setcompression(level) then becomes like the old setcompressionlevel(level).

Definition at line 43 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ setcompressionlevel() [1/2]

int gzfilebuf::setcompressionlevel ( int  comp_level)

◆ setcompressionlevel() [2/2]

int gzfilebuf::setcompressionlevel ( int  comp_level)

◆ setcompressionstrategy() [1/2]

int gzfilebuf::setcompressionstrategy ( int  comp_strategy)

◆ setcompressionstrategy() [2/2]

int gzfilebuf::setcompressionstrategy ( int  comp_strategy)

◆ showmanyc() [1/2]

virtual std::streamsize gzfilebuf::showmanyc ( )
protectedvirtual

Number of characters available in stream buffer.

Returns
Number of characters.

This indicates number of characters in get area of stream buffer. These characters can be read without accessing the gzipped file.

◆ showmanyc() [2/2]

std::streamsize gzfilebuf::showmanyc ( )
protectedvirtual

Number of characters available in stream buffer.

Returns
Number of characters.

This indicates number of characters in get area of stream buffer. These characters can be read without accessing the gzipped file.

Definition at line 169 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.cc.

◆ sync() [1/4]

virtual int gzfilebuf::sync ( )
virtual

◆ sync() [2/4]

int gzfilebuf::sync ( )
virtual

◆ sync() [3/4]

virtual int gzfilebuf::sync ( )
protectedvirtual

Flush stream buffer to file.

Returns
0 on success, -1 on error.

This calls underflow(EOF) to do the job.

◆ sync() [4/4]

virtual int gzfilebuf::sync ( )
protectedvirtual

Flush stream buffer to file.

Returns
0 on success, -1 on error.

This calls underflow(EOF) to do the job.

◆ underflow() [1/4]

virtual int gzfilebuf::underflow ( )
protectedvirtual

◆ underflow() [2/4]

gzfilebuf::int_type gzfilebuf::underflow ( )
protectedvirtual

◆ underflow() [3/4]

virtual int_type gzfilebuf::underflow ( )
protectedvirtual

Fill get area from gzipped file.

Returns
First character in get area on success, EOF on error.

This actually reads characters from gzipped file to stream buffer. Always buffered.

◆ underflow() [4/4]

virtual int_type gzfilebuf::underflow ( )
protectedvirtual

Fill get area from gzipped file.

Returns
First character in get area on success, EOF on error.

This actually reads characters from gzipped file to stream buffer. Always buffered.

Member Data Documentation

◆ buffer

char_type * gzfilebuf::buffer
private

Stream buffer.

For simplicity this remains allocated on the free store for the entire life span of the gzfilebuf object, unless replaced by setbuf.

Definition at line 207 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ buffer_size

std::streamsize gzfilebuf::buffer_size
private

Stream buffer size.

Defaults to system default buffer size (typically 8192 bytes). Modified by setbuf.

Definition at line 215 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ file

gzFile gzfilebuf::file
private

Underlying file pointer.

Definition at line 35 of file bloaty/third_party/zlib/contrib/iostream/zfstream.h.

◆ io_mode

std::ios_base::openmode gzfilebuf::io_mode
private

Mode in which file was opened.

Definition at line 191 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ mode

short gzfilebuf::mode
private

◆ own_buffer

bool gzfilebuf::own_buffer
private

True if this object owns stream buffer.

This makes the class responsible for deleting the buffer upon destruction.

Definition at line 223 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ own_fd

bool gzfilebuf::own_fd
private

True if this object owns file descriptor.

This makes the class responsible for closing the file upon destruction.

Definition at line 199 of file bloaty/third_party/zlib/contrib/iostream3/zfstream.h.

◆ own_file_descriptor

short gzfilebuf::own_file_descriptor
private

The documentation for this class was generated from the following files:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:46