COM.h
/*
SPDX-License-Identifier: MIT
Copyright © 1991-2022 Amebis
Copyright © 2016 GÉANT
*/
#pragma once
#include "Common.h"
#include <unknwn.h>
#include <string>
namespace winstd
{
class com_runtime_error : public num_runtime_error<HRESULT>
{
public:
com_runtime_error(_In_ error_type num, _In_ const std::string& msg) : num_runtime_error<HRESULT>(num, msg)
{
}
com_runtime_error(_In_ error_type num, _In_opt_z_ const char *msg = nullptr) : num_runtime_error<HRESULT>(num, msg)
{
}
};
struct CoTaskMemFree_delete
{
CoTaskMemFree_delete() noexcept {}
template <class _T>
void operator()(_T *_Ptr) const
{
CoTaskMemFree(_Ptr);
}
};
template <class T>
class com_obj : public dplhandle<T*, NULL>
{
WINSTD_DPLHANDLE_IMPL(com_obj, NULL)
public:
com_obj(_In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
{
CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (LPVOID*)&m_h);
}
template <class _Other>
com_obj(_In_ _Other *other)
{
assert(other);
other->QueryInterface(__uuidof(T), (void**)&m_h);
}
template <class _Other>
com_obj(_In_ com_obj<_Other> &other)
{
other->QueryInterface(__uuidof(T), (void**)&m_h);
}
virtual ~com_obj()
{
if (m_h != invalid)
free_internal();
}
HRESULT create(_In_ REFCLSID rclsid, _In_opt_ LPUNKNOWN pUnkOuter = NULL, _In_ DWORD dwClsContext = CLSCTX_ALL)
{
handle_type h;
HRESULT hr = CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&h);
if (SUCCEEDED(hr))
attach(h);
return hr;
}
template <class _Other>
HRESULT query_interface(_Out_ _Other **h) const
{
assert(h);
assert(m_h);
return m_h->QueryInterface(__uuidof(_Other), (void**)h);
}
template <class _Other>
HRESULT query_interface(_Out_ com_obj<_Other> &h) const
{
assert(m_h);
_Other *_h;
HRESULT hr = m_h->QueryInterface(__uuidof(_Other), (void**)&_h);
if (SUCCEEDED(hr))
h.attach(_h);
return hr;
}
protected:
void free_internal() noexcept override
{
m_h->Release();
}
handle_type duplicate_internal(_In_ handle_type h) const noexcept override
{
h->AddRef();
return h;
}
};
class bstr : public dplhandle<BSTR, NULL>
{
WINSTD_DPLHANDLE_IMPL(bstr, NULL)
public:
bstr(_In_ LPCOLESTR src) noexcept
{
m_h = SysAllocString(src);
}
bstr(_In_ LPCOLESTR src, _In_ UINT len) noexcept
{
m_h = SysAllocStringLen(src, len);
}
template<class _Traits, class _Ax>
bstr(_In_ const std::basic_string<wchar_t, _Traits, _Ax> &src) noexcept
{
m_h = SysAllocStringLen(src.c_str(), (UINT)src.length());
}
virtual ~bstr()
{
if (m_h != invalid)
free_internal();
}
UINT length() const noexcept
{
return SysStringLen(m_h);
}
protected:
void free_internal() noexcept override
{
SysFreeString(m_h);
}
handle_type duplicate_internal(_In_ handle_type h) const noexcept override
{
return SysAllocStringLen(h, SysStringLen(h));
}
};
#pragma warning(push)
#pragma warning(disable: 26432) // Copy constructor and assignment operator are also present, but not detected by code analysis as they are using base type source object reference.
class variant : public VARIANT
{
public:
variant() noexcept
{
VariantInit(this);
}
variant(_In_ const VARIANT& varSrc)
{
vt = VT_EMPTY;
const HRESULT hr = VariantCopy(this, &varSrc);
if (FAILED(hr))
throw winstd::com_runtime_error(hr, "VariantCopy failed.");
}
#pragma warning(suppress: 26495) // vt member is initialized as a result of memcpy()
variant(_Inout_ VARIANT&& varSrc) noexcept
{
memcpy(this, &varSrc, sizeof(VARIANT));
varSrc.vt = VT_EMPTY;
}
variant(_In_ bool bSrc) noexcept
{
vt = VT_BOOL;
boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
}
variant(_In_ char cSrc) noexcept
{
vt = VT_I1;
cVal = cSrc;
}
variant(_In_ unsigned char nSrc) noexcept
{
vt = VT_UI1;
bVal = nSrc;
}
variant(_In_ short nSrc) noexcept
{
vt = VT_I2;
iVal = nSrc;
}
variant(_In_ unsigned short nSrc) noexcept
{
vt = VT_UI2;
uiVal = nSrc;
}
variant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
{
assert(vtSrc == VT_I4 || vtSrc == VT_INT);
vt = vtSrc;
intVal = nSrc;
}
variant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) noexcept
{
assert(vtSrc == VT_UI4 || vtSrc == VT_UINT);
vt = vtSrc;
uintVal= nSrc;
}
variant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) noexcept
{
assert(vtSrc == VT_I4 || vtSrc == VT_ERROR);
vt = vtSrc;
lVal = nSrc;
}
variant(_In_ unsigned long nSrc) noexcept
{
vt = VT_UI4;
ulVal = nSrc;
}
variant(_In_ float fltSrc) noexcept
{
vt = VT_R4;
fltVal = fltSrc;
}
variant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) noexcept
{
assert(vtSrc == VT_R8 || vtSrc == VT_DATE);
vt = vtSrc;
dblVal = dblSrc;
}
variant(_In_ long long nSrc) noexcept
{
vt = VT_I8;
llVal = nSrc;
}
variant(_In_ unsigned long long nSrc) noexcept
{
vt = VT_UI8;
ullVal = nSrc;
}
variant(_In_ CY cySrc) noexcept
{
vt = VT_CY;
cyVal.Hi = cySrc.Hi;
cyVal.Lo = cySrc.Lo;
}
variant(_In_z_ LPCOLESTR lpszSrc) noexcept
{
vt = VT_EMPTY;
*this = lpszSrc;
}
variant(_In_z_ BSTR bstr) noexcept
{
vt = VT_EMPTY;
*this = bstr;
}
variant(_In_opt_ IDispatch* pSrc)
{
vt = VT_DISPATCH;
pdispVal = pSrc;
if (pdispVal != NULL)
pdispVal->AddRef();
}
variant(_In_opt_ IUnknown* pSrc)
{
vt = VT_UNKNOWN;
punkVal = pSrc;
if (punkVal != NULL)
punkVal->AddRef();
}
variant(_In_ const SAFEARRAY *pSrc)
{
assert(pSrc != NULL);
LPSAFEARRAY pCopy;
const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
if (FAILED(hr))
throw winstd::com_runtime_error(hr, "SafeArrayCopy failed.");
SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
vt |= VT_ARRAY;
parray = pCopy;
}
virtual ~variant()
{
VariantClear(this);
}
variant& operator=(_In_ const VARIANT& varSrc)
{
if (this != &varSrc) {
const HRESULT hr = VariantCopy(this, &varSrc);
if (FAILED(hr))
throw winstd::com_runtime_error(hr, "VariantCopy failed.");
}
return *this;
}
variant& operator=(_Inout_ VARIANT&& varSrc) noexcept
{
if (this != &varSrc) {
VariantClear(this);
memcpy(this, &varSrc, sizeof(VARIANT));
varSrc.vt = VT_EMPTY;
}
return *this;
}
variant& operator=(_In_ bool bSrc) noexcept
{
if (vt != VT_BOOL) {
VariantClear(this);
vt = VT_BOOL;
}
boolVal = bSrc ? VARIANT_TRUE : VARIANT_FALSE;
return *this;
}
variant& operator=(_In_ char cSrc) noexcept
{
if (vt != VT_I1) {
VariantClear(this);
vt = VT_I1;
}
cVal = cSrc;
return *this;
}
variant& operator=(_In_ unsigned char nSrc) noexcept
{
if (vt != VT_UI1) {
VariantClear(this);
vt = VT_UI1;
}
bVal = nSrc;
return *this;
}
variant& operator=(_In_ short nSrc) noexcept
{
if (vt != VT_I2) {
VariantClear(this);
vt = VT_I2;
}
iVal = nSrc;
return *this;
}
variant& operator=(_In_ unsigned short nSrc) noexcept
{
if (vt != VT_UI2) {
VariantClear(this);
vt = VT_UI2;
}
uiVal = nSrc;
return *this;
}
variant& operator=(_In_ int nSrc) noexcept
{
if (vt != VT_I4) {
VariantClear(this);
vt = VT_I4;
}
intVal = nSrc;
return *this;
}
variant& operator=(_In_ unsigned int nSrc) noexcept
{
if (vt != VT_UI4) {
VariantClear(this);
vt = VT_UI4;
}
uintVal= nSrc;
return *this;
}
variant& operator=(_In_ long nSrc) noexcept
{
if (vt != VT_I4) {
VariantClear(this);
vt = VT_I4;
}
lVal = nSrc;
return *this;
}
variant& operator=(_In_ unsigned long nSrc) noexcept
{
if (vt != VT_UI4) {
VariantClear(this);
vt = VT_UI4;
}
ulVal = nSrc;
return *this;
}
variant& operator=(_In_ long long nSrc) noexcept
{
if (vt != VT_I8) {
VariantClear(this);
vt = VT_I8;
}
llVal = nSrc;
return *this;
}
variant& operator=(_In_ unsigned long long nSrc) noexcept
{
if (vt != VT_UI8) {
VariantClear(this);
vt = VT_UI8;
}
ullVal = nSrc;
return *this;
}
variant& operator=(_In_ float fltSrc) noexcept
{
if (vt != VT_R4) {
VariantClear(this);
vt = VT_R4;
}
fltVal = fltSrc;
return *this;
}
variant& operator=(_In_ double dblSrc) noexcept
{
if (vt != VT_R8) {
VariantClear(this);
vt = VT_R8;
}
dblVal = dblSrc;
return *this;
}
variant& operator=(_In_ CY cySrc) noexcept
{
if (vt != VT_CY) {
VariantClear(this);
vt = VT_CY;
}
cyVal.Hi = cySrc.Hi;
cyVal.Lo = cySrc.Lo;
return *this;
}
variant& operator=(_In_z_ LPCOLESTR lpszSrc) noexcept
{
VariantClear(this);
vt = VT_BSTR;
bstrVal = SysAllocString(lpszSrc);
return *this;
}
variant& operator=(_Inout_opt_ IDispatch* pSrc)
{
VariantClear(this);
vt = VT_DISPATCH;
pdispVal = pSrc;
if (pdispVal != NULL)
pdispVal->AddRef();
return *this;
}
variant& operator=(_Inout_opt_ IUnknown* pSrc)
{
VariantClear(this);
vt = VT_UNKNOWN;
punkVal = pSrc;
if (punkVal != NULL)
punkVal->AddRef();
return *this;
}
variant& operator=(_In_ unsigned char* pbSrc) noexcept
{
if (vt != (VT_UI1|VT_BYREF)) {
VariantClear(this);
vt = VT_UI1|VT_BYREF;
}
pbVal = pbSrc;
return *this;
}
variant& operator=(_In_ short* pnSrc) noexcept
{
if (vt != (VT_I2|VT_BYREF)) {
VariantClear(this);
vt = VT_I2|VT_BYREF;
}
piVal = pnSrc;
return *this;
}
variant& operator=(_In_ unsigned short* pnSrc) noexcept
{
if (vt != (VT_UI2|VT_BYREF)) {
VariantClear(this);
vt = VT_UI2|VT_BYREF;
}
puiVal = pnSrc;
return *this;
}
variant& operator=(_In_ int* pnSrc) noexcept
{
if (vt != (VT_I4|VT_BYREF)) {
VariantClear(this);
vt = VT_I4|VT_BYREF;
}
pintVal = pnSrc;
return *this;
}
variant& operator=(_In_ unsigned int* pnSrc) noexcept
{
if (vt != (VT_UI4|VT_BYREF)) {
VariantClear(this);
vt = VT_UI4|VT_BYREF;
}
puintVal = pnSrc;
return *this;
}
variant& operator=(_In_ long* pnSrc) noexcept
{
if (vt != (VT_I4|VT_BYREF)) {
VariantClear(this);
vt = VT_I4|VT_BYREF;
}
plVal = pnSrc;
return *this;
}
variant& operator=(_In_ unsigned long* pnSrc) noexcept
{
if (vt != (VT_UI4|VT_BYREF)) {
VariantClear(this);
vt = VT_UI4|VT_BYREF;
}
pulVal = pnSrc;
return *this;
}
variant& operator=(_In_ long long* pnSrc) noexcept
{
if (vt != (VT_I8|VT_BYREF)) {
VariantClear(this);
vt = VT_I8|VT_BYREF;
}
pllVal = pnSrc;
return *this;
}
variant& operator=(_In_ unsigned long long* pnSrc) noexcept
{
if (vt != (VT_UI8|VT_BYREF)) {
VariantClear(this);
vt = VT_UI8|VT_BYREF;
}
pullVal = pnSrc;
return *this;
}
variant& operator=(_In_ float* pfSrc) noexcept
{
if (vt != (VT_R4|VT_BYREF)) {
VariantClear(this);
vt = VT_R4|VT_BYREF;
}
pfltVal = pfSrc;
return *this;
}
variant& operator=(_In_ double* pfSrc) noexcept
{
if (vt != (VT_R8|VT_BYREF)) {
VariantClear(this);
vt = VT_R8|VT_BYREF;
}
pdblVal = pfSrc;
return *this;
}
variant& operator=(_In_ const SAFEARRAY *pSrc) noexcept
{
assert(pSrc != NULL);
VariantClear(this);
LPSAFEARRAY pCopy;
const HRESULT hr = SafeArrayCopy(const_cast<LPSAFEARRAY>(pSrc), &pCopy);
if (SUCCEEDED(hr)) {
SafeArrayGetVartype(const_cast<LPSAFEARRAY>(pSrc), &vt);
vt |= VT_ARRAY;
parray = pCopy;
} else
assert(0);
return *this;
}
public:
bool operator==(_In_ const VARIANT& varSrc) const noexcept
{
if (vt == VT_NULL && varSrc.vt == VT_NULL) return true;
if (vt != varSrc.vt) return false;
return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0) == static_cast<HRESULT>(VARCMP_EQ);
}
bool operator!=(_In_ const VARIANT& varSrc) const noexcept
{
return !operator==(varSrc);
}
bool operator<(_In_ const VARIANT& varSrc) const noexcept
{
if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_LT);
}
bool operator>(_In_ const VARIANT& varSrc) const noexcept
{
if (vt == VT_NULL && varSrc.vt == VT_NULL) return false;
return compare(static_cast<const VARIANT&>(*this), varSrc, LOCALE_USER_DEFAULT, 0)== static_cast<HRESULT>(VARCMP_GT);
}
bool operator<=(_In_ const VARIANT& varSrc) const noexcept
{
return !operator>(varSrc);
}
bool operator>=(_In_ const VARIANT& varSrc) const noexcept
{
return !operator<(varSrc);
}
HRESULT change_type(_In_ VARTYPE _vt, _In_opt_ USHORT wFlags = 0) noexcept
{
return VariantChangeType(this, this, wFlags, _vt);
}
private:
HRESULT compare(_In_ const VARIANT &varLeft, _In_ const VARIANT &varRight, _In_ LCID lcid, _In_ ULONG dwFlags) const noexcept
{
switch(vt) {
case VT_I1: return varLeft.cVal == varRight.cVal ? VARCMP_EQ : varLeft.cVal > varRight.cVal ? VARCMP_GT : VARCMP_LT;
case VT_UI2: return varLeft.uiVal == varRight.uiVal ? VARCMP_EQ : varLeft.uiVal > varRight.uiVal ? VARCMP_GT : VARCMP_LT;
case VT_UI4: return varLeft.uintVal == varRight.uintVal ? VARCMP_EQ : varLeft.uintVal > varRight.uintVal ? VARCMP_GT : VARCMP_LT;
case VT_UI8: return varLeft.ullVal == varRight.ullVal ? VARCMP_EQ : varLeft.ullVal > varRight.ullVal ? VARCMP_GT : VARCMP_LT;
default: return VarCmp(const_cast<LPVARIANT>(&varLeft), const_cast<LPVARIANT>(&varRight), lcid, dwFlags);
}
}
};
#pragma warning(pop)
class com_initializer
{
WINSTD_NONCOPYABLE(com_initializer)
WINSTD_NONMOVABLE(com_initializer)
public:
com_initializer(_In_opt_ LPVOID pvReserved) noexcept
{
m_result = CoInitialize(pvReserved);
}
com_initializer(_In_opt_ LPVOID pvReserved, _In_ DWORD dwCoInit) noexcept
{
m_result = CoInitializeEx(pvReserved, dwCoInit);
}
virtual ~com_initializer()
{
if (SUCCEEDED(m_result))
CoUninitialize();
}
HRESULT status() const noexcept
{
return m_result;
}
protected:
HRESULT m_result;
};
}
winstd::bstr
BSTR string wrapper.
Definition: COM.h:202
winstd::bstr::bstr
bstr(LPCOLESTR src) noexcept
Constructs BSTR from OLE string.
Definition: COM.h:209
winstd::bstr::~bstr
virtual ~bstr()
Destroys the string.
Definition: COM.h:236
winstd::bstr::duplicate_internal
handle_type duplicate_internal(handle_type h) const noexcept override
Duplicates the string.
Definition: COM.h:272
winstd::bstr::bstr
bstr(const std::basic_string< wchar_t, _Traits, _Ax > &src) noexcept
Constructs BSTR from std::basic_string.
Definition: COM.h:226
winstd::bstr::bstr
bstr(LPCOLESTR src, UINT len) noexcept
Constructs BSTR from OLE string with length.
Definition: COM.h:217
winstd::bstr::free_internal
void free_internal() noexcept override
Destroys the string.
Definition: COM.h:258
winstd::bstr::length
UINT length() const noexcept
Returns the length of the string.
Definition: COM.h:247
winstd::com_initializer
Context scope automatic COM (un)initialization.
Definition: COM.h:1036
winstd::com_initializer::com_initializer
com_initializer(LPVOID pvReserved, DWORD dwCoInit) noexcept
Initializes the COM library for use by the calling thread, sets the thread's concurrency model,...
Definition: COM.h:1056
winstd::com_initializer::com_initializer
com_initializer(LPVOID pvReserved) noexcept
Initializes the COM library on the current thread and identifies the concurrency model as single-thre...
Definition: COM.h:1046
winstd::com_initializer::status
HRESULT status() const noexcept
Return result of CoInitialize() call.
Definition: COM.h:1077
winstd::com_initializer::~com_initializer
virtual ~com_initializer()
Uninitializes COM.
Definition: COM.h:1066
winstd::com_initializer::m_result
HRESULT m_result
Result of CoInitialize call.
Definition: COM.h:1083
winstd::com_obj
COM object wrapper template.
Definition: COM.h:82
winstd::com_obj::free_internal
void free_internal() noexcept override
Releases the object by decrementing reference counter.
Definition: COM.h:177
winstd::com_obj::duplicate_internal
handle_type duplicate_internal(handle_type h) const noexcept override
Duplicates the object by incrementing the reference counter.
Definition: COM.h:191
winstd::com_obj::query_interface
HRESULT query_interface(_Other **h) const
Queries the object for another interface.
Definition: COM.h:148
winstd::com_obj::create
HRESULT create(REFCLSID rclsid, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL)
Creates a new object.
Definition: COM.h:133
winstd::com_obj::query_interface
HRESULT query_interface(com_obj< _Other > &h) const
Queries the object for another interface.
Definition: COM.h:161
winstd::com_obj::~com_obj
virtual ~com_obj()
Releases object.
Definition: COM.h:122
winstd::com_obj::com_obj
com_obj(_Other *other)
Queries the object for another interface and creates new class with it.
Definition: COM.h:102
winstd::com_obj::com_obj
com_obj(REFCLSID rclsid, LPUNKNOWN pUnkOuter=NULL, DWORD dwClsContext=CLSCTX_ALL)
Constructs a new object and creates a new class with it.
Definition: COM.h:91
winstd::com_obj::com_obj
com_obj(com_obj< _Other > &other)
Queries the object for another interface and creates new class with it.
Definition: COM.h:114
winstd::com_runtime_error
COM runtime error.
Definition: COM.h:24
winstd::com_runtime_error::com_runtime_error
com_runtime_error(error_type num, const std::string &msg)
Constructs an exception.
Definition: COM.h:32
winstd::com_runtime_error::com_runtime_error
com_runtime_error(error_type num, const char *msg=nullptr)
Constructs an exception.
Definition: COM.h:42
winstd::dplhandle
Base abstract template class to support object handle keeping for objects that support handle duplica...
Definition: Common.h:866
winstd::handle< T *, INVAL >::handle_type
T * handle_type
Datatype of the object handle this template class handles.
Definition: Common.h:609
winstd::handle< T *, INVAL >::m_h
handle_type m_h
Object handle.
Definition: Common.h:855
winstd::handle< T *, INVAL >::attach
void attach(handle_type h) noexcept
Sets a new object handle for the class.
Definition: Common.h:818
winstd::num_runtime_error
Numerical runtime error.
Definition: Common.h:1003
winstd::num_runtime_error< HRESULT >::error_type
HRESULT error_type
Error number type.
Definition: Common.h:1005
winstd::variant
VARIANT struct wrapper.
Definition: COM.h:284
winstd::variant::operator<=
bool operator<=(const VARIANT &varSrc) const noexcept
Is variant less than or equal to?
Definition: COM.h:988
winstd::variant::variant
variant(bool bSrc) noexcept
Constructs VARIANT from bool.
Definition: COM.h:318
winstd::variant::operator=
variant & operator=(unsigned int nSrc) noexcept
Copy from unsigned int value.
Definition: COM.h:620
winstd::variant::operator=
variant & operator=(unsigned long nSrc) noexcept
Copy from unsigned long value.
Definition: COM.h:646
winstd::variant::variant
variant(float fltSrc) noexcept
Constructs VARIANT from float.
Definition: COM.h:402
winstd::variant::variant
variant(VARIANT &&varSrc) noexcept
Moves VARIANT from another.
Definition: COM.h:309
winstd::variant::operator=
variant & operator=(float fltSrc) noexcept
Copy from float value.
Definition: COM.h:686
winstd::variant::operator=
variant & operator=(float *pfSrc) noexcept
Copy from float reference.
Definition: COM.h:880
winstd::variant::variant
variant(IDispatch *pSrc)
Constructs VARIANT from IDispatch.
Definition: COM.h:467
winstd::variant::variant
variant(int nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from integer.
Definition: COM.h:363
winstd::variant::variant
variant(const SAFEARRAY *pSrc)
Constructs VARIANT from SAFEARRAY.
Definition: COM.h:491
winstd::variant::operator=
variant & operator=(double *pfSrc) noexcept
Copy from double reference.
Definition: COM.h:893
winstd::variant::operator=
variant & operator=(int *pnSrc) noexcept
Copy from int reference.
Definition: COM.h:802
winstd::variant::operator>
bool operator>(const VARIANT &varSrc) const noexcept
Is variant greater than?
Definition: COM.h:974
winstd::variant::operator=
variant & operator=(bool bSrc) noexcept
Copy from bool value.
Definition: COM.h:542
winstd::variant::operator=
variant & operator=(long nSrc) noexcept
Copy from long value.
Definition: COM.h:633
winstd::variant::operator=
variant & operator=(const SAFEARRAY *pSrc) noexcept
Copy from SAFEARRAY.
Definition: COM.h:906
winstd::variant::change_type
HRESULT change_type(VARTYPE _vt, USHORT wFlags=0) noexcept
Converts a variant from one type to another.
Definition: COM.h:1011
winstd::variant::operator=
variant & operator=(IUnknown *pSrc)
Copy from IUnknown.
Definition: COM.h:750
winstd::variant::operator=
variant & operator=(short nSrc) noexcept
Copy from short value.
Definition: COM.h:581
winstd::variant::operator=
variant & operator=(unsigned char *pbSrc) noexcept
Copy from unsigned char reference.
Definition: COM.h:763
winstd::variant::operator=
variant & operator=(unsigned short nSrc) noexcept
Copy from unsigned short value.
Definition: COM.h:594
winstd::variant::operator=
variant & operator=(unsigned char nSrc) noexcept
Copy from unsigned char value.
Definition: COM.h:568
winstd::variant::operator=
variant & operator=(char cSrc) noexcept
Copy from char value.
Definition: COM.h:555
winstd::variant::variant
variant(LPCOLESTR lpszSrc) noexcept
Constructs VARIANT from OLE string.
Definition: COM.h:449
winstd::variant::~variant
virtual ~variant()
Destroys VARIANT.
Definition: COM.h:508
winstd::variant::variant
variant(const VARIANT &varSrc)
Constructs VARIANT from another.
Definition: COM.h:297
winstd::variant::variant
variant(unsigned char nSrc) noexcept
Constructs VARIANT from byte.
Definition: COM.h:336
winstd::variant::operator=
variant & operator=(double dblSrc) noexcept
Copy from double value.
Definition: COM.h:699
winstd::variant::operator!=
bool operator!=(const VARIANT &varSrc) const noexcept
Is variant not equal to?
Definition: COM.h:947
winstd::variant::operator=
variant & operator=(int nSrc) noexcept
Copy from int value.
Definition: COM.h:607
winstd::variant::variant
variant(unsigned long nSrc) noexcept
Constructs VARIANT from unsigned long.
Definition: COM.h:393
winstd::variant::operator==
bool operator==(const VARIANT &varSrc) const noexcept
Is variant equal to?
Definition: COM.h:932
winstd::variant::variant
variant(IUnknown *pSrc)
Constructs VARIANT from IUnknown.
Definition: COM.h:479
winstd::variant::variant
variant(unsigned int nSrc, VARTYPE vtSrc=VT_UI4) noexcept
Constructs VARIANT from unsigned integer.
Definition: COM.h:373
winstd::variant::operator=
variant & operator=(CY cySrc) noexcept
Copy from CY value.
Definition: COM.h:712
winstd::variant::operator=
variant & operator=(LPCOLESTR lpszSrc) noexcept
Copy from OLE string value.
Definition: COM.h:726
winstd::variant::variant
variant(long long nSrc) noexcept
Constructs VARIANT from 64-bit integer.
Definition: COM.h:421
winstd::variant::operator=
variant & operator=(unsigned int *pnSrc) noexcept
Copy from unsigned int reference.
Definition: COM.h:815
winstd::variant::variant
variant(long nSrc, VARTYPE vtSrc=VT_I4) noexcept
Constructs VARIANT from long.
Definition: COM.h:383
winstd::variant::operator=
variant & operator=(long *pnSrc) noexcept
Copy from long reference.
Definition: COM.h:828
winstd::variant::variant
variant(unsigned short nSrc) noexcept
Constructs VARIANT from unsigned short.
Definition: COM.h:354
winstd::variant::operator>=
bool operator>=(const VARIANT &varSrc) const noexcept
Is variant greater than or equal to?
Definition: COM.h:1001
winstd::variant::operator=
variant & operator=(short *pnSrc) noexcept
Copy from short reference.
Definition: COM.h:776
winstd::variant::variant
variant() noexcept
Constructs blank VARIANT.
Definition: COM.h:289
winstd::variant::operator<
bool operator<(const VARIANT &varSrc) const noexcept
Is variant less than?
Definition: COM.h:960
winstd::variant::variant
variant(unsigned long long nSrc) noexcept
Constructs VARIANT from unsigned integer.
Definition: COM.h:430
winstd::variant::variant
variant(char cSrc) noexcept
Constructs VARIANT from character.
Definition: COM.h:327
winstd::variant::operator=
variant & operator=(unsigned short *pnSrc) noexcept
Copy from unsigned short reference.
Definition: COM.h:789
winstd::variant::operator=
variant & operator=(long long *pnSrc) noexcept
Copy from long long reference.
Definition: COM.h:854
winstd::variant::variant
variant(BSTR bstr) noexcept
Constructs VARIANT from BSTR.
Definition: COM.h:458
winstd::variant::operator=
variant & operator=(unsigned long long *pnSrc) noexcept
Copy from unsigned long long reference.
Definition: COM.h:867
winstd::variant::variant
variant(double dblSrc, VARTYPE vtSrc=VT_R8) noexcept
Constructs VARIANT from double or variant date.
Definition: COM.h:411
winstd::variant::variant
variant(short nSrc) noexcept
Constructs VARIANT from short.
Definition: COM.h:345
winstd::variant::variant
variant(CY cySrc) noexcept
Constructs VARIANT from CY (64-bit integer)
Definition: COM.h:439
winstd::variant::operator=
variant & operator=(unsigned long long nSrc) noexcept
Copy from unsigned long long value.
Definition: COM.h:672
winstd::variant::operator=
variant & operator=(VARIANT &&varSrc) noexcept
Moves from another VARIANT.
Definition: COM.h:529
winstd::variant::operator=
variant & operator=(long long nSrc) noexcept
Copy from long long value.
Definition: COM.h:659
winstd::variant::operator=
variant & operator=(IDispatch *pSrc)
Copy from IDispatch.
Definition: COM.h:737
winstd::variant::operator=
variant & operator=(unsigned long *pnSrc) noexcept
Copy from unsigned long reference.
Definition: COM.h:841
winstd::variant::operator=
variant & operator=(const VARIANT &varSrc)
Copy from another VARIANT.
Definition: COM.h:516
WINSTD_NONCOPYABLE
#define WINSTD_NONCOPYABLE(C)
Declares a class as non-copyable.
Definition: Common.h:53
WINSTD_NONMOVABLE
#define WINSTD_NONMOVABLE(C)
Declares a class as non-movable.
Definition: Common.h:61
WINSTD_DPLHANDLE_IMPL
#define WINSTD_DPLHANDLE_IMPL(C, INVAL)
Implements default constructors and operators to prevent their auto-generation by compiler.
Definition: Common.h:174
winstd::handle< T *, INVAL >::invalid
static const T * invalid
Invalid handle value.
Definition: Common.h:614
winstd::CoTaskMemFree_delete
Deleter for unique_ptr using CoTaskMemFree.
Definition: COM.h:59
winstd::CoTaskMemFree_delete::operator()
void operator()(_T *_Ptr) const
Delete a pointer.
Definition: COM.h:71
winstd::CoTaskMemFree_delete::CoTaskMemFree_delete
CoTaskMemFree_delete() noexcept
Default constructor.
Definition: COM.h:63