• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // OutStreamWithCRC.h
2 
3 #ifndef ZIP7_INC_OUT_STREAM_WITH_CRC_H
4 #define ZIP7_INC_OUT_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_1(
13   COutStreamWithCRC
14   , ISequentialOutStream
15 )
16   CMyComPtr<ISequentialOutStream> _stream;
17   UInt64 _size;
18   UInt32 _crc;
19   bool _calculate;
20 public:
SetStream(ISequentialOutStream * stream)21   void SetStream(ISequentialOutStream *stream) { _stream = stream; }
ReleaseStream()22   void ReleaseStream() { _stream.Release(); }
23   void Init(bool calculate = true)
24   {
25     _size = 0;
26     _calculate = calculate;
27     _crc = CRC_INIT_VAL;
28   }
EnableCalc(bool calculate)29   void EnableCalc(bool calculate) { _calculate = calculate; }
InitCRC()30   void InitCRC() { _crc = CRC_INIT_VAL; }
GetSize()31   UInt64 GetSize() const { return _size; }
GetCRC()32   UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
33 };
34 
35 #endif
36