1 // InStreamWithCRC.h
2 
3 #ifndef ZIP7_INC_IN_STREAM_WITH_CRC_H
4 #define ZIP7_INC_IN_STREAM_WITH_CRC_H
5 
6 #include "../../../../C/7zCrc.h"
7 
8 #include "../../../Common/MyCom.h"
9 
10 #include "../../IStream.h"
11 
12 Z7_CLASS_IMP_NOQIB_2(
13   CSequentialInStreamWithCRC
14   , ISequentialInStream
15   , IStreamGetSize
16 )
17   CMyComPtr<ISequentialInStream> _stream;
18   UInt64 _size;
19   UInt32 _crc;
20   bool _wasFinished;
21   UInt64 _fullSize;
22 public:
23 
CSequentialInStreamWithCRC()24   CSequentialInStreamWithCRC():
25     _fullSize((UInt64)(Int64)-1)
26     {}
27 
SetStream(ISequentialInStream *stream)28   void SetStream(ISequentialInStream *stream) { _stream = stream; }
SetFullSize(UInt64 fullSize)29   void SetFullSize(UInt64 fullSize) { _fullSize = fullSize; }
Init()30   void Init()
31   {
32     _size = 0;
33     _crc = CRC_INIT_VAL;
34     _wasFinished = false;
35   }
ReleaseStream()36   void ReleaseStream() { _stream.Release(); }
GetCRC() const37   UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
GetSize() const38   UInt64 GetSize() const { return _size; }
WasFinished() const39   bool WasFinished() const { return _wasFinished; }
40 };
41 
42 
43 Z7_CLASS_IMP_COM_1(
44   CInStreamWithCRC,
45   IInStream
46 )
47   Z7_IFACE_COM7_IMP(ISequentialInStream)
48 
49   CMyComPtr<IInStream> _stream;
50   UInt64 _size;
51   UInt32 _crc;
52   // bool _wasFinished;
53 public:
54   void SetStream(IInStream *stream) { _stream = stream; }
55   void Init()
56   {
57     _size = 0;
58     // _wasFinished = false;
59     _crc = CRC_INIT_VAL;
60   }
61   void ReleaseStream() { _stream.Release(); }
62   UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
63   UInt64 GetSize() const { return _size; }
64   // bool WasFinished() const { return _wasFinished; }
65 };
66 
67 #endif
68