|
|
|
1 |
|
/*** |
2 |
|
* comip.h - Native C++ compiler COM support - COM interface pointers header |
3 |
|
* |
4 |
|
* Copyright (c) Microsoft Corporation. All rights reserved. |
5 |
|
* |
6 |
|
****/ |
7 |
|
|
8 |
|
#if _MSC_VER > 1000 |
9 |
|
#pragma once |
10 |
|
#endif |
11 |
|
|
12 |
|
#ifdef _M_CEE_PURE |
13 |
|
#error comip.h header cannot be included under /clr:safe or /clr:pure |
14 |
|
#endif |
15 |
|
|
16 |
|
#if !defined(_INC_COMIP) |
17 |
|
#define _INC_COMIP |
18 |
|
|
19 |
|
#include <ole2.h> |
20 |
|
#include <malloc.h> |
21 |
|
|
22 |
|
#include <comutil.h> |
23 |
|
|
24 |
|
#pragma warning(push) |
25 |
|
#pragma warning(disable: 4290) |
26 |
|
|
27 |
|
#pragma push_macro("new") |
28 |
|
#undef new |
29 |
|
|
30 |
|
#include <new.h> |
31 |
|
|
32 |
|
class _com_error; |
33 |
|
|
34 |
|
void __stdcall _com_issue_error(HRESULT); |
35 |
|
struct __declspec(uuid("00000000-0000-0000-c000-000000000046")) IUnknown; |
36 |
|
|
37 |
|
// Provide Interface to IID association |
38 |
|
// |
39 |
|
template<typename _Interface, const IID* _IID /*= &__uuidof(_Interface)*/> |
40 |
|
class _com_IIID { |
41 |
|
public: |
42 |
|
typedef _Interface Interface; |
43 |
|
|
44 |
|
static _Interface* GetInterfacePtr() throw() |
45 |
|
{ |
46 |
|
return NULL; |
47 |
|
} |
48 |
|
|
49 |
|
static _Interface& GetInterface() throw() |
50 |
|
{ |
51 |
|
return *GetInterfacePtr(); |
52 |
|
} |
53 |
|
|
54 |
|
static const IID& GetIID() throw() |
55 |
|
{ |
56 |
|
return *_IID; |
57 |
|
} |
58 |
|
}; |
59 |
|
|
60 |
|
template<typename _IIID> class _com_ptr_t { |
61 |
|
public: |
62 |
|
// Declare interface type so that the type may be available outside |
63 |
|
// the scope of this template. |
64 |
|
// |
65 |
|
typedef _IIID ThisIIID; |
66 |
|
typedef typename _IIID::Interface Interface; |
67 |
|
|
988 |
|
} |
989 |
|
|
990 |
|
template<typename _Interface> bool operator>(int null, _com_ptr_t<_Interface>& p) |
991 |
|
{ |
992 |
|
if (null != 0) { |
993 |
|
_com_issue_error(E_POINTER); |
994 |
|
} |
995 |
|
|
996 |
|
return p < NULL; |
997 |
|
} |
998 |
|
|
999 |
|
template<typename _Interface, typename _InterfacePtr> bool operator>(_Interface* i, _com_ptr_t<_InterfacePtr>& p) |
1000 |
|
{ |
1001 |
|
return p < i; |
1002 |
|
} |
1003 |
|
|
1004 |
|
template<typename _Interface> bool operator<=(int null, _com_ptr_t<_Interface>& p) |
1005 |
|
{ |
1006 |
|
if (null != 0) { |
1007 |
|
_com_issue_error(E_POINTER); |
1008 |
|
} |
1009 |
|
|
1010 |
|
return p >= NULL; |
1011 |
|
} |
1012 |
|
|
1013 |
|
template<typename _Interface, typename _InterfacePtr> bool operator<=(_Interface* i, _com_ptr_t<_InterfacePtr>& p) |
1014 |
|
{ |
1015 |
|
return p >= i; |
1016 |
|
} |
1017 |
|
|
1018 |
|
template<typename _Interface> bool operator>=(int null, _com_ptr_t<_Interface>& p) |
1019 |
|
{ |
1020 |
|
if (null != 0) { |
1021 |
|
_com_issue_error(E_POINTER); |
1022 |
|
} |
1023 |
|
|
1024 |
|
return p <= NULL; |
1025 |
|
} |
1026 |
|
|
1027 |
|
template<typename _Interface, typename _InterfacePtr> bool operator>=(_Interface* i, _com_ptr_t<_InterfacePtr>& p) |
1028 |
|
{ |
1029 |
|
return p <= i; |
1030 |
|
} |
1031 |
|
|
1032 |
|
#pragma pop_macro("new") |
1033 |
|
#pragma warning(pop) |
1034 |
|
|
1035 |
|
#endif // _INC_COMIP |
1036 |
|
|
|
|
|