29 #ifndef YCL_MinGW32_INC_COMPtr_h_
30 #define YCL_MinGW32_INC_COMPtr_h_ 1
33 #include YFM_MinGW32_YCLib_MinGW32
50 : hResult(::CoInitialize(
nullptr))
71 : runtime_error(
"COMException"), hResult(h)
107 template<
class _iCOM>
110 template<
class _iOther>
126 template<
class _iOther>
131 template<
class _iOther>
144 template<
class _iOther>
146 std::is_convertible<_iOther*, _iCOM*>::value,
int> = 0)
ynothrow
157 template<
class _iOther>
159 std::is_convertible<_iOther*, _iCOM*>::value,
int> = 0)
ynothrow
162 ptr.pInterface =
nullptr;
213 return Get() !=
nullptr;
231 template<
class _iOther>
249 reinterpret_cast<void**>(&ptr.ReleaseAndGetRef()));
251 template<
class _iOther>
256 return pInterface->QueryInterface(__uuidof(_iOther),
257 reinterpret_cast<void**>(&ptr.ReleaseAndGetRef()));
283 template<
typename _type>
287 return pInterface->QueryInterface(__uuidof(_type),
288 reinterpret_cast<void**>(&p));
326 template<
class _iCOM1,
class _iCOM2>
330 static_assert(std::is_base_of<_iCOM1, _iCOM2>::value
331 || std::is_base_of<_iCOM1, _iCOM2>::value,
332 "'_iCOM1' and '_iCOM2' pointers must be comparable");
334 return x.Get() == y.Get();
336 template<
class _iCOM>
342 template<
class _iCOM>
349 template<
class _iCOM1,
class _iCOM2>
355 template<
class _iCOM>
362 template<
class _iCOM>
369 template<
class _iCOM1,
class _iCOM2>
373 static_assert(std::is_base_of<_iCOM1, _iCOM2>::value
374 || std::is_base_of<_iCOM1, _iCOM2>::value,
375 "'_iCOM1' and '_iCOM2' pointers must be comparable");
377 return x.Get() < y.Get();
380 template<
class _iCOM>
384 if(
const auto p_interface = ptr.Get())
386 const auto ref(p_interface->Release());
389 yassume(ref != 0 || p_interface != p);
394 template<
class _iCOM>
400 ptr.GetRef() =
nullptr;
404 template<
class _iCOM>
410 if(
const auto tmp = ptr.Get())
412 ptr.GetRef() =
nullptr;
418 template<
class _iCOM>
419 inline DefSwap(
ynothrow, COMPtr<_iCOM>)
void InternalRelease() ynothrow
#define ynothrowv
YSLib 无异常抛出保证验证:有条件地使用无异常抛出规范。
#define yunused(...)
标记未使用的表达式。
COMPtr< _iOther > As() const ythrow(COMException)
_iCOM * Detach(COMPtr< _iCOM > &ptr) ynothrow
COMPtr(std::nullptr_t) ynothrow
COMPtr & operator=(std::nullptr_t) ynothrow
COMPtr(const COMPtr< _iOther > &ptr, ystdex::enable_if_t< std::is_convertible< _iOther *, _iCOM * >::value, int >=0) ynothrow
_iCOM *& ReleaseAndGetRef() ynothrow
const class ystdex::nullptr_t nullptr
::HRESULT CopyTo(REFIID riid, void **ptr) const ynothrow
void EnsureNonNull(void *p) ythrow(COMException)
检查指针值,若为空则抛出 COMException 。
#define DefGetter(_q, _t, _n,...)
void swap(any &x, any &y)
交换对象。
COMPtr & operator=(_iCOM *p) ynothrow
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
COMPtr(_iOther *ptr) ynothrow
#define ythrow(...)
YSLib 动态异常规范:根据是否使用异常规范宏指定或忽略动态异常规范。
#define yconstraint
约束:接口语义。
_iCOM EnsureNonNull(pInterface)
bool operator!=(const COMPtr< _iCOM1 > &x, const COMPtr< _iCOM2 > &y) ynothrow
_iCOM & operator*() const ynothrowv
COMException(::HRESULT h)
void Attach(COMPtr< _iCOM > &ptr, typename COMPtr< _iCOM >::InterfaceType *p) ynothrow
unsigned long Reset(COMPtr< _iCOM > &ptr) ynothrow
_iCOM * operator->() const ynothrow
::HRESULT Cast(REFIID riid, COMPtr< IUnknown > &ptr) const ynothrow
::HRESULT CopyTo(_type *&p) const ynothrow
void InternalAddRef() const ynothrow
COMPtr(COMPtr &&ptr) ynothrow
bool operator==(const COMPtr< _iCOM1 > &x, const COMPtr< _iCOM2 > &y) ynothrow
InterfaceType * Copy() const ynothrow
COMPtr & operator=(const COMPtr &ptr) ynothrow
::HRESULT Cast(COMPtr< _iOther > &ptr) const ynothrow
DefGetter(const ynothrow, _iCOM *,, pInterface) DefGetter(const
COMPtr(_iOther &intf, ystdex::enable_if_t<!std::is_convertible< _iOther &, COMPtr & >::value, int >=0) ynothrow
void * Copy(REFIID riid) const ythrow(COMException)
InterfaceType * pInterface
COMPtr & operator=(COMPtr &&ptr) ynothrow
COMPtr(const COMPtr &ptr) ynothrow
COMPtr(COMPtr< _iOther > &&ptr, ystdex::enable_if_t< std::is_convertible< _iOther *, _iCOM * >::value, int >=0) ynothrow
typename enable_if< _bCond, _type >::type enable_if_t
inline::HRESULT CheckHResult(::HRESULT h) ythrow(COMException)
检查 ::HRESULT 值,若表示失败则抛出 COMException 。
void swap(COMPtr &ptr) ynothrow