Visualization Library v1.0.3

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

VL     Star     Watch     Fork     Issue

[Download] [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:
vl::VirtualFile vl::Object

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< VirtualFileclone () const
 Returns an equivalent GZipCodec.
GZipCodecoperator= (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 VirtualFilestream () const
 Returns the VirtualFile representing the GZip file to be read or to be written.
VirtualFilestream ()
 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< VirtualFilemStream
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 )
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]
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:
levelValues 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]
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]
bool GZipCodec::fillUncompressedBuffer (  ) [protected]

Member Data Documentation

Definition at line 122 of file GZipCodec.hpp.

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

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

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]

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

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:06.
Permission is granted to use this page to write and publish articles regarding Visualization Library.