view src/win32/7zip/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line source
1 // OutStreamWithCRC.h
3 #ifndef __OUT_STREAM_WITH_CRC_H
4 #define __OUT_STREAM_WITH_CRC_H
6 #include "../../../Common/MyCom.h"
7 #include "../../IStream.h"
9 extern "C"
10 {
11 #include "../../../../C/7zCrc.h"
12 }
14 class COutStreamWithCRC:
15 public ISequentialOutStream,
16 public CMyUnknownImp
17 {
18 CMyComPtr<ISequentialOutStream> _stream;
19 UInt64 _size;
20 UInt32 _crc;
21 bool _calculate;
22 public:
23 MY_UNKNOWN_IMP
24 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
25 void SetStream(ISequentialOutStream *stream) { _stream = stream; }
26 void ReleaseStream() { _stream.Release(); }
27 void Init(bool calculate = true)
28 {
29 _size = 0;
30 _calculate = calculate;
31 _crc = CRC_INIT_VAL;
32 }
33 void InitCRC() { _crc = CRC_INIT_VAL; }
34 UInt64 GetSize() const { return _size; }
35 UInt32 GetCRC() const { return CRC_GET_DIGEST(_crc); }
36 };
38 #endif