winegstreamer: Keep a IMFMediaSource pointer in the media stream.
[wine.git] / include / propvarutil.h
blob575c498b230f922f474f3afd5b1b3bb877899787
1 /*
2 * Copyright 2008 James Hawkins for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINE_PROPVARUTIL_H
20 #define __WINE_PROPVARUTIL_H
22 #include <shtypes.h>
23 #include <shlwapi.h>
25 #ifndef WINE_NTSTATUS_DECLARED
26 #define WINE_NTSTATUS_DECLARED
27 typedef LONG NTSTATUS;
28 #endif
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 enum tagPROPVAR_CHANGE_FLAGS
36 PVCHF_DEFAULT = 0x00000000,
37 PVCHF_NOVALUEPROP = 0x00000001,
38 PVCHF_ALPHABOOL = 0x00000002,
39 PVCHF_NOUSEROVERRIDE = 0x00000004,
40 PVCHF_LOCALBOOL = 0x00000008,
41 PVCHF_NOHEXSTRING = 0x00000010,
44 typedef int PROPVAR_CHANGE_FLAGS;
46 enum tagPROPVAR_COMPARE_UNIT
48 PVCU_DEFAULT = 0x00000000,
49 PVCU_SECOND = 0x00000001,
50 PVCU_MINUTE = 0x00000002,
51 PVCU_HOUR = 0x00000003,
52 PVCU_DAY = 0x00000004,
53 PVCU_MONTH = 0x00000005,
54 PVCU_YEAR = 0x00000006,
57 typedef int PROPVAR_COMPARE_UNIT;
59 enum tagPROPVAR_COMPARE_FLAGS
61 PVCF_DEFAULT = 0x00000000,
62 PVCF_TREATEMPTYASGREATERTHAN = 0x00000001,
63 PVCF_USESTRCMP = 0x00000002,
64 PVCF_USESTRCMPC = 0x00000004,
65 PVCF_USESTRCMPI = 0x00000008,
66 PVCF_USESTRCMPIC = 0x00000010,
69 typedef int PROPVAR_COMPARE_FLAGS;
71 HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT propvarSrc,
72 PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
73 HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar);
74 HRESULT WINAPI InitVariantFromFileTime(const FILETIME *ft, VARIANT *var);
75 HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar);
76 HRESULT WINAPI InitPropVariantFromBuffer(const VOID *pv, UINT cb, PROPVARIANT *ppropvar);
77 HRESULT WINAPI InitPropVariantFromCLSID(REFCLSID clsid, PROPVARIANT *ppropvar);
78 HRESULT WINAPI InitVariantFromBuffer(const VOID *pv, UINT cb, VARIANT *pvar);
79 HRESULT WINAPI PropVariantToGUID(const PROPVARIANT *ppropvar, GUID *guid);
80 HRESULT WINAPI VariantToGUID(const VARIANT *pvar, GUID *guid);
81 INT WINAPI PropVariantCompareEx(REFPROPVARIANT propvar1, REFPROPVARIANT propvar2,
82 PROPVAR_COMPARE_UNIT uint, PROPVAR_COMPARE_FLAGS flags);
83 HRESULT WINAPI InitPropVariantFromFileTime(const FILETIME *pftIn, PROPVARIANT *ppropvar);
84 HRESULT WINAPI InitPropVariantFromStringVector(PCWSTR *strs, ULONG count, PROPVARIANT *ppropvar);
86 HRESULT WINAPI PropVariantToDouble(REFPROPVARIANT propvarIn, double *ret);
87 HRESULT WINAPI PropVariantToInt16(REFPROPVARIANT propvarIn, SHORT *ret);
88 HRESULT WINAPI PropVariantToInt32(REFPROPVARIANT propvarIn, LONG *ret);
89 HRESULT WINAPI PropVariantToInt64(REFPROPVARIANT propvarIn, LONGLONG *ret);
90 HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret);
91 HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret);
92 HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret);
93 HRESULT WINAPI PropVariantToBoolean(REFPROPVARIANT propvarIn, BOOL *ret);
94 HRESULT WINAPI PropVariantToBuffer(REFPROPVARIANT propvarIn, void *ret, UINT cb);
95 HRESULT WINAPI PropVariantToString(REFPROPVARIANT propvarIn, PWSTR ret, UINT cch);
96 PCWSTR WINAPI PropVariantToStringWithDefault(REFPROPVARIANT propvarIn, LPCWSTR pszDefault);
97 PCWSTR WINAPI VariantToStringWithDefault(const VARIANT *pvar, LPCWSTR pszDefault);
99 HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret);
101 #ifdef __cplusplus
103 HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar);
104 HRESULT InitPropVariantFromInt16(SHORT nVal, PROPVARIANT *ppropvar);
105 HRESULT InitPropVariantFromUInt16(USHORT uiVal, PROPVARIANT *ppropvar);
106 HRESULT InitPropVariantFromInt32(LONG lVal, PROPVARIANT *ppropvar);
107 HRESULT InitPropVariantFromUInt32(ULONG ulVal, PROPVARIANT *ppropvar);
108 HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar);
109 HRESULT InitPropVariantFromUInt64(ULONGLONG ullVal, PROPVARIANT *ppropvar);
110 HRESULT InitPropVariantFromDouble(DOUBLE dblVal, PROPVARIANT *ppropvar);
111 HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar);
112 HRESULT InitPropVariantFromGUIDAsBuffer(REFGUID guid, PROPVARIANT *ppropvar);
113 BOOL IsPropVariantVector(REFPROPVARIANT propvar);
114 BOOL IsPropVariantString(REFPROPVARIANT propvar);
116 #ifndef NO_PROPVAR_INLINES
118 inline HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar)
120 ppropvar->vt = VT_BOOL;
121 ppropvar->boolVal = fVal ? VARIANT_TRUE : VARIANT_FALSE;
122 return S_OK;
125 inline HRESULT InitPropVariantFromInt16(SHORT nVal, PROPVARIANT *ppropvar)
127 ppropvar->vt = VT_I2;
128 ppropvar->iVal = nVal;
129 return S_OK;
132 inline HRESULT InitPropVariantFromUInt16(USHORT uiVal, PROPVARIANT *ppropvar)
134 ppropvar->vt = VT_UI2;
135 ppropvar->uiVal = uiVal;
136 return S_OK;
139 inline HRESULT InitPropVariantFromInt32(LONG lVal, PROPVARIANT *ppropvar)
141 ppropvar->vt = VT_I4;
142 ppropvar->lVal = lVal;
143 return S_OK;
146 inline HRESULT InitPropVariantFromUInt32(ULONG ulVal, PROPVARIANT *ppropvar)
148 ppropvar->vt = VT_UI4;
149 ppropvar->ulVal = ulVal;
150 return S_OK;
153 inline HRESULT InitPropVariantFromInt64(LONGLONG llVal, PROPVARIANT *ppropvar)
155 ppropvar->vt = VT_I8;
156 ppropvar->hVal.QuadPart = llVal;
157 return S_OK;
160 inline HRESULT InitPropVariantFromUInt64(ULONGLONG ullVal, PROPVARIANT *ppropvar)
162 ppropvar->vt = VT_UI8;
163 ppropvar->uhVal.QuadPart = ullVal;
164 return S_OK;
167 inline HRESULT InitPropVariantFromDouble(DOUBLE dblVal, PROPVARIANT *ppropvar)
169 ppropvar->vt = VT_R8;
170 ppropvar->dblVal = dblVal;
171 return S_OK;
174 inline HRESULT InitPropVariantFromString(PCWSTR psz, PROPVARIANT *ppropvar)
176 HRESULT hres;
178 hres = SHStrDupW(psz, &ppropvar->pwszVal);
179 if(SUCCEEDED(hres))
180 ppropvar->vt = VT_LPWSTR;
181 else
182 PropVariantInit(ppropvar);
184 return hres;
187 inline HRESULT InitPropVariantFromGUIDAsBuffer(REFGUID guid, PROPVARIANT *ppropvar)
189 #ifdef __cplusplus
190 return InitPropVariantFromBuffer(&guid, sizeof(GUID), ppropvar);
191 #else
192 return InitPropVariantFromBuffer(guid, sizeof(GUID), ppropvar);
193 #endif
196 inline BOOL IsPropVariantVector(REFPROPVARIANT propvar)
198 return (propvar.vt & (VT_ARRAY | VT_VECTOR));
201 inline BOOL IsPropVariantString(REFPROPVARIANT propvar)
203 return (PropVariantToStringWithDefault(propvar, NULL) != NULL);
206 #endif /* NO_PROPVAR_INLINES */
207 #endif /* __cplusplus */
209 HRESULT WINAPI StgSerializePropVariant(const PROPVARIANT *ppropvar, SERIALIZEDPROPERTYVALUE **ppprop, ULONG *pcb);
210 HRESULT WINAPI StgDeserializePropVariant(const SERIALIZEDPROPERTYVALUE *pprop, ULONG cbmax, PROPVARIANT *ppropvar);
212 #ifdef __cplusplus
214 #endif
216 #endif /* __WINE_PROPVARUTIL_H */