1 // LzmaDecoder.h 2 3 #ifndef __LZMA_DECODER_H 4 #define __LZMA_DECODER_H 5 6 #include "../../../C/LzmaDec.h" 7 8 #include "../../Common/MyCom.h" 9 #include "../ICoder.h" 10 11 namespace NCompress { 12 namespace NLzma { 13 14 class CDecoder: 15 public ICompressCoder, 16 public ICompressSetDecoderProperties2, 17 #ifndef NO_READ_FROM_CODER 18 public ICompressSetInStream, 19 public ICompressSetOutStreamSize, 20 public ISequentialInStream, 21 #endif 22 public CMyUnknownImp 23 { 24 CMyComPtr<ISequentialInStream> _inStream; 25 Byte *_inBuf; 26 UInt32 _inPos; 27 UInt32 _inSize; 28 CLzmaDec _state; 29 bool _propsWereSet; 30 bool _outSizeDefined; 31 UInt64 _outSize; 32 UInt64 _inSizeProcessed; 33 UInt64 _outSizeProcessed; 34 35 HRESULT CreateInputBuffer(); 36 HRESULT CodeSpec(ISequentialInStream *inStream, ISequentialOutStream *outStream, ICompressProgressInfo *progress); 37 void SetOutStreamSizeResume(const UInt64 *outSize); 38 39 public: 40 MY_QUERYINTERFACE_BEGIN 41 MY_QUERYINTERFACE_ENTRY(ICompressSetDecoderProperties2) 42 #ifndef NO_READ_FROM_CODER 43 MY_QUERYINTERFACE_ENTRY(ICompressSetInStream) 44 MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize) 45 MY_QUERYINTERFACE_ENTRY(ISequentialInStream) 46 #endif 47 MY_QUERYINTERFACE_END 48 MY_ADDREF_RELEASE 49 50 STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, 51 const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); 52 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); 53 STDMETHOD(SetOutStreamSize)(const UInt64 *outSize); 54 55 #ifndef NO_READ_FROM_CODER 56 57 STDMETHOD(SetInStream)(ISequentialInStream *inStream); 58 STDMETHOD(ReleaseInStream)(); 59 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 60 61 HRESULT CodeResume(ISequentialOutStream *outStream, const UInt64 *outSize, ICompressProgressInfo *progress); 62 HRESULT ReadFromInputStream(void *data, UInt32 size, UInt32 *processedSize); GetInputProcessedSize()63 UInt64 GetInputProcessedSize() const { return _inSizeProcessed; } 64 65 #endif 66 67 bool FinishStream; 68 69 CDecoder(); 70 virtual ~CDecoder(); 71 72 }; 73 74 }} 75 76 #endif 77