misc/libphysfs/lzma/CPP/7zip/Archive/Common/OutStreamWithCRC.h
branchui-scaling
changeset 15283 c4fd2813b127
parent 13390 0135e64c6c66
parent 15279 7ab5cf405686
child 15663 d92eeb468dad
equal deleted inserted replaced
13390:0135e64c6c66 15283:c4fd2813b127
     1 // OutStreamWithCRC.h
       
     2 
       
     3 #ifndef __OUTSTREAMWITHCRC_H
       
     4 #define __OUTSTREAMWITHCRC_H
       
     5 
       
     6 #include "../../../Common/MyCom.h"
       
     7 #include "../../IStream.h"
       
     8 
       
     9 extern "C" 
       
    10 { 
       
    11 #include "../../../../C/7zCrc.h"
       
    12 }
       
    13 
       
    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 };
       
    37 
       
    38 #endif