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

compressors/compressor_zle/zle.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 #include "zle.hpp"
00013 
00014 #include <iomanip>
00015 using namespace std;
00016 
00017 zleCompressor GloballyInstantiated_zle(true);
00018 
00019 zleCompressor::zleCompressor(bool registerme)
00020         :OctaneCompressor(registerme)
00021 {
00022         if (registerme)CompressorManager_SingletonInsurer managerinsurance(this);
00023 }
00024 
00025 bool zleCompressor::DoProtectedCompress(bitreader &s, bitwriter &d)
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 }
00049 
00050 bool zleCompressor::DoProtectedDecompress(bitreader &s, bitwriter &d)
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 }
 
Generated on 20 May 2004 by doxygen 1.3.3