Annotation of elwix/tools/oldlzma/SRC/7zip/Compress/LZ/LZOutWindow.h, revision 1.1
1.1 ! misho 1: // LZOutWindow.h
! 2:
! 3: #ifndef __LZ_OUT_WINDOW_H
! 4: #define __LZ_OUT_WINDOW_H
! 5:
! 6: #include "../../IStream.h"
! 7:
! 8: #ifndef _NO_EXCEPTIONS
! 9: class CLZOutWindowException
! 10: {
! 11: public:
! 12: HRESULT ErrorCode;
! 13: CLZOutWindowException(HRESULT errorCode): ErrorCode(errorCode) {}
! 14: };
! 15: #endif
! 16:
! 17: class CLZOutWindow
! 18: {
! 19: Byte *_buffer;
! 20: UInt32 _pos;
! 21: UInt32 _windowSize;
! 22: UInt32 _streamPos;
! 23: ISequentialOutStream *_stream;
! 24: void FlushWithCheck();
! 25: public:
! 26: #ifdef _NO_EXCEPTIONS
! 27: HRESULT ErrorCode;
! 28: #endif
! 29:
! 30: void Free();
! 31: CLZOutWindow(): _buffer(0), _stream(0) {}
! 32: ~CLZOutWindow() { Free(); /* ReleaseStream(); */ }
! 33: bool Create(UInt32 windowSize);
! 34:
! 35: void SetStream(ISequentialOutStream *stream);
! 36: void Init(bool solid = false);
! 37: HRESULT Flush();
! 38: void ReleaseStream();
! 39:
! 40: void CopyBlock(UInt32 distance, UInt32 len)
! 41: {
! 42: UInt32 pos = _pos - distance - 1;
! 43: if (pos >= _windowSize)
! 44: pos += _windowSize;
! 45: for(; len > 0; len--)
! 46: {
! 47: if (pos >= _windowSize)
! 48: pos = 0;
! 49: _buffer[_pos++] = _buffer[pos++];
! 50: if (_pos >= _windowSize)
! 51: FlushWithCheck();
! 52: // PutOneByte(GetOneByte(distance));
! 53: }
! 54: }
! 55:
! 56: void PutByte(Byte b)
! 57: {
! 58: _buffer[_pos++] = b;
! 59: if (_pos >= _windowSize)
! 60: FlushWithCheck();
! 61: }
! 62:
! 63: Byte GetByte(UInt32 distance) const
! 64: {
! 65: UInt32 pos = _pos - distance - 1;
! 66: if (pos >= _windowSize)
! 67: pos += _windowSize;
! 68: return _buffer[pos];
! 69: }
! 70: };
! 71:
! 72: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>