12#define _COM_ASSERT(x) ((void)0)
15#define _COM_MEMCPY_S(dest,destsize,src,count) memcpy(dest,src,count)
18#if !defined(__STDC_SECURE_LIB__) || defined(__REACTOS__)
19#define _COM_PRINTF_S_1(dest,destsize,format,arg1) wsprintf(dest,format,arg1)
21#define _COM_PRINTF_S_1(dest,destsize,format,arg1) swprintf_s(dest,destsize,format,arg1)
23#define _COM_PRINTF_S_1(dest,destsize,format,arg1) sprintf_s(dest,destsize,format,arg1)
28#pragma push_macro("new")
32#define WINAPI __stdcall
56 _bstr_t(
const _bstr_t &
s) throw();
60 _bstr_t(
BSTR bstr,
bool fCopy);
91 Data_t(
const char *
s);
92 Data_t(
const wchar_t *
s);
93 Data_t(
BSTR bstr,
bool fCopy);
94 Data_t(
const _bstr_t &
s1,
const _bstr_t &
s2);
95 unsigned long AddRef() throw();
96 unsigned long Release() throw();
97 unsigned long RefCount()
const throw();
101 wchar_t *&GetWString() throw();
105 void Attach(
BSTR s) throw();
112 unsigned long m_RefCount;
114 Data_t(
const Data_t &
s) throw();
116 void _Free() throw();
121 void _AddRef() throw();
122 void _Free() throw();
126inline _bstr_t::_bstr_t() throw() : m_Data(
NULL) { }
128inline _bstr_t::_bstr_t(
const _bstr_t &
s)
throw() : m_Data(
s.m_Data) { _AddRef(); }
130inline _bstr_t::_bstr_t(
const char *
s) : m_Data(
new Data_t(
s)) {
134inline _bstr_t::_bstr_t(
const wchar_t *
s) : m_Data(
new Data_t(
s)) {
138inline _bstr_t::_bstr_t(
BSTR bstr,
bool fCopy) : m_Data(
new Data_t(bstr,fCopy)) {
142inline _bstr_t::~_bstr_t() throw() { _Free(); }
144inline _bstr_t &_bstr_t::operator=(
const _bstr_t &
s)
throw() {
153inline _bstr_t &_bstr_t::operator=(
const char *
s) {
155 if(!
s ||
static_cast<const char *
>(*
this)!=
s) {
157 m_Data =
new Data_t(
s);
163inline _bstr_t &_bstr_t::operator=(
const wchar_t *
s) {
165 if(!
s ||
static_cast<const wchar_t *
>(*
this)!=
s) {
167 m_Data =
new Data_t(
s);
173inline _bstr_t &_bstr_t::operator+=(
const _bstr_t &
s) {
174 Data_t *newData =
new Data_t(*
this,
s);
183inline _bstr_t _bstr_t::operator+(
const _bstr_t &
s)
const {
195inline _bstr_t
operator+(
const wchar_t *
s1,
const _bstr_t &
s2) {
201inline _bstr_t::operator
const wchar_t *()
const throw() {
return (m_Data!=
NULL) ? m_Data->GetWString() :
NULL; }
202inline _bstr_t::operator
wchar_t *()
const throw() {
return const_cast<wchar_t *
>((m_Data!=
NULL) ? m_Data->GetWString() :
NULL); }
203inline _bstr_t::operator
const char *()
const {
return (m_Data!=
NULL) ? m_Data->GetString() :
NULL; }
204inline _bstr_t::operator
char *()
const {
return const_cast<char *
>((m_Data!=
NULL) ? m_Data->GetString() :
NULL); }
205inline bool _bstr_t::operator!()
const throw() {
return (m_Data!=
NULL) ? !m_Data->GetWString() :
true; }
206inline bool _bstr_t::operator==(
const _bstr_t &
str)
const throw() {
return _Compare(
str)==0; }
207inline bool _bstr_t::operator!=(
const _bstr_t &
str)
const throw() {
return _Compare(
str)!=0; }
208inline bool _bstr_t::operator<(
const _bstr_t &
str)
const throw() {
return _Compare(
str)<0; }
209inline bool _bstr_t::operator>(
const _bstr_t &
str)
const throw() {
return _Compare(
str)>0; }
210inline bool _bstr_t::operator<=(
const _bstr_t &
str)
const throw() {
return _Compare(
str)<=0; }
211inline bool _bstr_t::operator>=(
const _bstr_t &
str)
const throw() {
return _Compare(
str)>=0; }
212inline BSTR _bstr_t::copy(
bool fCopy)
const {
return (m_Data!=
NULL) ? (fCopy ? m_Data->Copy() : m_Data->GetWString()) :
NULL; }
213inline unsigned int _bstr_t::length()
const throw() {
return (m_Data!=
NULL) ? m_Data->Length() : 0; }
214inline void _bstr_t::Assign(
BSTR s) {
216 if(!
s || !m_Data || m_Data->GetWString()!=
s) {
218 m_Data =
new Data_t(
s,
TRUE);
223inline BSTR &_bstr_t::GetBSTR() {
225 m_Data =
new Data_t(0,
FALSE);
228 return m_Data->GetWString();
231inline BSTR *_bstr_t::GetAddress() {
233 return &m_Data->GetWString();
236inline void _bstr_t::Attach(
BSTR s) {
238 m_Data =
new Data_t(
s,
FALSE);
242inline BSTR _bstr_t::Detach() {
244 if(m_Data!=
NULL && m_Data->RefCount()==1) {
245 BSTR b = m_Data->GetWString();
246 m_Data->GetWString() =
NULL;
255inline void _bstr_t::_AddRef() throw() {
256 if(m_Data!=
NULL) m_Data->AddRef();
259inline void _bstr_t::_Free() throw() {
266inline int _bstr_t::_Compare(
const _bstr_t &
str)
const throw() {
267 if(m_Data==
str.m_Data)
return 0;
268 if(!m_Data)
return -1;
269 if(!
str.m_Data)
return 1;
270 return m_Data->Compare(*
str.m_Data);
273inline _bstr_t::Data_t::Data_t(
const char *
s) : m_str(
NULL),m_RefCount(1) {
277inline _bstr_t::Data_t::Data_t(
const wchar_t *
s) : m_str(
NULL),m_RefCount(1) {
282inline _bstr_t::Data_t::Data_t(
BSTR bstr,
bool fCopy) : m_str(
NULL),m_RefCount(1) {
283 if(fCopy && bstr!=
NULL) {
286 }
else m_wstr = bstr;
289inline _bstr_t::Data_t::Data_t(
const _bstr_t &
s1,
const _bstr_t &
s2) : m_str(
NULL),m_RefCount(1) {
290 const unsigned int l1 =
s1.length();
291 const unsigned int l2 =
s2.length();
297 const wchar_t *wstr1 =
static_cast<const wchar_t *
>(
s1);
299 _COM_MEMCPY_S(m_wstr,(l1 + l2 + 1) *
sizeof(
wchar_t),wstr1,(l1 + 1) *
sizeof(
wchar_t));
301 const wchar_t *wstr2 =
static_cast<const wchar_t *
>(
s2);
303 _COM_MEMCPY_S(m_wstr + l1,(l2 + 1) *
sizeof(
wchar_t),wstr2,(l2 + 1) *
sizeof(
wchar_t));
307inline unsigned long _bstr_t::Data_t::AddRef() throw() {
312inline unsigned long _bstr_t::Data_t::Release() throw() {
314 if(cRef==0)
delete this;
318inline unsigned long _bstr_t::Data_t::RefCount()
const throw() {
return m_RefCount; }
319inline _bstr_t::Data_t::operator
const wchar_t *()
const throw() {
return m_wstr; }
320inline _bstr_t::Data_t::operator
const char *()
const {
return GetString(); }
321inline const wchar_t *_bstr_t::Data_t::GetWString()
const throw() {
return m_wstr; }
322inline wchar_t *&_bstr_t::Data_t::GetWString() throw() {
return m_wstr; }
323inline const char *_bstr_t::Data_t::GetString()
const {
327inline BSTR _bstr_t::Data_t::Copy()
const {
335inline void _bstr_t::Data_t::Assign(
BSTR s) {
342inline void _bstr_t::Data_t::Attach(
BSTR s)
throw() {
348inline unsigned int _bstr_t::Data_t::Length()
const throw() {
return m_wstr ?
::SysStringLen(m_wstr) : 0; }
349inline int _bstr_t::Data_t::Compare(
const _bstr_t::Data_t &
str)
const throw() {
350 if(!m_wstr)
return str.m_wstr ? -1 : 0;
351 if(!
str.m_wstr)
return 1;
354 unsigned int len = l1;
359 if(*bstr1++!=*bstr2++)
return bstr1[-1] - bstr2[-1];
361 return (l1<l2) ? -1 : (l1==l2) ? 0 : 1;
364#ifdef _COM_OPERATOR_NEW_THROWS
365inline void *_bstr_t::Data_t::operator
new(
size_t sz) {
367 return ::operator
new(sz);
373inline void *_bstr_t::Data_t::operator
new(
size_t sz) {
374 return ::operator
new(sz);
378inline _bstr_t::Data_t::~Data_t() throw() { _Free(); }
379inline void _bstr_t::Data_t::_Free() throw() {
381 if(m_str!=
NULL)
delete [] m_str;
386 _variant_t() throw();
389 _variant_t(
const _variant_t &varSrc);
390 _variant_t(
VARIANT &varSrc,
bool fCopy);
393 _variant_t(
float fltSrc) throw();
395 _variant_t(
const CY &cySrc) throw();
396 _variant_t(
const _bstr_t &bstrSrc);
397 _variant_t(
const wchar_t *pSrc);
398 _variant_t(
const char *pSrc);
400 _variant_t(
bool boolSrc) throw();
403 _variant_t(
BYTE bSrc) throw();
404 _variant_t(
char cSrc) throw();
405 _variant_t(
unsigned short usSrc) throw();
406 _variant_t(
unsigned long ulSrc) throw();
407 _variant_t(
int iSrc) throw();
408 _variant_t(
unsigned int uiSrc) throw();
411 ~_variant_t() throw();
436 _variant_t &
operator=(
float fltSrc);
437 _variant_t &
operator=(
double dblSrc);
443 _variant_t &
operator=(
bool boolSrc);
448 _variant_t &
operator=(
unsigned short usSrc);
449 _variant_t &
operator=(
unsigned long ulSrc);
451 _variant_t &
operator=(
unsigned int uiSrc);
464 void SetString(
const char *pSrc);
468inline _variant_t::_variant_t(
const VARIANT &varSrc) {
472inline _variant_t::_variant_t(
const VARIANT *pSrc) {
479inline _variant_t::_variant_t(
const _variant_t &varSrc) {
483inline _variant_t::_variant_t(
VARIANT &varSrc,
bool fCopy) {
488 _COM_MEMCPY_S(
static_cast<void*
>(
this),
sizeof(varSrc),&varSrc,
sizeof(varSrc));
492inline _variant_t::_variant_t(
short sSrc,
VARTYPE vtSrc) {
499 V_BOOL(
this) = (sSrc ? VARIANT_TRUE : VARIANT_FALSE);
505inline _variant_t::_variant_t(
long lSrc,
VARTYPE vtSrc) {
515 V_BOOL(
this) = (lSrc ? VARIANT_TRUE : VARIANT_FALSE);
521inline _variant_t::_variant_t(
float fltSrc)
throw() {
526inline _variant_t::_variant_t(
double dblSrc,
VARTYPE vtSrc) {
539inline _variant_t::_variant_t(
const CY &cySrc)
throw() {
543inline _variant_t::_variant_t(
const _bstr_t &bstrSrc) {
545 BSTR bstr =
static_cast<wchar_t *
>(bstrSrc);
552inline _variant_t::_variant_t(
const wchar_t *pSrc) {
557inline _variant_t::_variant_t(
const char *pSrc) {
561inline _variant_t::_variant_t(
IDispatch *pSrc,
bool fAddRef)
throw() {
566inline _variant_t::_variant_t(
bool boolSrc)
throw() {
568 V_BOOL(
this) = (boolSrc ? VARIANT_TRUE : VARIANT_FALSE);
570inline _variant_t::_variant_t(
IUnknown *pSrc,
bool fAddRef)
throw() {
575inline _variant_t::_variant_t(
const DECIMAL &decSrc)
throw() {
579inline _variant_t::_variant_t(
BYTE bSrc)
throw() {
583inline _variant_t::_variant_t(
char cSrc)
throw() {
587inline _variant_t::_variant_t(
unsigned short usSrc)
throw() {
591inline _variant_t::_variant_t(
unsigned long ulSrc)
throw() {
595inline _variant_t::_variant_t(
int iSrc)
throw() {
599inline _variant_t::_variant_t(
unsigned int uiSrc)
throw() {
609 V_UI8(
this) = ui8Src;
611inline _variant_t::operator
short()
const {
614 varDest.ChangeType(
VT_I2,
this);
615 return V_I2(&varDest);
617inline _variant_t::operator
long()
const {
620 varDest.ChangeType(
VT_I4,
this);
621 return V_I4(&varDest);
624inline _variant_t::operator
float()
const {
627 varDest.ChangeType(
VT_R4,
this);
628 return V_R4(&varDest);
631inline _variant_t::operator
double()
const {
634 varDest.ChangeType(
VT_R8,
this);
635 return V_R8(&varDest);
638inline _variant_t::operator
CY()
const {
641 varDest.ChangeType(
VT_CY,
this);
642 return V_CY(&varDest);
645inline _variant_t::operator _bstr_t()
const {
648 varDest.ChangeType(
VT_BSTR,
this);
652inline _variant_t::operator
IDispatch*()
const {
662inline _variant_t::operator
bool()
const {
665 varDest.ChangeType(
VT_BOOL,
this);
666 return (
V_BOOL(&varDest)==VARIANT_TRUE) ?
true :
false;
669inline _variant_t::operator
IUnknown*()
const {
679inline _variant_t::operator
DECIMAL()
const {
685inline _variant_t::operator
BYTE()
const {
688 varDest.ChangeType(
VT_UI1,
this);
689 return V_UI1(&varDest);
691inline _variant_t::operator
VARIANT()
const throw() {
return *(
VARIANT*)
this; }
692inline _variant_t::operator
char()
const {
695 varDest.ChangeType(
VT_I1,
this);
696 return V_I1(&varDest);
699inline _variant_t::operator
unsigned short()
const {
702 varDest.ChangeType(
VT_UI2,
this);
703 return V_UI2(&varDest);
706inline _variant_t::operator
unsigned long()
const {
709 varDest.ChangeType(
VT_UI4,
this);
710 return V_UI4(&varDest);
712inline _variant_t::operator
int()
const {
715 varDest.ChangeType(
VT_INT,
this);
716 return V_INT(&varDest);
718inline _variant_t::operator
unsigned int()
const {
721 varDest.ChangeType(
VT_UINT,
this);
727 varDest.ChangeType(
VT_I8,
this);
728 return V_I8(&varDest);
733 varDest.ChangeType(
VT_UI8,
this);
734 return V_UI8(&varDest);
736inline _variant_t &_variant_t::operator=(
const VARIANT &varSrc) {
740inline _variant_t &_variant_t::operator=(
const VARIANT *pSrc) {
745inline _variant_t &_variant_t::operator=(
const _variant_t &varSrc) {
749inline _variant_t &_variant_t::operator=(
short sSrc) {
751 else if(
V_VT(
this)==
VT_BOOL)
V_BOOL(
this) = (sSrc ? VARIANT_TRUE : VARIANT_FALSE);
759inline _variant_t &_variant_t::operator=(
long lSrc) {
762 else if(
V_VT(
this)==
VT_BOOL)
V_BOOL(
this) = (lSrc ? VARIANT_TRUE : VARIANT_FALSE);
770inline _variant_t &_variant_t::operator=(
float fltSrc) {
779inline _variant_t &_variant_t::operator=(
double dblSrc)
798inline _variant_t &_variant_t::operator=(
const CY &cySrc)
812inline _variant_t &_variant_t::operator=(
const _bstr_t &bstrSrc)
824 BSTR bstr =
static_cast<wchar_t *
>(bstrSrc);
835inline _variant_t &_variant_t::operator=(
const wchar_t *pSrc)
857inline _variant_t &_variant_t::operator=(
const char *pSrc)
869inline _variant_t &_variant_t::operator=(
IDispatch *pSrc)
886inline _variant_t &_variant_t::operator=(
bool boolSrc)
895 V_BOOL(
this) = (boolSrc ? VARIANT_TRUE : VARIANT_FALSE);
900inline _variant_t &_variant_t::operator=(
IUnknown *pSrc)
917inline _variant_t &_variant_t::operator=(
const DECIMAL &decSrc)
930inline _variant_t &_variant_t::operator=(
BYTE bSrc)
944inline _variant_t &_variant_t::operator=(
char cSrc)
958inline _variant_t &_variant_t::operator=(
unsigned short usSrc)
972inline _variant_t &_variant_t::operator=(
unsigned long ulSrc)
986inline _variant_t &_variant_t::operator=(
int iSrc)
1000inline _variant_t &_variant_t::operator=(
unsigned int uiSrc)
1035 V_UI8(
this) = ui8Src;
1040inline bool _variant_t::operator==(
const VARIANT &varSrc)
const throw() {
1041 return *
this==&varSrc;
1044inline bool _variant_t::operator==(
const VARIANT *pSrc)
const throw()
1058 switch (
V_VT(
this)) {
1132inline bool _variant_t::operator!=(
const VARIANT &varSrc)
const throw()
1134 return !(*
this==&varSrc);
1137inline bool _variant_t::operator!=(
const VARIANT *pSrc)
const throw()
1139 return !(*
this==pSrc);
1142inline void _variant_t::Clear()
1147inline void _variant_t::Attach(
VARIANT &varSrc)
1152 _COM_MEMCPY_S(
static_cast<void*
>(
this),
sizeof(varSrc),&varSrc,
sizeof(varSrc));
1156inline VARIANT _variant_t::Detach()
1164inline VARIANT &_variant_t::GetVARIANT() throw()
1169inline VARIANT *_variant_t::GetAddress() {
1173inline void _variant_t::ChangeType(
VARTYPE vartype,
const _variant_t *pSrc) {
1174 if(!pSrc) pSrc =
this;
1175 if((
this!=pSrc) || (vartype!=
V_VT(
this))) {
1179inline void _variant_t::SetString(
const char *pSrc) { operator=(pSrc); }
1180inline _variant_t::~_variant_t() throw() {
::VariantClear(
this); }
1181inline _bstr_t::_bstr_t(
const _variant_t &
var) : m_Data(
NULL) {
1188 *
this =
V_BSTR(&varDest);
1190inline _bstr_t &_bstr_t::operator=(
const _variant_t &
var) {
1197 *
this =
V_BSTR(&varDest);
1204#define bstr_t _bstr_t
1205#define variant_t _variant_t
1208#pragma pop_macro("new")
#define __MINGW_EXTENSION
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define InterlockedIncrement
#define InterlockedDecrement
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
CHString WINAPI operator+(CHSTRING_WCHAR ch, const CHString &string)
void WINAPI _com_issue_error(HRESULT hr)
_variant_t vtMissing(DISP_E_PARAMNOTFOUND, VT_ERROR)
#define _COM_MEMCPY_S(dest, destsize, src, count)
struct tagVARIANT VARIANT
VOID Copy(PVOID Src, PVOID Dst, ULONG NumBytes)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
return DeviceInit Security Sddl Assign(SDDLString)
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
BOOL GetAddress(const WCHAR *, INTERNET_PORT, SOCKADDR *, int *, char *) DECLSPEC_HIDDEN
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
static BSTR GetBSTR(const LPINTERNAL_BSTR bstr)
static float(__cdecl *square_half_float)(float x
static ULONG WINAPI AddRef(IStream *iface)
BSTR WINAPI ConvertStringToBSTR(const char *pSrc)
char *WINAPI ConvertBSTRToString(BSTR pSrc)
_In_ ULONG _In_ ULONG _In_ ULONG Length
UINT WINAPI SysStringByteLen(BSTR str)
BSTR WINAPI SysAllocString(LPCOLESTR str)
UINT WINAPI SysStringLen(BSTR str)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
BSTR WINAPI DECLSPEC_HOTPATCH SysAllocStringByteLen(LPCSTR str, UINT len)
void CheckError(HRESULT hr)
#define new(TYPE, numElems)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantChangeType(VARIANTARG *pvargDest, VARIANTARG *pvargSrc, USHORT wFlags, VARTYPE vt)
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
void WINAPI VariantInit(VARIANTARG *pVarg)
HRESULT WINAPI VariantCopy(VARIANTARG *pvargDest, VARIANTARG *pvargSrc)