From afa90e325ec56733fd1c2079bc512136b6afeb01 Mon Sep 17 00:00:00 2001 From: Andreas Pflug Date: Wed, 17 Nov 2010 13:06:16 +0100 Subject: [PATCH] oledb32: Added conversions for R8,BOOL,DATE,DBTIMESTAMP. --- dlls/oledb32/convert.c | 120 +++++++++++++++++++++++++++++++++++++++++ include/oledb.idl | 9 ++++ 2 files changed, 129 insertions(+) diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index f6f72d0cb7c..c98d0b2d228 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -120,13 +120,19 @@ static int get_length(DBTYPE type) case DBTYPE_I2: case DBTYPE_UI2: return 2; + case DBTYPE_BOOL: + return sizeof(VARIANT_BOOL); case DBTYPE_I4: case DBTYPE_UI4: case DBTYPE_R4: return 4; case DBTYPE_I8: case DBTYPE_UI8: + case DBTYPE_R8: + case DBTYPE_DATE: return 8; + case DBTYPE_DBTIMESTAMP: + return sizeof(DBTIMESTAMP); case DBTYPE_CY: return sizeof(CY); case DBTYPE_BSTR: @@ -299,6 +305,120 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, } break; } + case DBTYPE_R8: + { + DOUBLE *d=dst; + switch (src_type) + { + case DBTYPE_EMPTY: *d = 0; hr = S_OK; break; + case DBTYPE_I1: hr = VarR8FromI1(*(signed char*)src, d); break; + case DBTYPE_I2: hr = VarR8FromI2(*(signed short*)src, d); break; + case DBTYPE_I4: hr = VarR8FromI4(*(signed int*)src, d); break; + case DBTYPE_I8: hr = VarR8FromI8(*(LONGLONG*)src, d); break; + case DBTYPE_UI1: hr = VarR8FromUI1(*(BYTE*)src, d); break; + case DBTYPE_UI2: hr = VarR8FromUI2(*(WORD*)src, d); break; + case DBTYPE_UI4: hr = VarR8FromUI4(*(DWORD*)src, d); break; + case DBTYPE_UI8: hr = VarR8FromUI8(*(ULONGLONG*)src, d); break; + case DBTYPE_R4: hr = VarR8FromR4(*(FLOAT*)src, d); break; + case DBTYPE_R8: *d = *(DOUBLE*)src; hr = S_OK; break; + case DBTYPE_CY: hr = VarR8FromCy(*(CY*)src, d); break; + case DBTYPE_DATE: hr = VarR8FromDate(*(DATE*)src, d); break; + case DBTYPE_BSTR: hr = VarR8FromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break; + case DBTYPE_BOOL: hr = VarR8FromBool(*(VARIANT_BOOL*)src, d); break; + case DBTYPE_DECIMAL: hr = VarR8FromDec((DECIMAL*)src, d); break; + default: FIXME("Unimplemented conversion %04x -> R8\n", src_type); return E_NOTIMPL; + } + break; + } + case DBTYPE_BOOL: + { + VARIANT_BOOL *d=dst; + switch (src_type) + { + case DBTYPE_EMPTY: *d = 0; hr = S_OK; break; + case DBTYPE_I1: hr = VarBoolFromI1(*(signed char*)src, d); break; + case DBTYPE_I2: hr = VarBoolFromI2(*(signed short*)src, d); break; + case DBTYPE_I4: hr = VarBoolFromI4(*(signed int*)src, d); break; + case DBTYPE_I8: hr = VarBoolFromI8(*(LONGLONG*)src, d); break; + case DBTYPE_UI1: hr = VarBoolFromUI1(*(BYTE*)src, d); break; + case DBTYPE_UI2: hr = VarBoolFromUI2(*(WORD*)src, d); break; + case DBTYPE_UI4: hr = VarBoolFromUI4(*(DWORD*)src, d); break; + case DBTYPE_UI8: hr = VarBoolFromUI8(*(ULONGLONG*)src, d); break; + case DBTYPE_R4: hr = VarBoolFromR4(*(FLOAT*)src, d); break; + case DBTYPE_R8: hr = VarBoolFromR8(*(DOUBLE*)src, d); break; + case DBTYPE_CY: hr = VarBoolFromCy(*(CY*)src, d); break; + case DBTYPE_DATE: hr = VarBoolFromDate(*(DATE*)src, d); break; + case DBTYPE_BSTR: hr = VarBoolFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break; + case DBTYPE_BOOL: *d = *(VARIANT_BOOL*)src; hr = S_OK; break; + case DBTYPE_DECIMAL: hr = VarBoolFromDec((DECIMAL*)src, d); break; + default: FIXME("Unimplemented conversion %04x -> BOOL\n", src_type); return E_NOTIMPL; + } + break; + } + case DBTYPE_DATE: + { + DATE *d=dst; + switch (src_type) + { + case DBTYPE_EMPTY: *d = 0; hr = S_OK; break; + case DBTYPE_I1: hr = VarDateFromI1(*(signed char*)src, d); break; + case DBTYPE_I2: hr = VarDateFromI2(*(signed short*)src, d); break; + case DBTYPE_I4: hr = VarDateFromI4(*(signed int*)src, d); break; + case DBTYPE_I8: hr = VarDateFromI8(*(LONGLONG*)src, d); break; + case DBTYPE_UI1: hr = VarDateFromUI1(*(BYTE*)src, d); break; + case DBTYPE_UI2: hr = VarDateFromUI2(*(WORD*)src, d); break; + case DBTYPE_UI4: hr = VarDateFromUI4(*(DWORD*)src, d); break; + case DBTYPE_UI8: hr = VarDateFromUI8(*(ULONGLONG*)src, d); break; + case DBTYPE_R4: hr = VarDateFromR4(*(FLOAT*)src, d); break; + case DBTYPE_R8: hr = VarDateFromR8(*(DOUBLE*)src, d); break; + case DBTYPE_CY: hr = VarDateFromCy(*(CY*)src, d); break; + case DBTYPE_DATE: *d = *(DATE*)src; hr = S_OK; break; + case DBTYPE_BSTR: hr = VarDateFromStr(*(WCHAR**)src, LOCALE_USER_DEFAULT, 0, d); break; + case DBTYPE_BOOL: hr = VarDateFromBool(*(VARIANT_BOOL*)src, d); break; + case DBTYPE_DECIMAL: hr = VarDateFromDec((DECIMAL*)src, d); break; + case DBTYPE_DBTIMESTAMP: + { + SYSTEMTIME st; + DBTIMESTAMP *ts=(DBTIMESTAMP*)src; + + st.wYear = ts->year; + st.wMonth = ts->month; + st.wDay = ts->day; + st.wHour = ts->hour; + st.wMinute = ts->minute; + st.wSecond = ts->second; + st.wMilliseconds = ts->fraction/1000000; + hr = (SystemTimeToVariantTime(&st, d) ? S_OK : E_FAIL); + break; + } + default: FIXME("Unimplemented conversion %04x -> DATE\n", src_type); return E_NOTIMPL; + } + break; + } + case DBTYPE_DBTIMESTAMP: + { + DBTIMESTAMP *d=dst; + switch (src_type) + { + case DBTYPE_EMPTY: memset(d, 0, sizeof(DBTIMESTAMP)); hr = S_OK; break; + case DBTYPE_DBTIMESTAMP: memcpy(d, src, sizeof(DBTIMESTAMP)); hr = S_OK; break; + case DBTYPE_DATE: + { + SYSTEMTIME st; + hr = (VariantTimeToSystemTime(*(double*)src, &st) ? S_OK : E_FAIL); + d->year = st.wYear; + d->month = st.wMonth; + d->day = st.wDay; + d->hour = st.wHour; + d->minute = st.wMinute; + d->second = st.wSecond; + d->fraction = st.wMilliseconds * 1000000; + break; + } + default: FIXME("Unimplemented conversion %04x -> DBTIMESTAMP\n", src_type); return E_NOTIMPL; + } + break; + } case DBTYPE_CY: { diff --git a/include/oledb.idl b/include/oledb.idl index 127df2b4906..48411651c55 100644 --- a/include/oledb.idl +++ b/include/oledb.idl @@ -40,6 +40,15 @@ typedef ULONG DBREFCOUNT; typedef ULONG DB_UPARAMS; typedef LONG DB_LPARAMS; typedef DWORD DBHASHVALUE; +typedef struct { + SHORT year; + USHORT month; + USHORT day; + USHORT hour; + USHORT minute; + USHORT second; + ULONG fraction; +} DBTIMESTAMP; #include "dbs.idl"