Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

regina::ZBuffer Class Reference
[General Utility Classes]

A common base class for compression/decompression stream buffers. More...

#include <zstream.h>

Inheritance diagram for regina::ZBuffer:

regina::CompressionBuffer regina::DecompressionBuffer List of all members.

Public Member Functions

virtual ~ZBuffer ()
 Destroys this stream buffer.

virtual int overflow (int c)
 Writes the given character to the underlying file, compressing en route.

virtual int underflow ()
 Reads the next character from the underlying file, decompressing en route.

virtual int uflow ()
 Reads the next character from the underlying file, decompressing en route.

virtual std::streamsize xsputn (const char *s, std::streamsize n)
 Writes the given set of characters to the underlying file, compressing en route.

virtual std::streamsize xsgetn (char *s, std::streamsize n)
 Reads a set of characters from the underlying file, decompressing en route.

virtual int pbackfail (int c)
 Pushes the given character back into the underlying input stream.

virtual int sync ()
 Flushes all input/output buffers.

int close ()
 Closes the underlying file.

void showError (std::ostream &out)
 Writes a description of the last (de)compression error that occurred.


Static Public Attributes

const int zEOF
 The end-of-file marker used with this stream buffer.


Protected Member Functions

 ZBuffer ()
 Creates a new stream buffer.

int open (const char *path, const char *mode)
 Opens the given file for (de)compressed reading or writing.


Detailed Description

A common base class for compression/decompression stream buffers.

This class should not be instantiated directly; see classes CompressionBuffer and DecompressionBuffer instead.

The standard zlib compression library is used for compression and decompression.

Python:
Not present.


Constructor & Destructor Documentation

regina::ZBuffer::ZBuffer  )  [inline, protected]
 

Creates a new stream buffer.

regina::ZBuffer::~ZBuffer  )  [inline, virtual]
 

Destroys this stream buffer.

Any underlying file that is open will be closed.


Member Function Documentation

int regina::ZBuffer::close  ) 
 

Closes the underlying file.

If no file is open, this routine does nothing.

Returns:
0 on success, or zEOF on error.

int regina::ZBuffer::open const char *  path,
const char *  mode
[protected]
 

Opens the given file for (de)compressed reading or writing.

If a file is already open, it will be closed before the new file is opened.

Parameters:
path the pathname of the new file to open.
mode the mode in which to open the file; this must be "rb" for reading or "wb" for writing.
Returns:
0 on success, or zEOF on error.

int regina::ZBuffer::overflow int  c  )  [inline, virtual]
 

Writes the given character to the underlying file, compressing en route.

Parameters:
c the uncompressed character to write.
Returns:
the given character on success, or zEOF on error.

int regina::ZBuffer::pbackfail int  c  )  [inline, virtual]
 

Pushes the given character back into the underlying input stream.

Warning:
This routine will only succeed if the next character in the underlying input stream has not already been read.
Parameters:
c the character to push back.
Returns:
the character that was pushed back, or zEOF if an error occurred.

void regina::ZBuffer::showError std::ostream &  out  ) 
 

Writes a description of the last (de)compression error that occurred.

For the message to be meaningful, the underlying file must still be open.

Parameters:
out the output stream to which the error description should be written.

int regina::ZBuffer::sync  )  [inline, virtual]
 

Flushes all input/output buffers.

Returns:
0 on success, or zEOF on error.

int regina::ZBuffer::uflow  )  [inline, virtual]
 

Reads the next character from the underlying file, decompressing en route.

The character is consumed.

Returns:
the next uncompressed character, or zEOF if there is an error or there are no more characters.

int regina::ZBuffer::underflow  )  [inline, virtual]
 

Reads the next character from the underlying file, decompressing en route.

The character is not consumed.

Returns:
the next uncompressed character, or zEOF if there is an error or there are no more characters.

virtual std::streamsize regina::ZBuffer::xsgetn char *  s,
std::streamsize  n
[virtual]
 

Reads a set of characters from the underlying file, decompressing en route.

The characters are all consumed. Reading will stop if end-of-file is reached or an error occurs.

Parameters:
s the array into which the uncompressed characters should be placed.
n the number of uncompressed characters to read.
Returns:
the number of uncompressed characters that were actually read, or zEOF if an error occurred.

std::streamsize regina::ZBuffer::xsputn const char *  s,
std::streamsize  n
[inline, virtual]
 

Writes the given set of characters to the underlying file, compressing en route.

Parameters:
s the uncompressed array of characters to write.
n the number of characters to write.
Returns:
the number of uncompressed characters that were actually written, or 0 if an error occurred.


Member Data Documentation

const int regina::ZBuffer::zEOF [static]
 

The end-of-file marker used with this stream buffer.


The documentation for this class was generated from the following file:
Copyright © 1999-2004, Ben Burton
This software is released under the GNU General Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).