1 /* OLE DB Conversion library
3 * Copyright 2009 Huw Davies
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #define NONAMELESSUNION
24 #define NONAMELESSSTRUCT
33 #include "oledb_private.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(oledb);
41 const struct IDataConvertVtbl *lpVtbl;
42 const struct IDCInfoVtbl *lpDCInfoVtbl;
46 UINT version; /* Set by IDCInfo_SetInfo */
49 static inline convert *impl_from_IDataConvert(IDataConvert *iface)
51 return (convert *)((char*)iface - FIELD_OFFSET(convert, lpVtbl));
54 static inline convert *impl_from_IDCInfo(IDCInfo *iface)
56 return (convert *)((char*)iface - FIELD_OFFSET(convert, lpDCInfoVtbl));
59 static HRESULT WINAPI convert_QueryInterface(IDataConvert* iface,
63 convert *This = impl_from_IDataConvert(iface);
64 TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
68 if(IsEqualIID(riid, &IID_IUnknown) ||
69 IsEqualIID(riid, &IID_IDataConvert))
73 else if(IsEqualIID(riid, &IID_IDCInfo))
75 *obj = &This->lpDCInfoVtbl;
79 FIXME("interface %s not implemented\n", debugstr_guid(riid));
83 IDataConvert_AddRef(iface);
88 static ULONG WINAPI convert_AddRef(IDataConvert* iface)
90 convert *This = impl_from_IDataConvert(iface);
91 TRACE("(%p)\n", This);
93 return InterlockedIncrement(&This->ref);
97 static ULONG WINAPI convert_Release(IDataConvert* iface)
99 convert *This = impl_from_IDataConvert(iface);
102 TRACE("(%p)\n", This);
104 ref = InterlockedDecrement(&This->ref);
107 HeapFree(GetProcessHeap(), 0, This);
113 static int get_length(DBTYPE type)
132 case DBTYPE_FILETIME:
133 return sizeof(FILETIME);
137 case DBTYPE_BYREF | DBTYPE_WSTR:
140 FIXME("Unhandled type %04x\n", type);
145 static HRESULT WINAPI convert_DataConvert(IDataConvert* iface,
146 DBTYPE src_type, DBTYPE dst_type,
147 DBLENGTH src_len, DBLENGTH *dst_len,
148 void *src, void *dst,
149 DBLENGTH dst_max_len,
150 DBSTATUS src_status, DBSTATUS *dst_status,
151 BYTE precision, BYTE scale,
154 convert *This = impl_from_IDataConvert(iface);
157 TRACE("(%p)->(%d, %d, %d, %p, %p, %p, %d, %d, %p, %d, %d, %x)\n", This,
158 src_type, dst_type, src_len, dst_len, src, dst, dst_max_len,
159 src_status, dst_status, precision, scale, flags);
161 *dst_len = get_length(dst_type);
162 *dst_status = DBSTATUS_E_BADACCESSOR;
164 if(IDataConvert_CanConvert(iface, src_type, dst_type) != S_OK)
166 return DB_E_UNSUPPORTEDCONVERSION;
169 if(src_type == DBTYPE_STR)
174 if(flags & DBDATACONVERT_LENGTHFROMNTS)
175 len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0) - 1;
177 len = MultiByteToWideChar(CP_ACP, 0, src, src_len, NULL, 0);
178 b = SysAllocStringLen(NULL, len);
179 if(!b) return E_OUTOFMEMORY;
180 if(flags & DBDATACONVERT_LENGTHFROMNTS)
181 MultiByteToWideChar(CP_ACP, 0, src, -1, b, len + 1);
183 MultiByteToWideChar(CP_ACP, 0, src, src_len, b, len);
185 hr = IDataConvert_DataConvert(iface, DBTYPE_BSTR, dst_type, 0, dst_len,
186 &b, dst, dst_max_len, src_status, dst_status,
187 precision, scale, flags);
193 if(src_type == DBTYPE_WSTR)
197 if(flags & DBDATACONVERT_LENGTHFROMNTS)
198 b = SysAllocString(src);
200 b = SysAllocStringLen(src, src_len / 2);
201 if(!b) return E_OUTOFMEMORY;
202 hr = IDataConvert_DataConvert(iface, DBTYPE_BSTR, dst_type, 0, dst_len,
203 &b, dst, dst_max_len, src_status, dst_status,
204 precision, scale, flags);
213 signed short *d = dst;
216 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
217 case DBTYPE_I2: *d = *(signed short*)src; hr = S_OK; break;
218 case DBTYPE_I4: hr = VarI2FromI4(*(signed int*)src, d); break;
219 case DBTYPE_R4: hr = VarI2FromR4(*(FLOAT*)src, d); break;
220 case DBTYPE_R8: hr = VarI2FromR8(*(double*)src, d); break;
221 case DBTYPE_CY: hr = VarI2FromCy(*(CY*)src, d); break;
222 case DBTYPE_DATE: hr = VarI2FromDate(*(DATE*)src, d); break;
223 case DBTYPE_BSTR: hr = VarI2FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
224 case DBTYPE_BOOL: hr = VarI2FromBool(*(VARIANT_BOOL*)src, d); break;
225 case DBTYPE_DECIMAL: hr = VarI2FromDec((DECIMAL*)src, d); break;
226 case DBTYPE_I1: hr = VarI2FromI1(*(signed char*)src, d); break;
227 case DBTYPE_UI1: hr = VarI2FromUI1(*(BYTE*)src, d); break;
228 case DBTYPE_UI2: hr = VarI2FromUI2(*(WORD*)src, d); break;
229 case DBTYPE_UI4: hr = VarI2FromUI4(*(DWORD*)src, d); break;
230 case DBTYPE_I8: hr = VarI2FromI8(*(LONGLONG*)src, d); break;
231 case DBTYPE_UI8: hr = VarI2FromUI8(*(ULONGLONG*)src, d); break;
232 default: FIXME("Unimplemented conversion %04x -> I2\n", src_type); return E_NOTIMPL;
242 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
243 case DBTYPE_I2: hr = VarI4FromI2(*(signed short*)src, d); break;
244 case DBTYPE_I4: *d = *(signed int*)src; hr = S_OK; break;
245 case DBTYPE_R4: hr = VarI4FromR4(*(FLOAT*)src, d); break;
246 case DBTYPE_R8: hr = VarI4FromR8(*(double*)src, d); break;
247 case DBTYPE_CY: hr = VarI4FromCy(*(CY*)src, d); break;
248 case DBTYPE_DATE: hr = VarI4FromDate(*(DATE*)src, d); break;
249 case DBTYPE_BSTR: hr = VarI4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
250 case DBTYPE_BOOL: hr = VarI4FromBool(*(VARIANT_BOOL*)src, d); break;
251 case DBTYPE_DECIMAL: hr = VarI4FromDec((DECIMAL*)src, d); break;
252 case DBTYPE_I1: hr = VarI4FromI1(*(signed char*)src, d); break;
253 case DBTYPE_UI1: hr = VarI4FromUI1(*(BYTE*)src, d); break;
254 case DBTYPE_UI2: hr = VarI4FromUI2(*(WORD*)src, d); break;
255 case DBTYPE_UI4: hr = VarI4FromUI4(*(DWORD*)src, d); break;
256 case DBTYPE_I8: hr = VarI4FromI8(*(LONGLONG*)src, d); break;
257 case DBTYPE_UI8: hr = VarI4FromUI8(*(ULONGLONG*)src, d); break;
258 default: FIXME("Unimplemented conversion %04x -> I4\n", src_type); return E_NOTIMPL;
268 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
269 case DBTYPE_I2: hr = VarR4FromI2(*(signed short*)src, d); break;
270 case DBTYPE_I4: hr = VarR4FromI4(*(signed int*)src, d); break;
271 case DBTYPE_R4: *d = *(FLOAT*)src; hr = S_OK; break;
272 case DBTYPE_R8: hr = VarR4FromR8(*(double*)src, d); break;
273 case DBTYPE_CY: hr = VarR4FromCy(*(CY*)src, d); break;
274 case DBTYPE_DATE: hr = VarR4FromDate(*(DATE*)src, d); break;
275 case DBTYPE_BSTR: hr = VarR4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
276 case DBTYPE_BOOL: hr = VarR4FromBool(*(VARIANT_BOOL*)src, d); break;
277 case DBTYPE_DECIMAL: hr = VarR4FromDec((DECIMAL*)src, d); break;
278 case DBTYPE_I1: hr = VarR4FromI1(*(signed char*)src, d); break;
279 case DBTYPE_UI1: hr = VarR4FromUI1(*(BYTE*)src, d); break;
280 case DBTYPE_UI2: hr = VarR4FromUI2(*(WORD*)src, d); break;
281 case DBTYPE_UI4: hr = VarR4FromUI4(*(DWORD*)src, d); break;
282 case DBTYPE_I8: hr = VarR4FromI8(*(LONGLONG*)src, d); break;
283 case DBTYPE_UI8: hr = VarR4FromUI8(*(ULONGLONG*)src, d); break;
284 default: FIXME("Unimplemented conversion %04x -> R4\n", src_type); return E_NOTIMPL;
294 case DBTYPE_EMPTY: *d = SysAllocStringLen(NULL, 0); hr = *d ? S_OK : E_OUTOFMEMORY; break;
295 case DBTYPE_I2: hr = VarBstrFromI2(*(signed short*)src, LOCALE_USER_DEFAULT, 0, d); break;
296 case DBTYPE_I4: hr = VarBstrFromI4(*(signed int*)src, LOCALE_USER_DEFAULT, 0, d); break;
297 case DBTYPE_R4: hr = VarBstrFromR4(*(FLOAT*)src, LOCALE_USER_DEFAULT, 0, d); break;
298 case DBTYPE_R8: hr = VarBstrFromR8(*(double*)src, LOCALE_USER_DEFAULT, 0, d); break;
299 case DBTYPE_CY: hr = VarBstrFromCy(*(CY*)src, LOCALE_USER_DEFAULT, 0, d); break;
300 case DBTYPE_DATE: hr = VarBstrFromDate(*(DATE*)src, LOCALE_USER_DEFAULT, 0, d); break;
301 case DBTYPE_BSTR: *d = SysAllocStringLen(*(BSTR*)src, SysStringLen(*(BSTR*)src)); hr = *d ? S_OK : E_OUTOFMEMORY; break;
302 case DBTYPE_BOOL: hr = VarBstrFromBool(*(VARIANT_BOOL*)src, LOCALE_USER_DEFAULT, 0, d); break;
303 case DBTYPE_DECIMAL: hr = VarBstrFromDec((DECIMAL*)src, LOCALE_USER_DEFAULT, 0, d); break;
304 case DBTYPE_I1: hr = VarBstrFromI1(*(signed char*)src, LOCALE_USER_DEFAULT, 0, d); break;
305 case DBTYPE_UI1: hr = VarBstrFromUI1(*(BYTE*)src, LOCALE_USER_DEFAULT, 0, d); break;
306 case DBTYPE_UI2: hr = VarBstrFromUI2(*(WORD*)src, LOCALE_USER_DEFAULT, 0, d); break;
307 case DBTYPE_UI4: hr = VarBstrFromUI4(*(DWORD*)src, LOCALE_USER_DEFAULT, 0, d); break;
308 case DBTYPE_I8: hr = VarBstrFromI8(*(LONGLONG*)src, LOCALE_USER_DEFAULT, 0, d); break;
309 case DBTYPE_UI8: hr = VarBstrFromUI8(*(ULONGLONG*)src, LOCALE_USER_DEFAULT, 0, d); break;
310 default: FIXME("Unimplemented conversion %04x -> BSTR\n", src_type); return E_NOTIMPL;
320 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
321 case DBTYPE_I2: hr = VarUI1FromI2(*(signed short*)src, d); break;
322 case DBTYPE_I4: hr = VarUI1FromI4(*(signed int*)src, d); break;
323 case DBTYPE_R4: hr = VarUI1FromR4(*(FLOAT*)src, d); break;
324 case DBTYPE_R8: hr = VarUI1FromR8(*(double*)src, d); break;
325 case DBTYPE_CY: hr = VarUI1FromCy(*(CY*)src, d); break;
326 case DBTYPE_DATE: hr = VarUI1FromDate(*(DATE*)src, d); break;
327 case DBTYPE_BSTR: hr = VarUI1FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
328 case DBTYPE_BOOL: hr = VarUI1FromBool(*(VARIANT_BOOL*)src, d); break;
329 case DBTYPE_DECIMAL: hr = VarUI1FromDec((DECIMAL*)src, d); break;
330 case DBTYPE_I1: hr = VarUI1FromI1(*(signed char*)src, d); break;
331 case DBTYPE_UI1: *d = *(BYTE*)src; hr = S_OK; break;
332 case DBTYPE_UI2: hr = VarUI1FromUI2(*(WORD*)src, d); break;
333 case DBTYPE_UI4: hr = VarUI1FromUI4(*(DWORD*)src, d); break;
334 case DBTYPE_I8: hr = VarUI1FromI8(*(LONGLONG*)src, d); break;
335 case DBTYPE_UI8: hr = VarUI1FromUI8(*(ULONGLONG*)src, d); break;
336 default: FIXME("Unimplemented conversion %04x -> UI1\n", src_type); return E_NOTIMPL;
346 case DBTYPE_EMPTY: *d = 0; hr = S_OK; break;
347 case DBTYPE_I2: hr = VarUI4FromI2(*(signed short*)src, d); break;
348 case DBTYPE_I4: hr = VarUI4FromI4(*(signed int*)src, d); break;
349 case DBTYPE_R4: hr = VarUI4FromR4(*(FLOAT*)src, d); break;
350 case DBTYPE_R8: hr = VarUI4FromR8(*(double*)src, d); break;
351 case DBTYPE_CY: hr = VarUI4FromCy(*(CY*)src, d); break;
352 case DBTYPE_DATE: hr = VarUI4FromDate(*(DATE*)src, d); break;
353 case DBTYPE_BSTR: hr = VarUI4FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break;
354 case DBTYPE_BOOL: hr = VarUI4FromBool(*(VARIANT_BOOL*)src, d); break;
355 case DBTYPE_DECIMAL: hr = VarUI4FromDec((DECIMAL*)src, d); break;
356 case DBTYPE_I1: hr = VarUI4FromI1(*(signed char*)src, d); break;
357 case DBTYPE_UI1: hr = VarUI4FromUI1(*(BYTE*)src, d); break;
358 case DBTYPE_UI2: hr = VarUI4FromUI2(*(WORD*)src, d); break;
359 case DBTYPE_UI4: *d = *(DWORD*)src; hr = S_OK; break;
360 case DBTYPE_I8: hr = VarUI4FromI8(*(LONGLONG*)src, d); break;
361 case DBTYPE_UI8: hr = VarUI4FromUI8(*(ULONGLONG*)src, d); break;
362 default: FIXME("Unimplemented conversion %04x -> UI4\n", src_type); return E_NOTIMPL;
367 case DBTYPE_FILETIME:
372 case DBTYPE_EMPTY: d->dwLowDateTime = d->dwHighDateTime = 0; hr = S_OK; break;
373 case DBTYPE_FILETIME: *d = *(FILETIME*)src; hr = S_OK; break;
374 default: FIXME("Unimplemented conversion %04x -> FILETIME\n", src_type); return E_NOTIMPL;
384 case DBTYPE_EMPTY: *d = GUID_NULL; hr = S_OK; break;
385 case DBTYPE_GUID: *d = *(GUID*)src; hr = S_OK; break;
386 default: FIXME("Unimplemented conversion %04x -> GUID\n", src_type); return E_NOTIMPL;
396 hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
397 src, &b, sizeof(BSTR), src_status, dst_status,
398 precision, scale, flags);
399 if(hr != S_OK) return hr;
400 bstr_len = SysStringLen(b);
401 *dst_len = bstr_len * sizeof(WCHAR); /* Doesn't include size for '\0' */
402 *dst_status = DBSTATUS_S_OK;
403 bytes_to_copy = min(*dst_len + sizeof(WCHAR), dst_max_len);
406 if(bytes_to_copy >= sizeof(WCHAR))
408 memcpy(dst, b, bytes_to_copy - sizeof(WCHAR));
409 *((WCHAR*)dst + bytes_to_copy / sizeof(WCHAR) - 1) = 0;
410 if(bytes_to_copy < *dst_len + sizeof(WCHAR))
411 *dst_status = DBSTATUS_S_TRUNCATED;
415 *dst_status = DBSTATUS_E_DATAOVERFLOW;
416 hr = DB_E_ERRORSOCCURRED;
423 case DBTYPE_BYREF | DBTYPE_WSTR:
428 hr = IDataConvert_DataConvert(iface, src_type, DBTYPE_BSTR, src_len, &bstr_len,
429 src, &b, sizeof(BSTR), src_status, dst_status,
430 precision, scale, flags);
431 if(hr != S_OK) return hr;
433 bstr_len = SysStringLen(b) * sizeof(WCHAR);
434 *dst_len = bstr_len; /* Doesn't include size for '\0' */
436 *d = CoTaskMemAlloc(bstr_len + sizeof(WCHAR));
437 if(*d) memcpy(*d, b, bstr_len + sizeof(WCHAR));
438 else hr = E_OUTOFMEMORY;
444 FIXME("Unimplemented conversion %04x -> %04x\n", src_type, dst_type);
449 if(hr == DISP_E_OVERFLOW)
451 *dst_status = DBSTATUS_E_DATAOVERFLOW;
452 hr = DB_E_ERRORSOCCURRED;
455 *dst_status = DBSTATUS_S_OK;
460 static inline WORD get_dbtype_class(DBTYPE type)
487 case DBTYPE_DBTIMESTAMP:
488 return DBTYPE_DBDATE;
493 /* Many src types will convert to this group of dst types */
494 static inline BOOL common_class(WORD dst_class)
514 static inline BOOL array_type(DBTYPE type)
516 return (type >= DBTYPE_I2 && type <= DBTYPE_UI4);
519 static HRESULT WINAPI convert_CanConvert(IDataConvert* iface,
520 DBTYPE src_type, DBTYPE dst_type)
522 convert *This = impl_from_IDataConvert(iface);
523 DBTYPE src_base_type = src_type & 0x1ff;
524 DBTYPE dst_base_type = dst_type & 0x1ff;
525 WORD dst_class = get_dbtype_class(dst_base_type);
527 TRACE("(%p)->(%d, %d)\n", This, src_type, dst_type);
529 if(src_type & DBTYPE_VECTOR || dst_type & DBTYPE_VECTOR) return S_FALSE;
531 if(src_type & DBTYPE_ARRAY)
533 if(!array_type(src_base_type)) return S_FALSE;
534 if(dst_type & DBTYPE_ARRAY)
536 if(src_type == dst_type) return S_OK;
539 if(dst_type == DBTYPE_VARIANT) return S_OK;
543 if(dst_type & DBTYPE_ARRAY)
545 if(!array_type(dst_base_type)) return S_FALSE;
546 if(src_type == DBTYPE_IDISPATCH || src_type == DBTYPE_VARIANT) return S_OK;
550 if(dst_type & DBTYPE_BYREF)
551 if(dst_base_type != DBTYPE_BYTES && dst_base_type != DBTYPE_STR && dst_base_type != DBTYPE_WSTR)
554 switch(get_dbtype_class(src_base_type))
557 if(common_class(dst_class)) return S_OK;
562 case DBTYPE_FILETIME:
565 if(dst_base_type == DBTYPE_DBTIMESTAMP) return S_OK;
570 switch(dst_base_type)
574 case DBTYPE_FILETIME: return S_OK;
575 default: return S_FALSE;
579 if(dst_base_type == DBTYPE_BYTES) return S_OK;
582 if(dst_base_type == DBTYPE_DATE) return S_OK;
585 if(common_class(dst_class)) return S_OK;
586 if(dst_class == DBTYPE_DBDATE) return S_OK;
590 if(dst_base_type == DBTYPE_DATE) return S_OK;
593 if(common_class(dst_class)) return S_OK;
597 if(common_class(dst_class)) return S_OK;
598 switch(dst_base_type)
601 case DBTYPE_FILETIME: return S_OK;
602 default: return S_FALSE;
618 case DBTYPE_FILETIME:
620 default: return S_FALSE;
623 case DBTYPE_IDISPATCH:
625 switch(dst_base_type)
627 case DBTYPE_IDISPATCH:
629 case DBTYPE_IUNKNOWN:
634 if(common_class(dst_class)) return S_OK;
641 case DBTYPE_FILETIME:
643 default: return S_FALSE;
647 switch(dst_base_type)
654 default: return S_FALSE;
657 case DBTYPE_IUNKNOWN:
658 switch(dst_base_type)
662 case DBTYPE_IDISPATCH:
664 case DBTYPE_IUNKNOWN:
666 default: return S_FALSE;
670 if(dst_class == DBTYPE_I4 || dst_class == DBTYPE_I8) return S_OK;
682 default: return S_FALSE;
685 case DBTYPE_FILETIME:
686 if(dst_class == DBTYPE_I8) return S_OK;
697 case DBTYPE_FILETIME:
699 default: return S_FALSE;
706 static HRESULT WINAPI convert_GetConversionSize(IDataConvert* iface,
707 DBTYPE wSrcType, DBTYPE wDstType,
708 DBLENGTH *pcbSrcLength, DBLENGTH *pcbDstLength,
711 convert *This = impl_from_IDataConvert(iface);
712 FIXME("(%p)->(%d, %d, %p, %p, %p): stub\n", This, wSrcType, wDstType, pcbSrcLength, pcbDstLength, pSrc);
717 static const struct IDataConvertVtbl convert_vtbl =
719 convert_QueryInterface,
724 convert_GetConversionSize
727 static HRESULT WINAPI dcinfo_QueryInterface(IDCInfo* iface, REFIID riid, void **obj)
729 convert *This = impl_from_IDCInfo(iface);
731 return IDataConvert_QueryInterface((IDataConvert *)This, riid, obj);
734 static ULONG WINAPI dcinfo_AddRef(IDCInfo* iface)
736 convert *This = impl_from_IDCInfo(iface);
738 return IDataConvert_AddRef((IDataConvert *)This);
741 static ULONG WINAPI dcinfo_Release(IDCInfo* iface)
743 convert *This = impl_from_IDCInfo(iface);
745 return IDataConvert_Release((IDataConvert *)This);
748 static HRESULT WINAPI dcinfo_GetInfo(IDCInfo *iface, ULONG num, DCINFOTYPE types[], DCINFO **info_ptr)
750 convert *This = impl_from_IDCInfo(iface);
754 TRACE("(%p)->(%d, %p, %p)\n", This, num, types, info_ptr);
756 *info_ptr = infos = CoTaskMemAlloc(num * sizeof(*infos));
757 if(!infos) return E_OUTOFMEMORY;
759 for(i = 0; i < num; i++)
761 infos[i].eInfoType = types[i];
762 VariantInit(&infos[i].vData);
766 case DCINFOTYPE_VERSION:
767 V_VT(&infos[i].vData) = VT_UI4;
768 V_UI4(&infos[i].vData) = This->version;
776 static HRESULT WINAPI dcinfo_SetInfo(IDCInfo* iface, ULONG num, DCINFO info[])
778 convert *This = impl_from_IDCInfo(iface);
782 TRACE("(%p)->(%d, %p)\n", This, num, info);
784 for(i = 0; i < num; i++)
786 switch(info[i].eInfoType)
788 case DCINFOTYPE_VERSION:
789 if(V_VT(&info[i].vData) != VT_UI4)
791 FIXME("VERSION with vt %x\n", V_VT(&info[i].vData));
792 hr = DB_S_ERRORSOCCURRED;
795 This->version = V_UI4(&info[i].vData);
799 FIXME("Unhandled info type %d (vt %x)\n", info[i].eInfoType, V_VT(&info[i].vData));
805 static const struct IDCInfoVtbl dcinfo_vtbl =
807 dcinfo_QueryInterface,
814 HRESULT create_oledb_convert(IUnknown *outer, void **obj)
818 TRACE("(%p, %p)\n", outer, obj);
822 if(outer) return CLASS_E_NOAGGREGATION;
824 This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
825 if(!This) return E_OUTOFMEMORY;
827 This->lpVtbl = &convert_vtbl;
828 This->lpDCInfoVtbl = &dcinfo_vtbl;
830 This->version = 0x110;
832 *obj = &This->lpVtbl;