# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

# vl::GZipCodec Class Reference

The GZipCodec class is a VirtualFile that transparently encodes and decodes a stream of data using the GZip compression algorithm. More...

`#include <GZipCodec.hpp>`

Inheritance diagram for vl::GZipCodec:

List of all members.

## Public Member Functions

| GZipCodec (VirtualFile *stream=NULL)
| Constructor.
| GZipCodec (const String &gz_path)
| Constructor.
| ~GZipCodec ()
| Destructor.
virtual bool | open (EOpenMode mode)
| Opens a compressed stream.
virtual bool | isOpen () const
| Returns true if the file is open for read or writing.
virtual bool | exists () const
| Returns true if the input or output stream file exists.
virtual void | close ()
| Closes the GZipStream.
virtual long long | size () const
| Returns the uncompressed size of the stream. This is not a thread safe function.
virtual ref< VirtualFile > | clone () const
| Returns an equivalent GZipCodec.
GZipCodec & | operator= (const GZipCodec &other)
void | setCompressionLevel (int level)
| Sets the compression level used during write operations.
int | compressionLevel () const
void | setStream (VirtualFile *stream)
| Installs the VirtualFile representing the GZip file to be read or to be written.
const VirtualFile * | stream () const
| Returns the VirtualFile representing the GZip file to be read or to be written.
VirtualFile * | stream ()
| Returns the VirtualFile representing the GZip file to be read or to be written.
long long | uncompressedSize ()
| Returns the uncompressed size of the stream.
long long | compressedSize () const
| Returns the size of the compressed stream as returned by `stream()->size()`.
float | compressionRatio () const
| Returns the compression ratio computed as `compressedsize/uncompressedsize`.
bool | warnOnSeek () const
void | setWarnOnSeek (bool warn_on)

## Protected Types

enum | { ZNone, ZCompress, ZDecompress }

## Protected Member Functions

virtual long long | read_Implementation (void *buffer, long long bytes_to_read)
virtual long long | write_Implementation (const void *buffer, long long byte_count)
virtual long long | position_Implementation () const
void | resetStream ()
bool | seekSet_Implementation (long long pos)
bool | fillUncompressedBuffer ()

## Protected Attributes

int | mCompressionLevel
ref< VirtualFile > | mStream
long long | mReadBytes
long long | mWrittenBytes
bool | mWarnOnSeek
z_stream_s * | mZStream
unsigned char | mZipBufferIn [CHUNK_SIZE]
unsigned char | mZipBufferOut [CHUNK_SIZE]
std::vector< char > | mUncompressedBuffer
int | mUncompressedBufferPtr
long long | mStreamSize
long long | mUncompressedSize
enum vl::GZipCodec:: { ... } | mMode

## Detailed Description

The GZipCodec class is a VirtualFile that transparently encodes and decodes a stream of data using the GZip compression algorithm.

Definition at line 43 of file GZipCodec.hpp.

## Member Enumeration Documentation

anonymous enum`[protected]`

Enumerator:

  ZNone |
  ZCompress |
  ZDecompress |

Definition at line 135 of file GZipCodec.hpp.

## Constructor & Destructor Documentation

GZipCodec::GZipCodec | ( | VirtualFile * | stream = `NULL` ) |

Constructor.

Definition at line 43 of file GZipCodec.cpp.

References mCompressionLevel, mReadBytes, mUncompressedSize, mWarnOnSeek, mWrittenBytes, and mZStream.

Referenced by clone().

GZipCodec::GZipCodec | ( | const String & | gz_path ) |

Constructor.

Definition at line 54 of file GZipCodec.cpp.

References mCompressionLevel, mReadBytes, mUncompressedSize, mWarnOnSeek, mWrittenBytes, mZStream, and vl::VirtualFile::setPath().

GZipCodec::~GZipCodec | ( | ) |

Destructor.

Definition at line 66 of file GZipCodec.cpp.

References close(), mUncompressedSize, mWrittenBytes, mZStream, and NULL.

## Member Function Documentation

bool GZipCodec::open | ( | EOpenMode | mode ) | `[virtual]`

Opens a compressed stream.

- If `mode` == `OM_ReadOnly` the stream will be decompressed during read operations.
- If `mode` == `OM_WriteOnly` the stream will be compressed during write operations.

Implements vl::VirtualFile.

Definition at line 74 of file GZipCodec.cpp.

References compressionLevel(), vl::Log::error(), vl::ref< T >::get(), isOpen(), vl::locateFile(), mMode, mReadBytes, mStreamSize, mUncompressedBuffer, mUncompressedBufferPtr, mWrittenBytes, mZStream, vl::OM_ReadOnly, vl::OM_WriteOnly, vl::VirtualFile::path(), setStream(), vl::VirtualFile::size(), stream(), ZCompress, ZDecompress, and ZNone.

