Visualization Library 2.1.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The GZipCodec class is a VirtualFile that transparently encodes and decodes a stream of data using the GZip compression algorithm. More...
#include <GZipCodec.hpp>
Public Member Functions | |
GZipCodec (VirtualFile *stream=NULL) | |
Constructor. More... | |
GZipCodec (const String &gz_path) | |
Constructor. More... | |
~GZipCodec () | |
Destructor. More... | |
virtual bool | open (EOpenMode mode) |
Opens a compressed stream. More... | |
virtual bool | isOpen () const |
Returns true if the file is open for read or writing. More... | |
virtual bool | exists () const |
Returns true if the input or output stream file exists. More... | |
virtual void | close () |
Closes the GZipStream. More... | |
virtual long long | size () const |
Returns the uncompressed size of the stream. This is not a thread safe function. More... | |
virtual ref< VirtualFile > | clone () const |
Returns an equivalent GZipCodec. More... | |
GZipCodec & | operator= (const GZipCodec &other) |
void | setCompressionLevel (int level) |
Sets the compression level used during write operations. More... | |
int | compressionLevel () const |
void | setStream (VirtualFile *stream) |
Installs the VirtualFile representing the GZip file to be read or to be written. More... | |
const VirtualFile * | stream () const |
Returns the VirtualFile representing the GZip file to be read or to be written. More... | |
VirtualFile * | stream () |
Returns the VirtualFile representing the GZip file to be read or to be written. More... | |
long long | uncompressedSize () |
Returns the uncompressed size of the stream. More... | |
long long | compressedSize () const |
Returns the size of the compressed stream as returned by stream()->size() . More... | |
float | compressionRatio () const |
Returns the compression ratio computed as compressedsize/uncompressedsize . More... | |
bool | warnOnSeek () const |
void | setWarnOnSeek (bool warn_on) |
Public Member Functions inherited from vl::VirtualFile | |
VirtualFile () | |
Constructor. More... | |
unsigned int | crc32 () |
Computes the crc32 of the entire file. More... | |
MD5CheckSum | md5 () |
Computes the md5 of the entire file. More... | |
VirtualFile & | operator= (const VirtualFile &other) |
const String & | path () const |
Returns the path of the file. More... | |
void | setPath (const String &name) |
Changes the path bound to a VirtualFile. Use carefully this function, you shouldn't rename a VirtualFile managed by a VirtualDirectory. More... | |
long long | peek (void *buffer, long long byte_count) |
Reads byte_count bytes and returns to the original position. More... | |
long long | read (void *buffer, long long byte_count) |
Reads byte_count bytes from a file. Returns the number of bytes actually read. More... | |
long long | write (const void *buffer, long long byte_count) |
Writes byte_count bytes to a file. Returns the number of bytes actually written. More... | |
long long | position () const |
Returns the current position in the file. More... | |
bool | seekSet (long long offset) |
Changes the current read/write position of a file. More... | |
bool | seekCur (long long offset) |
Changes the current read/write position of a file. More... | |
bool | seekEnd (long long offset) |
Changes the current read/write position of a file. More... | |
bool | endOfFile () const |
Returns true if position() >= size() More... | |
long long | load (std::vector< char > &data) |
Loads the entire file in the specified vector. More... | |
long long | load (void *buffer, long long max=-1) |
Loads the entire file in the specified buffer. More... | |
double | readDouble (bool little_endian_data=true) |
Reads single entry. More... | |
float | readFloat (bool little_endian_data=true) |
Reads single entry. More... | |
unsigned long long | readUInt64 (bool little_endian_data=true) |
Reads single entry. More... | |
long long | readSInt64 (bool little_endian_data=true) |
Reads single entry. More... | |
unsigned int | readUInt32 (bool little_endian_data=true) |
Reads single entry. More... | |
int | readSInt32 (bool little_endian_data=true) |
Reads single entry. More... | |
unsigned short | readUInt16 (bool little_endian_data=true) |
Reads single entry. More... | |
short | readSInt16 (bool little_endian_data=true) |
Reads single entry. More... | |
unsigned char | readUInt8 () |
Reads single entry. More... | |
char | readSInt8 () |
Reads single entry. More... | |
long long | readDouble (double *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readFloat (float *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readUInt64 (unsigned long long *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readSInt64 (long long *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readUInt32 (unsigned int *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readSInt32 (int *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readUInt16 (unsigned short *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readSInt16 (short *buffer, long long count, bool little_endian_data=true) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readUInt8 (unsigned char *buffer, long long count) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | readSInt8 (char *buffer, long long count) |
Reads multiple entries. Returns the number of bytes read. More... | |
long long | writeDouble (double data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeFloat (float data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeUInt64 (unsigned long long data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeSInt64 (long long data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeUInt32 (unsigned int data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeSInt32 (int data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeUInt16 (unsigned short data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeSInt16 (short data, bool little_endian_data=true) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeUInt8 (unsigned char data) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeSInt8 (char data) |
Writes a single entry. Returns the number of bytes written. More... | |
long long | writeDouble (const double *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeFloat (const float *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeUInt64 (const unsigned long long *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeSInt64 (const long long *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeUInt32 (const unsigned int *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeSInt32 (const int *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeUInt16 (const unsigned short *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeSInt16 (const short *buffer, long long count, bool little_endian_data=true) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeUInt8 (const unsigned char *buffer, long long count) |
Writes multiple entries. Returns the number of bytes written. More... | |
long long | writeSInt8 (const char *buffer, long long count) |
Writes multiple entries. Returns the number of bytes written. More... | |
Public Member Functions inherited from vl::Object | |
Object () | |
Constructor. More... | |
Object (const Object &other) | |
Copy constructor: copies the name, ref count mutex and user data. More... | |
Object & | operator= (const Object &other) |
Copy operator: copies the object's name, ref count mutex and user data. More... | |
const std::string & | objectName () const |
The name of the object, by default set to the object's class name. More... | |
void | setObjectName (const char *name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setObjectName (const std::string &name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setRefCountMutex (IMutex *mutex) |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () const |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
int | referenceCount () const |
Returns the number of references of an object. More... | |
void | incReference () const |
Increments the reference count of an object. More... | |
void | decReference () |
Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More... | |
void | setAutomaticDelete (bool autodel_on) |
If set to true the Object is deleted when its reference count reaches 0. More... | |
bool | automaticDelete () const |
If set to true the Object is deleted when its reference count reaches 0. More... | |
template<class T > | |
T * | as () |
Casts an Object to the specified class. More... | |
template<class T > | |
const T * | as () const |
Casts an Object to the specified class. More... | |
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 Member Functions inherited from vl::VirtualFile | |
VirtualFile (const VirtualFile &other) | |
long long | write64 (const void *buffer, long long count, bool little_endian_data=true) |
long long | write32 (const void *buffer, long long count, bool little_endian_data=true) |
long long | write16 (const void *buffer, long long count, bool little_endian_data=true) |
long long | read64 (void *buffer, long long count, bool little_endian_data=true) |
long long | read32 (void *buffer, long long count, bool little_endian_data=true) |
long long | read16 (void *buffer, long long count, bool little_endian_data=true) |
long long | write64 (const void *buffer, bool little_endian_data=true) |
long long | write32 (const void *buffer, bool little_endian_data=true) |
long long | write16 (const void *buffer, bool little_endian_data=true) |
long long | read64 (void *buffer, bool little_endian_data=true) |
long long | read32 (void *buffer, bool little_endian_data=true) |
long long | read16 (void *buffer, bool little_endian_data=true) |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
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 |
Protected Attributes inherited from vl::VirtualFile | |
String | mPath |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
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.
|
protected |
Enumerator | |
---|---|
ZNone | |
ZCompress | |
ZDecompress |
Definition at line 135 of file GZipCodec.hpp.
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.
|
virtual |
Returns an equivalent GZipCodec.
Implements vl::VirtualFile.
Definition at line 178 of file GZipCodec.cpp.
References GZipCodec().
|
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().
|
inline |
Returns the size of the compressed stream as returned by stream()->size()
.
Definition at line 104 of file GZipCodec.hpp.
References vl::VirtualFile::size().
Referenced by compressionRatio().
|
inline |
Definition at line 86 of file GZipCodec.hpp.
Referenced by open().
float GZipCodec::compressionRatio | ( | ) | const |
Returns the compression ratio computed as compressedsize/uncompressedsize
.
Definition at line 385 of file GZipCodec.cpp.
References compressedSize(), and size().
|
inlinevirtual |
Returns true if the input or output stream file exists.
Implements vl::VirtualFile.
Definition at line 69 of file GZipCodec.hpp.
|
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().
|
inlinevirtual |
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 |
Opens a compressed stream.
mode
== OM_ReadOnly
the stream will be decompressed during read operations.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().
Definition at line 185 of file GZipCodec.cpp.
References close(), mCompressionLevel, and mStream.
|
protectedvirtual |
|
protectedvirtual |
Implements vl::VirtualFile.
Definition at line 195 of file GZipCodec.cpp.
References vl::Log::error(), fillUncompressedBuffer(), isOpen(), mReadBytes, mUncompressedBuffer, mUncompressedBufferPtr, and VL_CHECK.
|
protected |
Definition at line 265 of file GZipCodec.cpp.
References close(), vl::OM_ReadOnly, and open().
Referenced by seekSet_Implementation().
|
protectedvirtual |
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.
|
inline |
Sets the compression level used during write operations.
level | Values can be between 0 (faster compression) to 9 (slower but better compression). |
Definition at line 84 of file GZipCodec.hpp.
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 vl::LoadWriterManager::loadResource(), and open().
|
inline |
Definition at line 111 of file GZipCodec.hpp.
|
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().
|
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().
|
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.
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().
|
inline |
Definition at line 109 of file GZipCodec.hpp.
Referenced by seekSet_Implementation().
|
protectedvirtual |
Implements vl::VirtualFile.
Definition at line 233 of file GZipCodec.cpp.
References vl::Log::error(), mWrittenBytes, mZStream, stream(), and vl::VirtualFile::write().
|
protected |
Definition at line 122 of file GZipCodec.hpp.
Referenced by GZipCodec(), and operator=().
enum { ... } vl::GZipCodec::mMode |
Referenced by close(), open(), seekSet_Implementation(), size(), and uncompressedSize().
|
protected |
Definition at line 124 of file GZipCodec.hpp.
Referenced by close(), GZipCodec(), open(), position_Implementation(), and read_Implementation().
|
protected |
Definition at line 123 of file GZipCodec.hpp.
Referenced by operator=(), and setStream().
|
protected |
Definition at line 133 of file GZipCodec.hpp.
Referenced by fillUncompressedBuffer(), and open().
|
protected |
Definition at line 131 of file GZipCodec.hpp.
Referenced by close(), fillUncompressedBuffer(), open(), and read_Implementation().
|
protected |
Definition at line 132 of file GZipCodec.hpp.
Referenced by close(), fillUncompressedBuffer(), open(), and read_Implementation().
|
protected |
Definition at line 134 of file GZipCodec.hpp.
Referenced by GZipCodec(), setStream(), uncompressedSize(), and ~GZipCodec().
|
protected |
Definition at line 126 of file GZipCodec.hpp.
Referenced by GZipCodec().
|
protected |
Definition at line 125 of file GZipCodec.hpp.
Referenced by close(), GZipCodec(), open(), setStream(), size(), write_Implementation(), and ~GZipCodec().
|
protected |
Definition at line 129 of file GZipCodec.hpp.
Referenced by fillUncompressedBuffer().
|
protected |
Definition at line 130 of file GZipCodec.hpp.
Referenced by fillUncompressedBuffer().
|
protected |
Definition at line 128 of file GZipCodec.hpp.
Referenced by close(), fillUncompressedBuffer(), GZipCodec(), open(), write_Implementation(), and ~GZipCodec().
Visualization Library 2.1.0 Reference Documentation
Updated on Wed Mar 10 2021 16:02:50.
© Copyright Michele Bosi. All rights reserved.