Octane v1.01.20 - The Open Compression Toolkit for C++ http://octane.sourceforge.net/
Homepage | Main | Modules | Class Hierarchy | Compound List | File List | Compound Members | Related Pages

zleCompressor Class Reference
[Compressors]

#include <zle.hpp>

Inheritance diagram for zleCompressor:

OctaneCompressor OctaneClass List of all members.

Detailed Description

This is a zero-length-encoder, it performs run-length-encoding for 0 bytes only.

Any contiguous string of 0 bytes up to 255 characters long will be replaced by a 0 byte followed by counter signifying the length of the string of 0s.

Definition at line 22 of file zle.hpp.

Public Member Functions

 zleCompressor (bool registerme=false)
virtual std::string GetClassName ()
 Get the assigned name of an instantiated compressor.

virtual std::string GetDescription ()
 optionally provide a longer (maybe 20-60 characters) description

virtual OctaneCompressorMakeCompressorInstantiation ()
 Instantiate a compressor from this class (like a factory).


Protected Member Functions

virtual bool DoProtectedCompress (bitreader &s, bitwriter &d)
 This is the member function which does the actual compression, and this is the function that should be subclasses by derived classes.

virtual bool DoProtectedDecompress (bitreader &s, bitwriter &d)
 This is the member function which does the actual decompression, and this is the function that should be subclasses by derived classes.


Member Function Documentation

virtual std::string zleCompressor::GetDescription  )  [inline, virtual]
 

optionally provide a longer (maybe 20-60 characters) description

Returns:
a one line description

Reimplemented from OctaneCompressor.

Definition at line 29 of file zle.hpp.

00029 {return "Zero length encoding";}

bool zleCompressor::DoProtectedCompress bitreader s,
bitwriter d
[protected, virtual]
 

This is the member function which does the actual compression, and this is the function that should be subclasses by derived classes.

It is wrapped by the public API call Compress() which performs some measurements on compression speed and streamsize.

Note:
this function should never be called by an outside class - the API interface should be called instead.
Returns:
true on success

Implements OctaneCompressor.

Definition at line 25 of file zle.cpp.

References bitreader::empty(), bitreader::get_byte(), bitwriter::put_byte(), and bitreader::seek_byte().

00026 {
00027         while (!s.empty())
00028         {
00029                 unsigned char b = s.get_byte();
00030                 unsigned char c;
00031                 d.put_byte(b);
00032 
00033                 if (!b)
00034                 {
00035                         for (c= 0; c < 255; c++)
00036                         {
00037                                 if (s.empty()) break;
00038                                 if (s.get_byte())
00039                                 {
00040                                         s.seek_byte(-1, ios::cur);
00041                                         break;
00042                                 }
00043                         }
00044                         d.put_byte(c);
00045                 }
00046         }
00047         return true;
00048 }

bool zleCompressor::DoProtectedDecompress bitreader s,
bitwriter d
[protected, virtual]
 

This is the member function which does the actual decompression, and this is the function that should be subclasses by derived classes.

It is wrapped by the public API call Decompress() which performs some measurements on decompression speed and streamsize.

Note:
this function should never be called by an outside class - the API interface should be called instead.
Returns:
true on success

Implements OctaneCompressor.

Definition at line 50 of file zle.cpp.

References bitreader::empty(), bitreader::get_byte(), and bitwriter::put_byte().

00051 {
00052         while (!s.empty())
00053         {
00054                 unsigned char b = s.get_byte();
00055                 d.put_byte(b);
00056 
00057                 if (!b)
00058                 {
00059                         for (unsigned char c = s.get_byte(); c; c--) d.put_byte(0);
00060                 }
00061         }
00062         return true;
00063 }


The documentation for this class was generated from the following files:  
Generated on 20 May 2004 by doxygen 1.3.3