Mercurial > vba-linux
diff src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Common/FilterCoder.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,143 @@ 1.4 +// FilterCoder.h 1.5 + 1.6 +#ifndef __FILTERCODER_H 1.7 +#define __FILTERCODER_H 1.8 + 1.9 +#include "../../Common/MyCom.h" 1.10 +#include "../ICoder.h" 1.11 +#include "../IPassword.h" 1.12 + 1.13 +#define MY_QUERYINTERFACE_ENTRY_AG(i, sub0, sub) if (iid == IID_ ## i) \ 1.14 +{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \ 1.15 +*outObject = (void *)(i *)this; AddRef(); return S_OK; } 1.16 + 1.17 +class CFilterCoder: 1.18 + public ICompressCoder, 1.19 + // #ifdef _ST_MODE 1.20 + public ICompressSetInStream, 1.21 + public ISequentialInStream, 1.22 + public ICompressSetOutStream, 1.23 + public ISequentialOutStream, 1.24 + public IOutStreamFlush, 1.25 + // #endif 1.26 + 1.27 + #ifndef _NO_CRYPTO 1.28 + public ICryptoSetPassword, 1.29 + #endif 1.30 + #ifndef EXTRACT_ONLY 1.31 + public ICompressSetCoderProperties, 1.32 + public ICompressWriteCoderProperties, 1.33 + // public ICryptoResetSalt, 1.34 + public ICryptoResetInitVector, 1.35 + #endif 1.36 + public ICompressSetDecoderProperties2, 1.37 + public CMyUnknownImp 1.38 +{ 1.39 +protected: 1.40 + Byte *_buffer; 1.41 + // #ifdef _ST_MODE 1.42 + CMyComPtr<ISequentialInStream> _inStream; 1.43 + CMyComPtr<ISequentialOutStream> _outStream; 1.44 + UInt32 _bufferPos; 1.45 + UInt32 _convertedPosBegin; 1.46 + UInt32 _convertedPosEnd; 1.47 + // #endif 1.48 + bool _outSizeIsDefined; 1.49 + UInt64 _outSize; 1.50 + UInt64 _nowPos64; 1.51 + 1.52 + HRESULT Init() 1.53 + { 1.54 + _nowPos64 = 0; 1.55 + _outSizeIsDefined = false; 1.56 + return Filter->Init(); 1.57 + } 1.58 + 1.59 + CMyComPtr<ICryptoSetPassword> _setPassword; 1.60 + #ifndef EXTRACT_ONLY 1.61 + CMyComPtr<ICompressSetCoderProperties> _SetCoderProperties; 1.62 + CMyComPtr<ICompressWriteCoderProperties> _writeCoderProperties; 1.63 + // CMyComPtr<ICryptoResetSalt> _CryptoResetSalt; 1.64 + CMyComPtr<ICryptoResetInitVector> _CryptoResetInitVector; 1.65 + #endif 1.66 + CMyComPtr<ICompressSetDecoderProperties2> _setDecoderProperties; 1.67 +public: 1.68 + CMyComPtr<ICompressFilter> Filter; 1.69 + 1.70 + CFilterCoder(); 1.71 + ~CFilterCoder(); 1.72 + HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size); 1.73 + bool NeedMore() const 1.74 + { return (!_outSizeIsDefined || (_nowPos64 < _outSize)); } 1.75 + 1.76 +public: 1.77 + MY_QUERYINTERFACE_BEGIN 1.78 + MY_QUERYINTERFACE_ENTRY(ICompressCoder) 1.79 + // #ifdef _ST_MODE 1.80 + MY_QUERYINTERFACE_ENTRY(ICompressSetInStream) 1.81 + MY_QUERYINTERFACE_ENTRY(ISequentialInStream) 1.82 + 1.83 + MY_QUERYINTERFACE_ENTRY(ICompressSetOutStream) 1.84 + MY_QUERYINTERFACE_ENTRY(ISequentialOutStream) 1.85 + MY_QUERYINTERFACE_ENTRY(IOutStreamFlush) 1.86 + // #endif 1.87 + 1.88 + #ifndef _NO_CRYPTO 1.89 + MY_QUERYINTERFACE_ENTRY_AG(ICryptoSetPassword, Filter, _setPassword) 1.90 + #endif 1.91 + 1.92 + #ifndef EXTRACT_ONLY 1.93 + MY_QUERYINTERFACE_ENTRY_AG(ICompressSetCoderProperties, Filter, _SetCoderProperties) 1.94 + MY_QUERYINTERFACE_ENTRY_AG(ICompressWriteCoderProperties, Filter, _writeCoderProperties) 1.95 + // MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetSalt, Filter, _CryptoResetSalt) 1.96 + MY_QUERYINTERFACE_ENTRY_AG(ICryptoResetInitVector, Filter, _CryptoResetInitVector) 1.97 + #endif 1.98 + 1.99 + MY_QUERYINTERFACE_ENTRY_AG(ICompressSetDecoderProperties2, Filter, _setDecoderProperties) 1.100 + MY_QUERYINTERFACE_END 1.101 + MY_ADDREF_RELEASE 1.102 + STDMETHOD(Code)(ISequentialInStream *inStream, 1.103 + ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, 1.104 + ICompressProgressInfo *progress); 1.105 + // #ifdef _ST_MODE 1.106 + STDMETHOD(ReleaseInStream)(); 1.107 + STDMETHOD(SetInStream)(ISequentialInStream *inStream); 1.108 + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); \ 1.109 + STDMETHOD(SetOutStream)(ISequentialOutStream *outStream); 1.110 + STDMETHOD(ReleaseOutStream)(); 1.111 + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 1.112 + STDMETHOD(Flush)(); 1.113 + // #endif 1.114 + 1.115 + #ifndef _NO_CRYPTO 1.116 + STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size); 1.117 + #endif 1.118 + #ifndef EXTRACT_ONLY 1.119 + STDMETHOD(SetCoderProperties)(const PROPID *propIDs, 1.120 + const PROPVARIANT *properties, UInt32 numProperties); 1.121 + STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream); 1.122 + // STDMETHOD(ResetSalt)(); 1.123 + STDMETHOD(ResetInitVector)(); 1.124 + #endif 1.125 + STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size); 1.126 +}; 1.127 + 1.128 +// #ifdef _ST_MODE 1.129 +class CInStreamReleaser 1.130 +{ 1.131 +public: 1.132 + CFilterCoder *FilterCoder; 1.133 + CInStreamReleaser(): FilterCoder(0) {} 1.134 + ~CInStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseInStream(); } 1.135 +}; 1.136 + 1.137 +class COutStreamReleaser 1.138 +{ 1.139 +public: 1.140 + CFilterCoder *FilterCoder; 1.141 + COutStreamReleaser(): FilterCoder(0) {} 1.142 + ~COutStreamReleaser() { if (FilterCoder) FilterCoder->ReleaseOutStream(); } 1.143 +}; 1.144 +// #endif 1.145 + 1.146 +#endif