ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::GZipReadStream Class Reference

A simple wrapper class which can be used to wrap around an arbitrary other SeekableReadStream and will then provide on-the-fly decompression support. More...

Inheritance diagram for Common::GZipReadStream:
Collaboration diagram for Common::GZipReadStream:

List of all members.

Public Member Functions

 GZipReadStream (SeekableReadStream *w, uint32 knownSize=0)
 ~GZipReadStream ()
bool err () const
 Returns true if an I/O failure occurred.
void clearErr ()
 Reset the I/O error status as returned by err().
uint32 read (void *dataPtr, uint32 dataSize)
 Read data from the stream.
bool eos () const
 Returns true if a read failed because the stream end has been reached.
int32 pos () const
 Obtains the current value of the stream position indicator of the stream.
int32 size () const
 Obtains the total size of the stream, measured in bytes.
bool seek (int32 offset, int whence=SEEK_SET)
 Sets the stream position indicator for the stream.

Protected Types

enum  { BUFSIZE = 16384 }

Protected Attributes

byte _buf [BUFSIZE]
ScopedPtr< SeekableReadStream_wrapped
z_stream _stream
int _zlibErr
uint32 _pos
uint32 _origSize
bool _eos

Detailed Description

A simple wrapper class which can be used to wrap around an arbitrary other SeekableReadStream and will then provide on-the-fly decompression support.

Assumes the compressed data to be in gzip format.

Definition at line 153 of file zlib.cpp.


Member Enumeration Documentation

anonymous enum [protected]
Enumerator:
BUFSIZE 

Definition at line 155 of file zlib.cpp.


Constructor & Destructor Documentation

Common::GZipReadStream::GZipReadStream ( SeekableReadStream w,
uint32  knownSize = 0 
) [inline]

Definition at line 170 of file zlib.cpp.

Common::GZipReadStream::~GZipReadStream (  )  [inline]

Definition at line 206 of file zlib.cpp.


Member Function Documentation

void Common::GZipReadStream::clearErr (  )  [inline, virtual]

Reset the I/O error status as returned by err().

For a ReadStream, also reset the end-of-stream status returned by eos().

Note:
The semantics of any implementation of this method are supposed to match those of ISO C clearerr().

Reimplemented from Common::Stream.

Definition at line 211 of file zlib.cpp.

bool Common::GZipReadStream::eos (  )  const [inline, virtual]

Returns true if a read failed because the stream end has been reached.

This flag is cleared by clearErr(). For a SeekableReadStream, it is also cleared by a successful seek.

Note:
The semantics of any implementation of this method are supposed to match those of ISO C feof(). In particular, in a stream with N bytes, reading exactly N bytes from the start should *not* set eos; only reading *beyond* the available data should set it.

Implements Common::ReadStream.

Definition at line 239 of file zlib.cpp.

bool Common::GZipReadStream::err (  )  const [inline, virtual]

Returns true if an I/O failure occurred.

This flag is never cleared automatically. In order to clear it, client code has to call clearErr() explicitly.

Note:
The semantics of any implementation of this method are supposed to match those of ISO C ferror().

Reimplemented from Common::Stream.

Definition at line 210 of file zlib.cpp.

int32 Common::GZipReadStream::pos (  )  const [inline, virtual]

Obtains the current value of the stream position indicator of the stream.

Returns:
the current position indicator, or -1 if an error occurred.

Implements Common::SeekableReadStream.

Definition at line 242 of file zlib.cpp.

uint32 Common::GZipReadStream::read ( void *  dataPtr,
uint32  dataSize 
) [inline, virtual]

Read data from the stream.

Subclasses must implement this method; all other read methods are implemented using it.

Note:
The semantics of any implementation of this method are supposed to match those of ISO C fread(), in particular where it concerns setting error and end of file/stream flags.
Parameters:
dataPtr pointer to a buffer into which the data is read
dataSize number of bytes to be read
Returns:
the number of bytes which were actually read.

Implements Common::ReadStream.

Definition at line 216 of file zlib.cpp.

bool Common::GZipReadStream::seek ( int32  offset,
int  whence = SEEK_SET 
) [inline, virtual]

Sets the stream position indicator for the stream.

The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to SEEK_SET, SEEK_CUR, or SEEK_END, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the seek() method clears the end-of-file indicator for the stream.

Note:
The semantics of any implementation of this method are supposed to match those of ISO C fseek().
Parameters:
offset the relative offset in bytes
whence the seek reference: SEEK_SET, SEEK_CUR, or SEEK_END
Returns:
true on success, false in case of a failure

Implements Common::SeekableReadStream.

Definition at line 248 of file zlib.cpp.

int32 Common::GZipReadStream::size (  )  const [inline, virtual]

Obtains the total size of the stream, measured in bytes.

If this value is unknown or can not be computed, -1 is returned.

Returns:
the size of the stream, or -1 if an error occurred

Implements Common::SeekableReadStream.

Definition at line 245 of file zlib.cpp.


Member Data Documentation

byte Common::GZipReadStream::_buf[BUFSIZE] [protected]

Definition at line 159 of file zlib.cpp.

bool Common::GZipReadStream::_eos [protected]

Definition at line 166 of file zlib.cpp.

Definition at line 165 of file zlib.cpp.

Definition at line 164 of file zlib.cpp.

z_stream Common::GZipReadStream::_stream [protected]

Definition at line 162 of file zlib.cpp.

Definition at line 161 of file zlib.cpp.

Definition at line 163 of file zlib.cpp.


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


Generated on Sat Nov 16 2019 05:02:54 for ResidualVM by doxygen 1.7.1
curved edge   curved edge