Mercurial > vba-linux
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Compress/LzOutWindow.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,66 @@ 1.4 +// LzOutWindow.h 1.5 + 1.6 +#ifndef __LZ_OUT_WINDOW_H 1.7 +#define __LZ_OUT_WINDOW_H 1.8 + 1.9 +#include "../IStream.h" 1.10 + 1.11 +#include "../Common/OutBuffer.h" 1.12 + 1.13 +#ifndef _NO_EXCEPTIONS 1.14 +typedef COutBufferException CLzOutWindowException; 1.15 +#endif 1.16 + 1.17 +class CLzOutWindow: public COutBuffer 1.18 +{ 1.19 +public: 1.20 + void Init(bool solid = false); 1.21 + 1.22 + // distance >= 0, len > 0, 1.23 + bool CopyBlock(UInt32 distance, UInt32 len) 1.24 + { 1.25 + UInt32 pos = _pos - distance - 1; 1.26 + if (distance >= _pos) 1.27 + { 1.28 + if (!_overDict || distance >= _bufferSize) 1.29 + return false; 1.30 + pos += _bufferSize; 1.31 + } 1.32 + if (_limitPos - _pos > len && _bufferSize - pos > len) 1.33 + { 1.34 + const Byte *src = _buffer + pos; 1.35 + Byte *dest = _buffer + _pos; 1.36 + _pos += len; 1.37 + do 1.38 + *dest++ = *src++; 1.39 + while(--len != 0); 1.40 + } 1.41 + else do 1.42 + { 1.43 + if (pos == _bufferSize) 1.44 + pos = 0; 1.45 + _buffer[_pos++] = _buffer[pos++]; 1.46 + if (_pos == _limitPos) 1.47 + FlushWithCheck(); 1.48 + } 1.49 + while(--len != 0); 1.50 + return true; 1.51 + } 1.52 + 1.53 + void PutByte(Byte b) 1.54 + { 1.55 + _buffer[_pos++] = b; 1.56 + if (_pos == _limitPos) 1.57 + FlushWithCheck(); 1.58 + } 1.59 + 1.60 + Byte GetByte(UInt32 distance) const 1.61 + { 1.62 + UInt32 pos = _pos - distance - 1; 1.63 + if (pos >= _bufferSize) 1.64 + pos += _bufferSize; 1.65 + return _buffer[pos]; 1.66 + } 1.67 +}; 1.68 + 1.69 +#endif