# Visualization Library

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

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

# 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 const char * | className ()
| Returns the name of the class.
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
unsigned int | mUncompressedSize
enum vl::GZipCodec:: { ... } | mMode

## Static Protected Attributes

static const int | CHUNK_SIZE = 128*1024

## Detailed Description

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

## Member Enumeration Documentation

anonymous enum`[protected]`

Enumerator:

  ZNone |
  ZCompress |
  ZDecompress |

## Constructor & Destructor Documentation

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

Constructor.

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

Constructor.

GZipCodec::~GZipCodec | ( |  | ) |

Destructor.

## Member Function Documentation

virtual const char* vl::GZipCodec::className | ( |  | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::VirtualFile.

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.

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

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

Implements vl::VirtualFile.

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

Returns true if the input or output stream file exists.

Implements vl::VirtualFile.

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

Closes the GZipStream.

Implements vl::VirtualFile.

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

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

Implements vl::VirtualFile.

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

Returns an equivalent GZipCodec.

Implements vl::VirtualFile.

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

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).

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

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

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

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

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

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

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

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.

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

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

float GZipCodec::compressionRatio | ( |  | ) | const

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

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

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

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

Implements vl::VirtualFile.

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

Implements vl::VirtualFile.

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

Implements vl::VirtualFile.

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

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

Implements vl::VirtualFile.

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

## Member Data Documentation

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

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

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

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

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

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

const int vl::GZipCodec::CHUNK_SIZE = 128*1024`[static, protected]`

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

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

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

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

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

unsigned int vl::GZipCodec::mUncompressedSize`[protected]`

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

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

- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/GZipCodec.hpp
- E:/VisualizationLibrary/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vl/GZipCodec.cpp

Visualization Library v2009.07 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Mon Aug 10 21:41:36 2009.
Permission is granted to use this page to write and publish articles regarding Visualization Library.