diff options
Diffstat (limited to 'CPP/Windows/PropVariant.h')
-rw-r--r-- | CPP/Windows/PropVariant.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/CPP/Windows/PropVariant.h b/CPP/Windows/PropVariant.h new file mode 100644 index 0000000..108bf6b --- /dev/null +++ b/CPP/Windows/PropVariant.h | |||
@@ -0,0 +1,127 @@ | |||
1 | // Windows/PropVariant.h | ||
2 | |||
3 | #ifndef __WINDOWS_PROP_VARIANT_H | ||
4 | #define __WINDOWS_PROP_VARIANT_H | ||
5 | |||
6 | #include "../Common/MyTypes.h" | ||
7 | #include "../Common/MyWindows.h" | ||
8 | #include "../Common/MyString.h" | ||
9 | |||
10 | namespace NWindows { | ||
11 | namespace NCOM { | ||
12 | |||
13 | BSTR AllocBstrFromAscii(const char *s) throw(); | ||
14 | |||
15 | HRESULT PropVariant_Clear(PROPVARIANT *p) throw(); | ||
16 | |||
17 | HRESULT PropVarEm_Alloc_Bstr(PROPVARIANT *p, unsigned numChars) throw(); | ||
18 | HRESULT PropVarEm_Set_Str(PROPVARIANT *p, const char *s) throw(); | ||
19 | |||
20 | inline void PropVarEm_Set_UInt32(PROPVARIANT *p, UInt32 v) throw() | ||
21 | { | ||
22 | p->vt = VT_UI4; | ||
23 | p->ulVal = v; | ||
24 | } | ||
25 | |||
26 | inline void PropVarEm_Set_UInt64(PROPVARIANT *p, UInt64 v) throw() | ||
27 | { | ||
28 | p->vt = VT_UI8; | ||
29 | p->uhVal.QuadPart = v; | ||
30 | } | ||
31 | |||
32 | inline void PropVarEm_Set_FileTime64(PROPVARIANT *p, UInt64 v) throw() | ||
33 | { | ||
34 | p->vt = VT_FILETIME; | ||
35 | p->filetime.dwLowDateTime = (DWORD)v; | ||
36 | p->filetime.dwHighDateTime = (DWORD)(v >> 32); | ||
37 | } | ||
38 | |||
39 | inline void PropVarEm_Set_Bool(PROPVARIANT *p, bool b) throw() | ||
40 | { | ||
41 | p->vt = VT_BOOL; | ||
42 | p->boolVal = (b ? VARIANT_TRUE : VARIANT_FALSE); | ||
43 | } | ||
44 | |||
45 | |||
46 | class CPropVariant : public tagPROPVARIANT | ||
47 | { | ||
48 | // ---------- forbidden functions ---------- | ||
49 | CPropVariant(const char *s); | ||
50 | // CPropVariant(const UString &s); | ||
51 | #ifdef DEBUG_FSTRING_INHERITS_ASTRING | ||
52 | CPropVariant(const FString &s); | ||
53 | CPropVariant& operator=(const FString &s); | ||
54 | #endif | ||
55 | |||
56 | public: | ||
57 | CPropVariant() | ||
58 | { | ||
59 | vt = VT_EMPTY; | ||
60 | wReserved1 = 0; | ||
61 | // wReserved2 = 0; | ||
62 | // wReserved3 = 0; | ||
63 | // uhVal.QuadPart = 0; | ||
64 | bstrVal = 0; | ||
65 | } | ||
66 | ~CPropVariant() throw() { Clear(); } | ||
67 | CPropVariant(const PROPVARIANT &varSrc); | ||
68 | CPropVariant(const CPropVariant &varSrc); | ||
69 | CPropVariant(BSTR bstrSrc); | ||
70 | CPropVariant(LPCOLESTR lpszSrc); | ||
71 | CPropVariant(bool bSrc) { vt = VT_BOOL; wReserved1 = 0; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); } | ||
72 | CPropVariant(Byte value) { vt = VT_UI1; wReserved1 = 0; bVal = value; } | ||
73 | |||
74 | private: | ||
75 | CPropVariant(UInt16 value); // { vt = VT_UI2; wReserved1 = 0; uiVal = value; } | ||
76 | CPropVariant(Int16 value); // { vt = VT_I2; wReserved1 = 0; iVal = value; } | ||
77 | CPropVariant(Int32 value); // { vt = VT_I4; wReserved1 = 0; lVal = value; } | ||
78 | CPropVariant(Int64 value); // { vt = VT_I8; wReserved1 = 0; hVal.QuadPart = value; } | ||
79 | |||
80 | public: | ||
81 | CPropVariant(UInt32 value) { vt = VT_UI4; wReserved1 = 0; ulVal = value; } | ||
82 | CPropVariant(UInt64 value) { vt = VT_UI8; wReserved1 = 0; uhVal.QuadPart = value; } | ||
83 | CPropVariant(const FILETIME &value) { vt = VT_FILETIME; wReserved1 = 0; filetime = value; } | ||
84 | |||
85 | CPropVariant& operator=(const CPropVariant &varSrc); | ||
86 | CPropVariant& operator=(const PROPVARIANT &varSrc); | ||
87 | CPropVariant& operator=(BSTR bstrSrc); | ||
88 | CPropVariant& operator=(LPCOLESTR lpszSrc); | ||
89 | CPropVariant& operator=(const UString &s); | ||
90 | CPropVariant& operator=(const UString2 &s); | ||
91 | CPropVariant& operator=(const char *s); | ||
92 | CPropVariant& operator=(const AString &s) | ||
93 | { return (*this)=(const char *)s; } | ||
94 | |||
95 | CPropVariant& operator=(bool bSrc) throw(); | ||
96 | CPropVariant& operator=(Byte value) throw(); | ||
97 | |||
98 | private: | ||
99 | CPropVariant& operator=(Int16 value) throw(); | ||
100 | CPropVariant& operator=(UInt16 value) throw(); | ||
101 | CPropVariant& operator=(Int32 value) throw(); | ||
102 | CPropVariant& operator=(Int64 value) throw(); | ||
103 | |||
104 | public: | ||
105 | CPropVariant& operator=(UInt32 value) throw(); | ||
106 | CPropVariant& operator=(UInt64 value) throw(); | ||
107 | CPropVariant& operator=(const FILETIME &value) throw(); | ||
108 | |||
109 | void Set_Int32(Int32 value) throw(); | ||
110 | void Set_Int64(Int64 value) throw(); | ||
111 | |||
112 | BSTR AllocBstr(unsigned numChars); | ||
113 | |||
114 | HRESULT Clear() throw(); | ||
115 | HRESULT Copy(const PROPVARIANT *pSrc) throw(); | ||
116 | HRESULT Attach(PROPVARIANT *pSrc) throw(); | ||
117 | HRESULT Detach(PROPVARIANT *pDest) throw(); | ||
118 | |||
119 | HRESULT InternalClear() throw(); | ||
120 | void InternalCopy(const PROPVARIANT *pSrc); | ||
121 | |||
122 | int Compare(const CPropVariant &a) throw(); | ||
123 | }; | ||
124 | |||
125 | }} | ||
126 | |||
127 | #endif | ||