• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RegisterArc.h
2 
3 #ifndef __REGISTER_ARC_H
4 #define __REGISTER_ARC_H
5 
6 #include "../Archive/IArchive.h"
7 
8 struct CArcInfo
9 {
10   UInt16 Flags;
11   Byte Id;
12   Byte SignatureSize;
13   UInt16 SignatureOffset;
14 
15   const Byte *Signature;
16   const char *Name;
17   const char *Ext;
18   const char *AddExt;
19 
20   Func_CreateInArchive CreateInArchive;
21   Func_CreateOutArchive CreateOutArchive;
22   Func_IsArc IsArc;
23 
IsMultiSignatureCArcInfo24   bool IsMultiSignature() const { return (Flags & NArcInfoFlags::kMultiSignature) != 0; }
25 };
26 
27 void RegisterArc(const CArcInfo *arcInfo) throw();
28 
29 
30 #define IMP_CreateArcIn_2(c) \
31   static IInArchive *CreateArc() { return new c; }
32 
33 #define IMP_CreateArcIn IMP_CreateArcIn_2(CHandler())
34 
35 #ifdef EXTRACT_ONLY
36   #define IMP_CreateArcOut
37   #define CreateArcOut NULL
38 #else
39   #define IMP_CreateArcOut static IOutArchive *CreateArcOut() { return new CHandler(); }
40 #endif
41 
42 #define REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
43   static const CArcInfo g_ArcInfo = { flags, id, sigSize, offs, sig, n, e, ae, crIn, crOut, isArc } ; \
44 
45 #define REGISTER_ARC_R(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
46   REGISTER_ARC_V(n, e, ae, id, sigSize, sig, offs, flags, crIn, crOut, isArc) \
47   struct CRegisterArc { CRegisterArc() { RegisterArc(&g_ArcInfo); }}; \
48   static CRegisterArc g_RegisterArc;
49 
50 
51 #define REGISTER_ARC_I_CLS(cls, n, e, ae, id, sig, offs, flags, isArc) \
52   IMP_CreateArcIn_2(cls) \
53   REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, NULL, isArc)
54 
55 #define REGISTER_ARC_I_CLS_NO_SIG(cls, n, e, ae, id, offs, flags, isArc) \
56   IMP_CreateArcIn_2(cls) \
57   REGISTER_ARC_R(n, e, ae, id, 0, NULL, offs, flags, CreateArc, NULL, isArc)
58 
59 #define REGISTER_ARC_I(n, e, ae, id, sig, offs, flags, isArc) \
60   REGISTER_ARC_I_CLS(CHandler(), n, e, ae, id, sig, offs, flags, isArc)
61 
62 #define REGISTER_ARC_I_NO_SIG(n, e, ae, id, offs, flags, isArc) \
63   REGISTER_ARC_I_CLS_NO_SIG(CHandler(), n, e, ae, id, offs, flags, isArc)
64 
65 
66 #define REGISTER_ARC_IO(n, e, ae, id, sig, offs, flags, isArc) \
67   IMP_CreateArcIn \
68   IMP_CreateArcOut \
69   REGISTER_ARC_R(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc)
70 
71 #define REGISTER_ARC_IO_DECREMENT_SIG(n, e, ae, id, sig, offs, flags, isArc) \
72   IMP_CreateArcIn \
73   IMP_CreateArcOut \
74   REGISTER_ARC_V(n, e, ae, id, ARRAY_SIZE(sig), sig, offs, flags, CreateArc, CreateArcOut, isArc) \
75   struct CRegisterArcDecSig { CRegisterArcDecSig() { sig[0]--; RegisterArc(&g_ArcInfo); }}; \
76   static CRegisterArcDecSig g_RegisterArc;
77 
78 #endif
79