1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/7zip/Compress/LZ/LZOutWindow.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 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 +#include "../../Common/OutBuffer.h" 1.11 + 1.12 +#ifndef _NO_EXCEPTIONS 1.13 +typedef COutBufferException CLZOutWindowException; 1.14 +#endif 1.15 + 1.16 +class CLZOutWindow: public COutBuffer 1.17 +{ 1.18 +public: 1.19 + void Init(bool solid = false); 1.20 + 1.21 + // distance >= 0, len > 0, 1.22 + bool CopyBlock(UInt32 distance, UInt32 len) 1.23 + { 1.24 + UInt32 pos = _pos - distance - 1; 1.25 + if (distance >= _pos) 1.26 + { 1.27 + if (!_overDict || distance >= _bufferSize) 1.28 + return false; 1.29 + pos += _bufferSize; 1.30 + } 1.31 + do 1.32 + { 1.33 + if (pos == _bufferSize) 1.34 + pos = 0; 1.35 + _buffer[_pos++] = _buffer[pos++]; 1.36 + if (_pos == _limitPos) 1.37 + FlushWithCheck(); 1.38 + } 1.39 + while(--len != 0); 1.40 + return true; 1.41 + } 1.42 + 1.43 + void PutByte(Byte b) 1.44 + { 1.45 + _buffer[_pos++] = b; 1.46 + if (_pos == _limitPos) 1.47 + FlushWithCheck(); 1.48 + } 1.49 + 1.50 + Byte GetByte(UInt32 distance) const 1.51 + { 1.52 + UInt32 pos = _pos - distance - 1; 1.53 + if (pos >= _bufferSize) 1.54 + pos += _bufferSize; 1.55 + return _buffer[pos]; 1.56 + } 1.57 +}; 1.58 + 1.59 +#endif