Referenced by resetStream().

virtual bool vl::GZipCodec::isOpen | ( | ) | const`[inline, virtual]`

Returns true if the file is open for read or writing.

Implements vl::VirtualFile.

Definition at line 66 of file GZipCodec.hpp.

Referenced by fillUncompressedBuffer(), open(), read_Implementation(), setStream(), and uncompressedSize().

virtual bool vl::GZipCodec::exists | ( | ) | const`[inline, virtual]`

Returns true if the input or output stream file exists.

Implements vl::VirtualFile.

Definition at line 69 of file GZipCodec.hpp.

void GZipCodec::close | ( | ) | `[virtual]`

Closes the GZipStream.

Implements vl::VirtualFile.

Definition at line 134 of file GZipCodec.cpp.

References vl::VirtualFile::close(), vl::Log::error(), mMode, mReadBytes, mUncompressedBuffer, mUncompressedBufferPtr, mWrittenBytes, mZStream, stream(), vl::VirtualFile::write(), ZCompress, ZDecompress, and ZNone.

Referenced by fillUncompressedBuffer(), operator=(), resetStream(), and ~GZipCodec().

long long GZipCodec::size | ( | ) | const`[virtual]`

Returns the uncompressed size of the stream. This is not a thread safe function.

Implements vl::VirtualFile.

Definition at line 367 of file GZipCodec.cpp.

References mMode, mWrittenBytes, uncompressedSize(), and ZCompress.

Referenced by compressionRatio().

ref< VirtualFile > GZipCodec::clone | ( | ) | const`[virtual]`

Returns an equivalent GZipCodec.

Implements vl::VirtualFile.

Definition at line 178 of file GZipCodec.cpp.

References GZipCodec().

GZipCodec & GZipCodec::operator= | ( | const GZipCodec & | other ) |

Definition at line 185 of file GZipCodec.cpp.

References close(), mCompressionLevel, and mStream.

void vl::GZipCodec::setCompressionLevel | ( | int | level ) | `[inline]`

Sets the compression level used during write operations.

Parameters:

  level | Values can be between 0 (faster compression) to 9 (slower but better compression).

Definition at line 84 of file GZipCodec.hpp.

int vl::GZipCodec::compressionLevel | ( | ) | const`[inline]`

Definition at line 86 of file GZipCodec.hpp.

Referenced by open().

void GZipCodec::setStream | ( | VirtualFile * | stream ) |

Installs the VirtualFile representing the GZip file to be read or to be written.

Definition at line 375 of file GZipCodec.cpp.

References vl::VirtualFile::close(), isOpen(), mStream, mUncompressedSize, mWrittenBytes, vl::VirtualFile::path(), vl::VirtualFile::setPath(), and stream().

Referenced by open().

const VirtualFile* vl::GZipCodec::stream | ( | ) | const`[inline]`

Returns the VirtualFile representing the GZip file to be read or to be written.

Definition at line 92 of file GZipCodec.hpp.

Referenced by close(), fillUncompressedBuffer(), open(), setStream(), uncompressedSize(), and write_Implementation().

VirtualFile* vl::GZipCodec::stream | ( | ) | `[inline]`

Returns the VirtualFile representing the GZip file to be read or to be written.

Definition at line 95 of file GZipCodec.hpp.

long long GZipCodec::uncompressedSize | ( | ) |

Returns the uncompressed size of the stream.

Note:
  This function needs to seek to the end of the GZip stream in order to read the uncompressed file size.

Definition at line 340 of file GZipCodec.cpp.

References vl::VirtualFile::close(), isOpen(), mMode, mUncompressedSize, vl::OM_ReadOnly, vl::VirtualFile::open(), vl::VirtualFile::position(), vl::VirtualFile::readUInt32(), vl::VirtualFile::seekEnd(), vl::VirtualFile::seekSet(), stream(), ZDecompress, and ZNone.

Referenced by size().

long long vl::GZipCodec::compressedSize | ( | ) | const`[inline]`

Returns the size of the compressed stream as returned by `stream()->size()`.

Definition at line 104 of file GZipCodec.hpp.

Referenced by compressionRatio().

float GZipCodec::compressionRatio | ( | ) | const

Returns the compression ratio computed as `compressedsize/uncompressedsize`.

Definition at line 385 of file GZipCodec.cpp.

References compressedSize(), and size().

bool vl::GZipCodec::warnOnSeek | ( | ) | const`[inline]`

Definition at line 109 of file GZipCodec.hpp.

Referenced by seekSet_Implementation().

void vl::GZipCodec::setWarnOnSeek | ( | bool | warn_on ) | `[inline]`

Definition at line 111 of file GZipCodec.hpp.

