1
#ifndef __STREAM_WINDOWIN_H
2
#define __STREAM_WINDOWIN_H
4
#include "IInOutStreams.h"
13
BYTE *m_BufferBase; // pointer to buffer with data
14
ISequentialInStream* m_Stream;
15
INT m_PosLimit; // offset (from m_Buffer) of first byte when new block reading must be done
16
bool m_StreamEndWasReached; // if (true) then m_StreamPos shows real end of stream
18
const BYTE *m_PointerToLastSafePosition;
21
BYTE *m_Buffer; // Pointer to virtual Buffer begin
22
INT m_BlockSize; // Size of Allocated memory block
23
INT m_Pos; // offset (from m_Buffer) of curent byte
24
INT m_KeepSizeBefore; // how many BYTEs must be kept in buffer before m_Pos
25
INT m_KeepSizeAfter; // how many BYTEs must be kept buffer after m_Pos
26
INT m_KeepSizeReserv; // how many BYTEs must be kept as reserv
27
INT m_StreamPos; // offset (from m_Buffer) of first not read byte from Stream
29
virtual void BeforeMoveBlock() {};
30
virtual void AfterMoveBlock() {};
32
virtual HRESULT ReadBlock();
36
void Create(INT aKeepSizeBefore, INT aKeepSizeAfter,
37
INT aKeepSizeReserv = (1<<17));
40
HRESULT Init(ISequentialInStream *aStream);
42
BYTE *GetBuffer() const { return m_Buffer; }
44
const BYTE *GetPointerToCurrentPos() const { return m_Buffer + m_Pos; }
49
if (m_Pos > m_PosLimit)
51
const BYTE *aPointerToPostion = m_Buffer + m_Pos;
52
if(aPointerToPostion > m_PointerToLastSafePosition)
59
// BYTE GetCurrentByte()const;
60
BYTE GetIndexByte(INT anIndex)const
61
{ return m_Buffer[m_Pos + anIndex]; }
63
// INT GetCurPos()const { return m_Pos;};
64
// BYTE *GetBufferBeg()const { return m_Buffer;};
66
// aIndex + aLimit have not to exceed m_KeepSizeAfter;
67
INT GetMatchLen(INT aIndex, INT aBack, INT aLimit) const
69
if(m_StreamEndWasReached)
70
if ((m_Pos + aIndex) + aLimit > m_StreamPos)
71
aLimit = m_StreamPos - (m_Pos + aIndex);
73
BYTE *pby = m_Buffer + m_Pos + aIndex;
75
for(i = 0; i < aLimit && pby[i] == pby[i - aBack]; i++);
79
INT GetNumAvailableBytes() const { return m_StreamPos - m_Pos; }
81
void ReduceOffsets(INT aSubValue)
83
m_Buffer += aSubValue;
84
m_PosLimit -= aSubValue;
86
m_StreamPos -= aSubValue;