xref: /third_party/lzma/CPP/Common/MyCom.h (revision 370b324c)
1370b324cSopenharmony_ci// MyCom.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_MY_COM_H
4370b324cSopenharmony_ci#define ZIP7_INC_MY_COM_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci#include "MyWindows.h"
7370b324cSopenharmony_ci#include "MyTypes.h"
8370b324cSopenharmony_ci
9370b324cSopenharmony_citemplate <class T>
10370b324cSopenharmony_ciclass CMyComPtr
11370b324cSopenharmony_ci{
12370b324cSopenharmony_ci  T* _p;
13370b324cSopenharmony_cipublic:
14370b324cSopenharmony_ci  CMyComPtr(): _p(NULL) {}
15370b324cSopenharmony_ci  CMyComPtr(T* p) throw() { if ((_p = p) != NULL) p->AddRef(); }
16370b324cSopenharmony_ci  CMyComPtr(const CMyComPtr<T>& lp) throw() { if ((_p = lp._p) != NULL) _p->AddRef(); }
17370b324cSopenharmony_ci  ~CMyComPtr() { if (_p) _p->Release(); }
18370b324cSopenharmony_ci  void Release() { if (_p) { _p->Release(); _p = NULL; } }
19370b324cSopenharmony_ci  operator T*() const {  return (T*)_p;  }
20370b324cSopenharmony_ci  // T& operator*() const {  return *_p; }
21370b324cSopenharmony_ci  T** operator&() { return &_p; }
22370b324cSopenharmony_ci  T* operator->() const { return _p; }
23370b324cSopenharmony_ci  T* operator=(T* p)
24370b324cSopenharmony_ci  {
25370b324cSopenharmony_ci    if (p)
26370b324cSopenharmony_ci      p->AddRef();
27370b324cSopenharmony_ci    if (_p)
28370b324cSopenharmony_ci      _p->Release();
29370b324cSopenharmony_ci    _p = p;
30370b324cSopenharmony_ci    return p;
31370b324cSopenharmony_ci  }
32370b324cSopenharmony_ci  T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
33370b324cSopenharmony_ci  bool operator!() const { return (_p == NULL); }
34370b324cSopenharmony_ci  // bool operator==(T* pT) const {  return _p == pT; }
35370b324cSopenharmony_ci  void Attach(T* p2)
36370b324cSopenharmony_ci  {
37370b324cSopenharmony_ci    Release();
38370b324cSopenharmony_ci    _p = p2;
39370b324cSopenharmony_ci  }
40370b324cSopenharmony_ci  T* Detach()
41370b324cSopenharmony_ci  {
42370b324cSopenharmony_ci    T* pt = _p;
43370b324cSopenharmony_ci    _p = NULL;
44370b324cSopenharmony_ci    return pt;
45370b324cSopenharmony_ci  }
46370b324cSopenharmony_ci  #ifdef _WIN32
47370b324cSopenharmony_ci  HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
48370b324cSopenharmony_ci  {
49370b324cSopenharmony_ci    return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
50370b324cSopenharmony_ci  }
51370b324cSopenharmony_ci  #endif
52370b324cSopenharmony_ci  /*
53370b324cSopenharmony_ci  HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
54370b324cSopenharmony_ci  {
55370b324cSopenharmony_ci    CLSID clsid;
56370b324cSopenharmony_ci    HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
57370b324cSopenharmony_ci    ATLASSERT(_p == NULL);
58370b324cSopenharmony_ci    if (SUCCEEDED(hr))
59370b324cSopenharmony_ci      hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
60370b324cSopenharmony_ci    return hr;
61370b324cSopenharmony_ci  }
62370b324cSopenharmony_ci  */
63370b324cSopenharmony_ci  template <class Q>
64370b324cSopenharmony_ci  HRESULT QueryInterface(REFGUID iid, Q** pp) const throw()
65370b324cSopenharmony_ci  {
66370b324cSopenharmony_ci    // if (*pp) throw 20220216; // for debug
67370b324cSopenharmony_ci    return _p->QueryInterface(iid, (void**)pp);
68370b324cSopenharmony_ci  }
69370b324cSopenharmony_ci};
70370b324cSopenharmony_ci
71370b324cSopenharmony_ci#define Z7_DECL_CMyComPtr_QI_FROM(i, v, unk) \
72370b324cSopenharmony_ci  CMyComPtr<i> v; (unk)->QueryInterface(IID_ ## i, (void **)&v);
73370b324cSopenharmony_ci
74370b324cSopenharmony_ci
75370b324cSopenharmony_ci//////////////////////////////////////////////////////////
76370b324cSopenharmony_ci
77370b324cSopenharmony_ciinline HRESULT StringToBstr(LPCOLESTR src, BSTR *bstr)
78370b324cSopenharmony_ci{
79370b324cSopenharmony_ci  *bstr = ::SysAllocString(src);
80370b324cSopenharmony_ci  return (*bstr) ? S_OK : E_OUTOFMEMORY;
81370b324cSopenharmony_ci}
82370b324cSopenharmony_ci
83370b324cSopenharmony_ciclass CMyComBSTR
84370b324cSopenharmony_ci{
85370b324cSopenharmony_ci  BSTR m_str;
86370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CMyComBSTR)
87370b324cSopenharmony_cipublic:
88370b324cSopenharmony_ci  CMyComBSTR(): m_str(NULL) {}
89370b324cSopenharmony_ci  ~CMyComBSTR() { ::SysFreeString(m_str); }
90370b324cSopenharmony_ci  BSTR* operator&() { return &m_str; }
91370b324cSopenharmony_ci  operator LPCOLESTR() const { return m_str; }
92370b324cSopenharmony_ci  // operator bool() const { return m_str != NULL; }
93370b324cSopenharmony_ci  // bool operator!() const { return m_str == NULL; }
94370b324cSopenharmony_ci
95370b324cSopenharmony_ci  void Wipe_and_Free()
96370b324cSopenharmony_ci  {
97370b324cSopenharmony_ci    if (m_str)
98370b324cSopenharmony_ci    {
99370b324cSopenharmony_ci      memset(m_str, 0, ::SysStringLen(m_str) * sizeof(*m_str));
100370b324cSopenharmony_ci      Empty();
101370b324cSopenharmony_ci    }
102370b324cSopenharmony_ci  }
103370b324cSopenharmony_ci
104370b324cSopenharmony_ciprivate:
105370b324cSopenharmony_ci  // operator BSTR() const { return m_str; }
106370b324cSopenharmony_ci
107370b324cSopenharmony_ci  CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }
108370b324cSopenharmony_ci  // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
109370b324cSopenharmony_ci  // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize);  }
110370b324cSopenharmony_ci  // CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
111370b324cSopenharmony_ci
112370b324cSopenharmony_ci  /*
113370b324cSopenharmony_ci  CMyComBSTR(REFGUID src)
114370b324cSopenharmony_ci  {
115370b324cSopenharmony_ci    LPOLESTR szGuid;
116370b324cSopenharmony_ci    StringFromCLSID(src, &szGuid);
117370b324cSopenharmony_ci    m_str = ::SysAllocString(szGuid);
118370b324cSopenharmony_ci    CoTaskMemFree(szGuid);
119370b324cSopenharmony_ci  }
120370b324cSopenharmony_ci  */
121370b324cSopenharmony_ci
122370b324cSopenharmony_ci  /*
123370b324cSopenharmony_ci  CMyComBSTR& operator=(const CMyComBSTR& src)
124370b324cSopenharmony_ci  {
125370b324cSopenharmony_ci    if (m_str != src.m_str)
126370b324cSopenharmony_ci    {
127370b324cSopenharmony_ci      if (m_str)
128370b324cSopenharmony_ci        ::SysFreeString(m_str);
129370b324cSopenharmony_ci      m_str = src.MyCopy();
130370b324cSopenharmony_ci    }
131370b324cSopenharmony_ci    return *this;
132370b324cSopenharmony_ci  }
133370b324cSopenharmony_ci  */
134370b324cSopenharmony_ci
135370b324cSopenharmony_ci  CMyComBSTR& operator=(LPCOLESTR src)
136370b324cSopenharmony_ci  {
137370b324cSopenharmony_ci    ::SysFreeString(m_str);
138370b324cSopenharmony_ci    m_str = ::SysAllocString(src);
139370b324cSopenharmony_ci    return *this;
140370b324cSopenharmony_ci  }
141370b324cSopenharmony_ci
142370b324cSopenharmony_ci  unsigned Len() const { return ::SysStringLen(m_str); }
143370b324cSopenharmony_ci
144370b324cSopenharmony_ci  BSTR MyCopy() const
145370b324cSopenharmony_ci  {
146370b324cSopenharmony_ci    // We don't support Byte BSTRs here
147370b324cSopenharmony_ci    return ::SysAllocStringLen(m_str, ::SysStringLen(m_str));
148370b324cSopenharmony_ci    /*
149370b324cSopenharmony_ci    UINT byteLen = ::SysStringByteLen(m_str);
150370b324cSopenharmony_ci    BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
151370b324cSopenharmony_ci    if (res && byteLen != 0 && m_str)
152370b324cSopenharmony_ci      memcpy(res, m_str, byteLen);
153370b324cSopenharmony_ci    return res;
154370b324cSopenharmony_ci    */
155370b324cSopenharmony_ci  }
156370b324cSopenharmony_ci
157370b324cSopenharmony_ci  /*
158370b324cSopenharmony_ci  void Attach(BSTR src) { m_str = src; }
159370b324cSopenharmony_ci  BSTR Detach()
160370b324cSopenharmony_ci  {
161370b324cSopenharmony_ci    BSTR s = m_str;
162370b324cSopenharmony_ci    m_str = NULL;
163370b324cSopenharmony_ci    return s;
164370b324cSopenharmony_ci  }
165370b324cSopenharmony_ci  */
166370b324cSopenharmony_ci
167370b324cSopenharmony_ci  void Empty()
168370b324cSopenharmony_ci  {
169370b324cSopenharmony_ci    ::SysFreeString(m_str);
170370b324cSopenharmony_ci    m_str = NULL;
171370b324cSopenharmony_ci  }
172370b324cSopenharmony_ci};
173370b324cSopenharmony_ci
174370b324cSopenharmony_ci
175370b324cSopenharmony_ciclass CMyComBSTR_Wipe: public CMyComBSTR
176370b324cSopenharmony_ci{
177370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CMyComBSTR_Wipe)
178370b324cSopenharmony_cipublic:
179370b324cSopenharmony_ci  CMyComBSTR_Wipe(): CMyComBSTR() {}
180370b324cSopenharmony_ci  ~CMyComBSTR_Wipe() { Wipe_and_Free(); }
181370b324cSopenharmony_ci};
182370b324cSopenharmony_ci
183370b324cSopenharmony_ci
184370b324cSopenharmony_ci
185370b324cSopenharmony_ci/*
186370b324cSopenharmony_ci  If CMyUnknownImp doesn't use virtual destructor, the code size is smaller.
187370b324cSopenharmony_ci  But if some class_1 derived from CMyUnknownImp
188370b324cSopenharmony_ci    uses Z7_COM_ADDREF_RELEASE and IUnknown::Release()
189370b324cSopenharmony_ci    and some another class_2 is derived from class_1,
190370b324cSopenharmony_ci    then class_1 must use virtual destructor:
191370b324cSopenharmony_ci      virtual ~class_1();
192370b324cSopenharmony_ci    In that case, class_1::Release() calls correct destructor of class_2.
193370b324cSopenharmony_ci  We can use virtual ~CMyUnknownImp() to disable warning
194370b324cSopenharmony_ci    "class has virtual functions, but destructor is not virtual".
195370b324cSopenharmony_ci  Also we can use virtual ~IUnknown() {} in MyWindows.h
196370b324cSopenharmony_ci*/
197370b324cSopenharmony_ci
198370b324cSopenharmony_ciclass CMyUnknownImp
199370b324cSopenharmony_ci{
200370b324cSopenharmony_ci  Z7_CLASS_NO_COPY(CMyUnknownImp)
201370b324cSopenharmony_ciprotected:
202370b324cSopenharmony_ci  ULONG _m_RefCount;
203370b324cSopenharmony_ci  CMyUnknownImp(): _m_RefCount(0) {}
204370b324cSopenharmony_ci
205370b324cSopenharmony_ci  #ifdef _WIN32
206370b324cSopenharmony_ci  #if defined(__GNUC__) || defined(__clang__)
207370b324cSopenharmony_ci  // virtual ~CMyUnknownImp() {} // to disable GCC/CLANG varnings
208370b324cSopenharmony_ci  #endif
209370b324cSopenharmony_ci  #endif
210370b324cSopenharmony_ci};
211370b324cSopenharmony_ci
212370b324cSopenharmony_ci
213370b324cSopenharmony_ci
214370b324cSopenharmony_ci#define Z7_COM_QI_BEGIN \
215370b324cSopenharmony_ci  private: STDMETHOD(QueryInterface) (REFGUID iid, void **outObject) throw() Z7_override Z7_final \
216370b324cSopenharmony_ci    { *outObject = NULL;
217370b324cSopenharmony_ci
218370b324cSopenharmony_ci#define Z7_COM_QI_ENTRY(i) \
219370b324cSopenharmony_ci  else if (iid == IID_ ## i) \
220370b324cSopenharmony_ci    { i *ti = this;  *outObject = ti; }
221370b324cSopenharmony_ci//   { *outObject = (void *)(i *)this; }
222370b324cSopenharmony_ci
223370b324cSopenharmony_ci#define Z7_COM_QI_ENTRY_UNKNOWN_0 \
224370b324cSopenharmony_ci  if (iid == IID_IUnknown) \
225370b324cSopenharmony_ci    { IUnknown *tu = this;  *outObject = tu; }
226370b324cSopenharmony_ci
227370b324cSopenharmony_ci#define Z7_COM_QI_ENTRY_UNKNOWN(i) \
228370b324cSopenharmony_ci  if (iid == IID_IUnknown) \
229370b324cSopenharmony_ci    { i *ti = this;  IUnknown *tu = ti;  *outObject = tu; }
230370b324cSopenharmony_ci//    { *outObject = (void *)(IUnknown *)(i *)this; }
231370b324cSopenharmony_ci
232370b324cSopenharmony_ci#define Z7_COM_QI_BEGIN2(i) \
233370b324cSopenharmony_ci  Z7_COM_QI_BEGIN \
234370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i) \
235370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i)
236370b324cSopenharmony_ci
237370b324cSopenharmony_ci#define Z7_COM_QI_END \
238370b324cSopenharmony_ci  else return E_NOINTERFACE; \
239370b324cSopenharmony_ci  ++_m_RefCount; /* AddRef(); */ return S_OK; }
240370b324cSopenharmony_ci
241370b324cSopenharmony_ci#define Z7_COM_ADDREF_RELEASE \
242370b324cSopenharmony_ci  private: \
243370b324cSopenharmony_ci  STDMETHOD_(ULONG, AddRef)() throw() Z7_override Z7_final \
244370b324cSopenharmony_ci    { return ++_m_RefCount; } \
245370b324cSopenharmony_ci  STDMETHOD_(ULONG, Release)() throw() Z7_override Z7_final \
246370b324cSopenharmony_ci    { if (--_m_RefCount != 0) return _m_RefCount;  delete this;  return 0; } \
247370b324cSopenharmony_ci
248370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_SPEC(i) \
249370b324cSopenharmony_ci  Z7_COM_QI_BEGIN \
250370b324cSopenharmony_ci  i \
251370b324cSopenharmony_ci  Z7_COM_QI_END \
252370b324cSopenharmony_ci  Z7_COM_ADDREF_RELEASE
253370b324cSopenharmony_ci
254370b324cSopenharmony_ci
255370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_0 \
256370b324cSopenharmony_ci  Z7_COM_QI_BEGIN \
257370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN_0 \
258370b324cSopenharmony_ci  Z7_COM_QI_END \
259370b324cSopenharmony_ci  Z7_COM_ADDREF_RELEASE
260370b324cSopenharmony_ci
261370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_1(i) \
262370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
263370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i) \
264370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i) \
265370b324cSopenharmony_ci  )
266370b324cSopenharmony_ci
267370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_2(i1, i2) \
268370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
269370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
270370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
271370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
272370b324cSopenharmony_ci  )
273370b324cSopenharmony_ci
274370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_3(i1, i2, i3) \
275370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
276370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
277370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
278370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
279370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i3) \
280370b324cSopenharmony_ci  )
281370b324cSopenharmony_ci
282370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_4(i1, i2, i3, i4) \
283370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
284370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
285370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
286370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
287370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i3) \
288370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i4) \
289370b324cSopenharmony_ci  )
290370b324cSopenharmony_ci
291370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_5(i1, i2, i3, i4, i5) \
292370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
293370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
294370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
295370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
296370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i3) \
297370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i4) \
298370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i5) \
299370b324cSopenharmony_ci  )
300370b324cSopenharmony_ci
301370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_6(i1, i2, i3, i4, i5, i6) \
302370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
303370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
304370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
305370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
306370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i3) \
307370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i4) \
308370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i5) \
309370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i6) \
310370b324cSopenharmony_ci  )
311370b324cSopenharmony_ci
312370b324cSopenharmony_ci#define Z7_COM_UNKNOWN_IMP_7(i1, i2, i3, i4, i5, i6, i7) \
313370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_SPEC( \
314370b324cSopenharmony_ci  Z7_COM_QI_ENTRY_UNKNOWN(i1) \
315370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i1) \
316370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i2) \
317370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i3) \
318370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i4) \
319370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i5) \
320370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i6) \
321370b324cSopenharmony_ci  Z7_COM_QI_ENTRY(i7) \
322370b324cSopenharmony_ci  )
323370b324cSopenharmony_ci
324370b324cSopenharmony_ci
325370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_1(i1) \
326370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_1(i1) \
327370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
328370b324cSopenharmony_ci
329370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_2(i1, i2) \
330370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_2(i1, i2) \
331370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
332370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
333370b324cSopenharmony_ci
334370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_3(i1, i2, i3) \
335370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_3(i1, i2, i3) \
336370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
337370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
338370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
339370b324cSopenharmony_ci
340370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_4(i1, i2, i3, i4) \
341370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_4(i1, i2, i3, i4) \
342370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
343370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
344370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
345370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i4) \
346370b324cSopenharmony_ci
347370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_5(i1, i2, i3, i4, i5) \
348370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_5(i1, i2, i3, i4, i5) \
349370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
350370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
351370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
352370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i4) \
353370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i5) \
354370b324cSopenharmony_ci
355370b324cSopenharmony_ci#define Z7_IFACES_IMP_UNK_6(i1, i2, i3, i4, i5, i6) \
356370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_6(i1, i2, i3, i4, i5, i6) \
357370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
358370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
359370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
360370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i4) \
361370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i5) \
362370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i6) \
363370b324cSopenharmony_ci
364370b324cSopenharmony_ci
365370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_0(c) \
366370b324cSopenharmony_ci  Z7_class_final(c) : \
367370b324cSopenharmony_ci  public IUnknown, \
368370b324cSopenharmony_ci  public CMyUnknownImp { \
369370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_0 \
370370b324cSopenharmony_ci  private:
371370b324cSopenharmony_ci
372370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_1(c, i1) \
373370b324cSopenharmony_ci  Z7_class_final(c) : \
374370b324cSopenharmony_ci  public i1, \
375370b324cSopenharmony_ci  public CMyUnknownImp { \
376370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_1(i1) \
377370b324cSopenharmony_ci  private:
378370b324cSopenharmony_ci
379370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_2(c, i1, i2) \
380370b324cSopenharmony_ci  Z7_class_final(c) : \
381370b324cSopenharmony_ci  public i1, \
382370b324cSopenharmony_ci  public i2, \
383370b324cSopenharmony_ci  public CMyUnknownImp { \
384370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_2(i1, i2) \
385370b324cSopenharmony_ci  private:
386370b324cSopenharmony_ci
387370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_3(c, i1, i2, i3) \
388370b324cSopenharmony_ci  Z7_class_final(c) : \
389370b324cSopenharmony_ci  public i1, \
390370b324cSopenharmony_ci  public i2, \
391370b324cSopenharmony_ci  public i3, \
392370b324cSopenharmony_ci  public CMyUnknownImp { \
393370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_3(i1, i2, i3) \
394370b324cSopenharmony_ci  private:
395370b324cSopenharmony_ci
396370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_4(c, i1, i2, i3, i4) \
397370b324cSopenharmony_ci  Z7_class_final(c) : \
398370b324cSopenharmony_ci  public i1, \
399370b324cSopenharmony_ci  public i2, \
400370b324cSopenharmony_ci  public i3, \
401370b324cSopenharmony_ci  public i4, \
402370b324cSopenharmony_ci  public CMyUnknownImp { \
403370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_4(i1, i2, i3, i4) \
404370b324cSopenharmony_ci  private:
405370b324cSopenharmony_ci
406370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_5(c, i1, i2, i3, i4, i5) \
407370b324cSopenharmony_ci  Z7_class_final(c) : \
408370b324cSopenharmony_ci  public i1, \
409370b324cSopenharmony_ci  public i2, \
410370b324cSopenharmony_ci  public i3, \
411370b324cSopenharmony_ci  public i4, \
412370b324cSopenharmony_ci  public i5, \
413370b324cSopenharmony_ci  public CMyUnknownImp { \
414370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_5(i1, i2, i3, i4, i5) \
415370b324cSopenharmony_ci  private:
416370b324cSopenharmony_ci
417370b324cSopenharmony_ci#define Z7_CLASS_IMP_COM_6(c, i1, i2, i3, i4, i5, i6) \
418370b324cSopenharmony_ci  Z7_class_final(c) : \
419370b324cSopenharmony_ci  public i1, \
420370b324cSopenharmony_ci  public i2, \
421370b324cSopenharmony_ci  public i3, \
422370b324cSopenharmony_ci  public i4, \
423370b324cSopenharmony_ci  public i5, \
424370b324cSopenharmony_ci  public i6, \
425370b324cSopenharmony_ci  public CMyUnknownImp { \
426370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_6(i1, i2, i3, i4, i5, i6) \
427370b324cSopenharmony_ci  private:
428370b324cSopenharmony_ci
429370b324cSopenharmony_ci
430370b324cSopenharmony_ci/*
431370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_0(c) \
432370b324cSopenharmony_ci  Z7_class_final(c) : \
433370b324cSopenharmony_ci  public IUnknown, \
434370b324cSopenharmony_ci  public CMyUnknownImp { \
435370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_0 \
436370b324cSopenharmony_ci  private:
437370b324cSopenharmony_ci*/
438370b324cSopenharmony_ci
439370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_1(c, i1) \
440370b324cSopenharmony_ci  Z7_class_final(c) : \
441370b324cSopenharmony_ci  public i1, \
442370b324cSopenharmony_ci  public CMyUnknownImp { \
443370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_0 \
444370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
445370b324cSopenharmony_ci  private:
446370b324cSopenharmony_ci
447370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_2(c, i1, i2) \
448370b324cSopenharmony_ci  Z7_class_final(c) : \
449370b324cSopenharmony_ci  public i1, \
450370b324cSopenharmony_ci  public i2, \
451370b324cSopenharmony_ci  public CMyUnknownImp { \
452370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_1(i2) \
453370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
454370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
455370b324cSopenharmony_ci  private:
456370b324cSopenharmony_ci
457370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_3(c, i1, i2, i3) \
458370b324cSopenharmony_ci  Z7_class_final(c) : \
459370b324cSopenharmony_ci  public i1, \
460370b324cSopenharmony_ci  public i2, \
461370b324cSopenharmony_ci  public i3, \
462370b324cSopenharmony_ci  public CMyUnknownImp { \
463370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_2(i2, i3) \
464370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
465370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
466370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
467370b324cSopenharmony_ci  private:
468370b324cSopenharmony_ci
469370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_4(c, i1, i2, i3, i4) \
470370b324cSopenharmony_ci  Z7_class_final(c) : \
471370b324cSopenharmony_ci  public i1, \
472370b324cSopenharmony_ci  public i2, \
473370b324cSopenharmony_ci  public i3, \
474370b324cSopenharmony_ci  public i4, \
475370b324cSopenharmony_ci  public CMyUnknownImp { \
476370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_3(i2, i3, i4) \
477370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
478370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
479370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
480370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i4) \
481370b324cSopenharmony_ci
482370b324cSopenharmony_ci/*
483370b324cSopenharmony_ci#define Z7_CLASS_IMP_NOQIB_5(c, i1, i2, i3, i4, i5) \
484370b324cSopenharmony_ci  Z7_class_final(c) : \
485370b324cSopenharmony_ci  public i1, \
486370b324cSopenharmony_ci  public i2, \
487370b324cSopenharmony_ci  public i3, \
488370b324cSopenharmony_ci  public i4, \
489370b324cSopenharmony_ci  public i5, \
490370b324cSopenharmony_ci  public CMyUnknownImp { \
491370b324cSopenharmony_ci  Z7_COM_UNKNOWN_IMP_4(i2, i3, i4, i5) \
492370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i1) \
493370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i2) \
494370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i3) \
495370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i4) \
496370b324cSopenharmony_ci  Z7_IFACE_COM7_IMP(i5) \
497370b324cSopenharmony_ci*/
498370b324cSopenharmony_ci
499370b324cSopenharmony_ci
500370b324cSopenharmony_ci#define Z7_CLASS_IMP_IInStream(c) \
501370b324cSopenharmony_ci  class c Z7_final : \
502370b324cSopenharmony_ci  public IInStream, \
503370b324cSopenharmony_ci  public CMyUnknownImp { \
504370b324cSopenharmony_ci  Z7_IFACES_IMP_UNK_2(ISequentialInStream, IInStream) \
505370b324cSopenharmony_ci
506370b324cSopenharmony_ci
507370b324cSopenharmony_ci#define k_My_HRESULT_WritingWasCut 0x20000010
508370b324cSopenharmony_ci
509370b324cSopenharmony_ci#endif
510