long long GZipCodec::read_Implementation | ( | void * | buffer,
|  | long long | bytes_to_read
| ) |  | `[protected, virtual]`

Implements vl::VirtualFile.

Definition at line 195 of file GZipCodec.cpp.

References vl::Log::error(), fillUncompressedBuffer(), isOpen(), mReadBytes, mUncompressedBuffer, mUncompressedBufferPtr, and VL_CHECK.

long long GZipCodec::write_Implementation | ( | const void * | buffer,
|  | long long | byte_count
| ) |  | `[protected, virtual]`

Implements vl::VirtualFile.

Definition at line 233 of file GZipCodec.cpp.

References vl::Log::error(), mWrittenBytes, mZStream, stream(), and vl::VirtualFile::write().

long long GZipCodec::position_Implementation | ( | ) | const`[protected, virtual]`

Implements vl::VirtualFile.

Definition at line 260 of file GZipCodec.cpp.

References mReadBytes.

void GZipCodec::resetStream | ( | ) | `[protected]`

Definition at line 265 of file GZipCodec.cpp.

References close(), vl::OM_ReadOnly, and open().

Referenced by seekSet_Implementation().

bool GZipCodec::seekSet_Implementation | ( | long long | pos ) | `[protected, virtual]`

Implements vl::VirtualFile.

Definition at line 271 of file GZipCodec.cpp.

References vl::Log::error(), mMode, vl::VirtualFile::path(), vl::VirtualFile::position(), vl::Log::print(), vl::VirtualFile::read(), resetStream(), warnOnSeek(), and ZDecompress.

bool GZipCodec::fillUncompressedBuffer | ( | ) | `[protected]`

Definition at line 295 of file GZipCodec.cpp.

References close(), vl::Log::error(), isOpen(), mStreamSize, mUncompressedBuffer, mUncompressedBufferPtr, mZipBufferIn, mZipBufferOut, mZStream, vl::VirtualFile::position(), vl::VirtualFile::read(), stream(), and VL_CHECK.

Referenced by read_Implementation().

## Member Data Documentation

int vl::GZipCodec::mCompressionLevel`[protected]`

Definition at line 122 of file GZipCodec.hpp.

Referenced by GZipCodec(), and operator=().

ref<VirtualFile> vl::GZipCodec::mStream`[protected]`

Definition at line 123 of file GZipCodec.hpp.

Referenced by operator=(), and setStream().

long long vl::GZipCodec::mReadBytes`[protected]`

Definition at line 124 of file GZipCodec.hpp.

Referenced by close(), GZipCodec(), open(), position_Implementation(), and read_Implementation().

long long vl::GZipCodec::mWrittenBytes`[protected]`

Definition at line 125 of file GZipCodec.hpp.

Referenced by close(), GZipCodec(), open(), setStream(), size(), write_Implementation(), and ~GZipCodec().

bool vl::GZipCodec::mWarnOnSeek`[protected]`

Definition at line 126 of file GZipCodec.hpp.

Referenced by GZipCodec().

z_stream_s* vl::GZipCodec::mZStream`[protected]`

Definition at line 128 of file GZipCodec.hpp.

Referenced by close(), fillUncompressedBuffer(), GZipCodec(), open(), write_Implementation(), and ~GZipCodec().

unsigned char vl::GZipCodec::mZipBufferIn[CHUNK_SIZE]`[protected]`

Definition at line 129 of file GZipCodec.hpp.

Referenced by fillUncompressedBuffer().

unsigned char vl::GZipCodec::mZipBufferOut[CHUNK_SIZE]`[protected]`

Definition at line 130 of file GZipCodec.hpp.

Referenced by fillUncompressedBuffer().

std::vector<char> vl::GZipCodec::mUncompressedBuffer`[protected]`

Definition at line 131 of file GZipCodec.hpp.

Referenced by close(), fillUncompressedBuffer(), open(), and read_Implementation().

int vl::GZipCodec::mUncompressedBufferPtr`[protected]`

Definition at line 132 of file GZipCodec.hpp.

Referenced by close(), fillUncompressedBuffer(), open(), and read_Implementation().

long long vl::GZipCodec::mStreamSize`[protected]`

Definition at line 133 of file GZipCodec.hpp.

Referenced by fillUncompressedBuffer(), and open().

long long vl::GZipCodec::mUncompressedSize`[protected]`

Definition at line 134 of file GZipCodec.hpp.

Referenced by GZipCodec(), setStream(), uncompressedSize(), and ~GZipCodec().

enum { ... } vl::GZipCodec::mMode`[protected]`

Referenced by close(), open(), seekSet_Implementation(), size(), and uncompressedSize().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/GZipCodec.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlCore/GZipCodec.cpp

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:44:05.
Permission is granted to use this page to write and publish articles regarding Visualization Library.