other-licenses/7zstub/src/7zip/Compress/Branch/BranchCoder.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 // BranchCoder.h
michael@0 2
michael@0 3 #ifndef __BRANCH_CODER_H
michael@0 4 #define __BRANCH_CODER_H
michael@0 5
michael@0 6 #include "Common/MyCom.h"
michael@0 7 #include "Common/Types.h"
michael@0 8 #include "Common/Alloc.h"
michael@0 9
michael@0 10 #include "../../ICoder.h"
michael@0 11
michael@0 12 class CBranchConverter:
michael@0 13 public ICompressFilter,
michael@0 14 public CMyUnknownImp
michael@0 15 {
michael@0 16 protected:
michael@0 17 UInt32 _bufferPos;
michael@0 18 virtual void SubInit() {}
michael@0 19 virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
michael@0 20 public:
michael@0 21 MY_UNKNOWN_IMP;
michael@0 22 STDMETHOD(Init)();
michael@0 23 STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
michael@0 24 };
michael@0 25
michael@0 26 #define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
michael@0 27 { public: UInt32 SubFilter(Byte *data, UInt32 size); };
michael@0 28
michael@0 29 #define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
michael@0 30 { public: UInt32 SubFilter(Byte *data, UInt32 size); };
michael@0 31
michael@0 32 #define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
michael@0 33 { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
michael@0 34
michael@0 35 #define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
michael@0 36 { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
michael@0 37
michael@0 38 #define MyClass2b(Name, id, subId, encodingId) \
michael@0 39 DEFINE_GUID(CLSID_CCompressConvert ## Name, \
michael@0 40 0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00);
michael@0 41
michael@0 42 #define MyClassA(Name, id, subId) \
michael@0 43 MyClass2b(Name ## _Encoder, id, subId, 0x01) \
michael@0 44 MyClassEncoderA(Name ## _Encoder) \
michael@0 45 MyClass2b(Name ## _Decoder, id, subId, 0x00) \
michael@0 46 MyClassDecoderA(Name ## _Decoder)
michael@0 47
michael@0 48 #define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \
michael@0 49 MyClass2b(Name ## _Encoder, id, subId, 0x01) \
michael@0 50 MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
michael@0 51 MyClass2b(Name ## _Decoder, id, subId, 0x00) \
michael@0 52 MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
michael@0 53
michael@0 54 #endif

mercurial