From 615f2ccd2fd34f46316458a476a432619cd874ff Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Mon, 19 Jun 2017 14:52:51 +0000 Subject: [PATCH] [ATL] -Add a new template called CComQIIDPtr and its partner I_ID macro. Its purpose is to be a gcc compatible version of CComQIPtr. -CComQIIDPtr is the gcc compatible version of CComQIPtr - WARNING: this is not tested yet. svn path=/trunk/; revision=75129 --- reactos/sdk/lib/atl/atlcomcli.h | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/reactos/sdk/lib/atl/atlcomcli.h b/reactos/sdk/lib/atl/atlcomcli.h index b7b8d0b0582..9c19e3371c4 100644 --- a/reactos/sdk/lib/atl/atlcomcli.h +++ b/reactos/sdk/lib/atl/atlcomcli.h @@ -149,6 +149,66 @@ public: }; +//CComQIIDPtr is the gcc compatible version of CComQIPtr +#define I_ID(Itype) Itype,IID_##Itype + +template +class CComQIIDPtr : + public CComPtr +{ +public: + CComQIIDPtr() + { + } + CComQIIDPtr(_Inout_opt_ T* lp) : + CComPtr(lp) + { + } + CComQIIDPtr(_Inout_ const CComQIIDPtr& lp): + CComPtr(lp.p) + { + } + CComQIIDPtr(_Inout_opt_ IUnknown* lp) + { + if (lp != NULL) + { + if (FAILED(lp->QueryInterface(*piid, (void **)&this.p))) + this.p = NULL; + } + } + T *operator = (T *lp) + { + if (this.p != NULL) + this.p->Release(); + this.p = lp; + if (this.p != NULL) + this.p->AddRef(); + return *this; + } + + T *operator = (const CComQIIDPtr &lp) + { + if (this.p != NULL) + this.p->Release(); + this.p = lp.p; + if (this.p != NULL) + this.p->AddRef(); + return *this; + } + + T * operator=(IUnknown* lp) + { + if (this.p != NULL) + this.p->Release(); + + if (FAILED(lp->QueryInterface(*piid, (void **)&this.p))) + this.p = NULL; + + return *this; + } +}; + + class CComBSTR { public: -- 2.17.1