Mercurial > vba-linux
view src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line source
1 // LzOutWindow.h3 #ifndef __LZ_OUT_WINDOW_H4 #define __LZ_OUT_WINDOW_H6 #include "../IStream.h"8 #include "../Common/OutBuffer.h"10 #ifndef _NO_EXCEPTIONS11 typedef COutBufferException CLzOutWindowException;12 #endif14 class CLzOutWindow: public COutBuffer15 {16 public:17 void Init(bool solid = false);19 // distance >= 0, len > 0,20 bool CopyBlock(UInt32 distance, UInt32 len)21 {22 UInt32 pos = _pos - distance - 1;23 if (distance >= _pos)24 {25 if (!_overDict || distance >= _bufferSize)26 return false;27 pos += _bufferSize;28 }29 if (_limitPos - _pos > len && _bufferSize - pos > len)30 {31 const Byte *src = _buffer + pos;32 Byte *dest = _buffer + _pos;33 _pos += len;34 do35 *dest++ = *src++;36 while(--len != 0);37 }38 else do39 {40 if (pos == _bufferSize)41 pos = 0;42 _buffer[_pos++] = _buffer[pos++];43 if (_pos == _limitPos)44 FlushWithCheck();45 }46 while(--len != 0);47 return true;48 }50 void PutByte(Byte b)51 {52 _buffer[_pos++] = b;53 if (_pos == _limitPos)54 FlushWithCheck();55 }57 Byte GetByte(UInt32 distance) const58 {59 UInt32 pos = _pos - distance - 1;60 if (pos >= _bufferSize)61 pos += _bufferSize;62 return _buffer[pos];63 }64 };66 #endif