25#include <com/sun/star/io/XInputStream.hpp>
26#include <com/sun/star/sdbc/XClob.hpp>
27#include <com/sun/star/sdbc/XBlob.hpp>
28#include <com/sun/star/sdb/XColumn.hpp>
29#include <com/sun/star/sdbc/XRow.hpp>
30#include <rtl/ustrbuf.hxx>
32#include <osl/diagnose.h>
45 bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
47 bool bIsCompatible =
true;
49 if (_eType1 != _eType2)
51 SAL_INFO(
"connectivity.commontools",
"ORowSetValue::isStorageCompatible _eType1 != _eType2" );
55 case DataType::VARCHAR:
56 case DataType::DECIMAL:
57 case DataType::NUMERIC:
58 case DataType::LONGVARCHAR:
59 bIsCompatible = (DataType::CHAR == _eType2)
60 || (DataType::VARCHAR == _eType2)
61 || (DataType::DECIMAL == _eType2)
62 || (DataType::NUMERIC == _eType2)
63 || (DataType::LONGVARCHAR == _eType2);
66 case DataType::DOUBLE:
68 bIsCompatible = (DataType::DOUBLE == _eType2)
69 || (DataType::REAL == _eType2);
72 case DataType::BINARY:
73 case DataType::VARBINARY:
74 case DataType::LONGVARBINARY:
75 bIsCompatible = (DataType::BINARY == _eType2)
76 || (DataType::VARBINARY == _eType2)
77 || (DataType::LONGVARBINARY == _eType2);
80 case DataType::INTEGER:
81 bIsCompatible = (DataType::SMALLINT == _eType2)
82 || (DataType::TINYINT == _eType2)
83 || (DataType::BIT == _eType2)
84 || (DataType::BOOLEAN == _eType2);
86 case DataType::SMALLINT:
87 bIsCompatible = (DataType::TINYINT == _eType2)
88 || (DataType::BIT == _eType2)
89 || (DataType::BOOLEAN == _eType2);
91 case DataType::TINYINT:
92 bIsCompatible = (DataType::BIT == _eType2)
93 || (DataType::BOOLEAN == _eType2);
98 case DataType::OBJECT:
99 bIsCompatible = (DataType::BLOB == _eType2)
100 || (DataType::CLOB == _eType2)
101 || (DataType::OBJECT == _eType2);
105 bIsCompatible =
false;
108 return bIsCompatible;
111 bool isStorageComparable(sal_Int32 _eType1, sal_Int32 _eType2)
113 bool bIsComparable =
true;
115 if (_eType1 != _eType2)
117 SAL_INFO(
"connectivity.commontools",
"ORowSetValue::isStorageCompatible _eType1 != _eType2" );
121 case DataType::VARCHAR:
122 case DataType::LONGVARCHAR:
123 bIsComparable = (DataType::CHAR == _eType2)
124 || (DataType::VARCHAR == _eType2)
125 || (DataType::LONGVARCHAR == _eType2);
128 case DataType::DECIMAL:
129 case DataType::NUMERIC:
130 bIsComparable = (DataType::DECIMAL == _eType2)
131 || (DataType::NUMERIC == _eType2);
134 case DataType::DOUBLE:
136 bIsComparable = (DataType::DOUBLE == _eType2)
137 || (DataType::REAL == _eType2);
140 case DataType::BINARY:
141 case DataType::VARBINARY:
142 case DataType::LONGVARBINARY:
143 bIsComparable = (DataType::BINARY == _eType2)
144 || (DataType::VARBINARY == _eType2)
145 || (DataType::LONGVARBINARY == _eType2);
148 case DataType::INTEGER:
149 bIsComparable = (DataType::SMALLINT == _eType2)
150 || (DataType::TINYINT == _eType2)
151 || (DataType::BIT == _eType2)
152 || (DataType::BOOLEAN == _eType2);
154 case DataType::SMALLINT:
155 bIsComparable = (DataType::TINYINT == _eType2)
156 || (DataType::BIT == _eType2)
157 || (DataType::BOOLEAN == _eType2);
159 case DataType::TINYINT:
160 bIsComparable = (DataType::BIT == _eType2)
161 || (DataType::BOOLEAN == _eType2);
166 case DataType::OBJECT:
167 bIsComparable = (DataType::BLOB == _eType2)
168 || (DataType::CLOB == _eType2)
169 || (DataType::OBJECT == _eType2);
173 bIsComparable =
false;
176 return bIsComparable;
186 case DataType::VARCHAR:
188 case DataType::DECIMAL:
189 case DataType::NUMERIC:
190 case DataType::LONGVARCHAR:
193 case DataType::BIGINT:
197 if (nVal == 0 && nuVal != 0)
204 case DataType::FLOAT:
207 case DataType::DOUBLE:
211 case DataType::TINYINT:
214 case DataType::SMALLINT:
217 case DataType::INTEGER:
221 if (nVal == 0 && nuVal != 0)
228 case DataType::BOOLEAN:
237 case DataType::TIMESTAMP:
240 case DataType::BINARY:
241 case DataType::VARBINARY:
242 case DataType::LONGVARBINARY:
247 case DataType::OBJECT:
248 case DataType::OTHER:
253 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!");
269 case DataType::VARCHAR:
270 case DataType::DECIMAL:
271 case DataType::NUMERIC:
272 case DataType::LONGVARCHAR:
273 OSL_ENSURE(
m_aValue.m_pString,
"String pointer is null!");
274 rtl_uString_release(
m_aValue.m_pString);
278 delete static_cast<css::util::Date*
>(
m_aValue.m_pValue);
282 delete static_cast<css::util::Time*
>(
m_aValue.m_pValue);
285 case DataType::TIMESTAMP:
286 delete static_cast<css::util::DateTime*
>(
m_aValue.m_pValue);
289 case DataType::BINARY:
290 case DataType::VARBINARY:
291 case DataType::LONGVARBINARY:
292 delete static_cast<Sequence<sal_Int8>*
>(
m_aValue.m_pValue);
297 case DataType::OBJECT:
302 case DataType::TINYINT:
303 case DataType::SMALLINT:
304 case DataType::INTEGER:
305 case DataType::BIGINT:
306 case DataType::BOOLEAN:
307 case DataType::FLOAT:
308 case DataType::DOUBLE:
340 case DataType::VARCHAR:
341 case DataType::DECIMAL:
342 case DataType::NUMERIC:
343 case DataType::LONGVARCHAR:
353 case DataType::TIMESTAMP:
356 case DataType::BINARY:
357 case DataType::VARBINARY:
358 case DataType::LONGVARBINARY:
362 case DataType::BOOLEAN:
365 case DataType::TINYINT:
371 case DataType::SMALLINT:
377 case DataType::INTEGER:
383 case DataType::BIGINT:
389 case DataType::FLOAT:
392 case DataType::DOUBLE:
405 case DataType::VARCHAR:
406 case DataType::DECIMAL:
407 case DataType::NUMERIC:
408 case DataType::LONGVARCHAR:
417 case DataType::TIMESTAMP:
420 case DataType::BINARY:
421 case DataType::VARBINARY:
422 case DataType::LONGVARBINARY:
426 case DataType::BOOLEAN:
429 case DataType::TINYINT:
435 case DataType::SMALLINT:
441 case DataType::INTEGER:
447 case DataType::BIGINT:
453 case DataType::FLOAT:
456 case DataType::DOUBLE:
474 if ( m_eTypeKind != _rRH.m_eTypeKind || !m_bNull)
478 m_aValue = _rRH.m_aValue;
479 memset(&_rRH.m_aValue, 0,
sizeof(_rRH.m_aValue));
481 m_bBound = _rRH.m_bBound;
482 m_eTypeKind = _rRH.m_eTypeKind;
483 m_bSigned = _rRH.m_bSigned;
484 m_bNull = _rRH.m_bNull;
549 rtl_uString_acquire(
m_aValue.m_pString);
692 if (!isStorageCompatible(DataType::LONGVARBINARY,
m_eTypeKind))
697 m_aValue.m_pValue =
new Sequence<sal_Int8>(_rRH);
700 *
static_cast< Sequence< sal_Int8 >*
>(
m_aValue.m_pValue) = _rRH;
710 if (!isStorageCompatible(DataType::OBJECT,
m_eTypeKind))
739 case DataType::FLOAT:
740 case DataType::DOUBLE:
746 case DataType::FLOAT:
747 case DataType::DOUBLE:
759 OSL_ENSURE(!
m_bNull,
"Should not be null!");
762 case DataType::VARCHAR:
764 case DataType::LONGVARCHAR:
768 return aVal1 == aVal2;
778 case DataType::DECIMAL:
779 case DataType::NUMERIC:
783 bRet = aVal1 == aVal2;
786 case DataType::FLOAT:
789 case DataType::DOUBLE:
793 case DataType::TINYINT:
796 case DataType::SMALLINT:
799 case DataType::INTEGER:
802 case DataType::BIGINT:
806 case DataType::BOOLEAN:
815 case DataType::TIMESTAMP:
818 case DataType::BINARY:
819 case DataType::VARBINARY:
820 case DataType::LONGVARBINARY:
825 case DataType::OBJECT:
826 case DataType::OTHER:
831 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::operator==(): UNSUPPORTED TYPE!");
844 case DataType::SQLNULL:
845 assert(rValue ==
Any());
848 case DataType::VARCHAR:
849 case DataType::DECIMAL:
850 case DataType::NUMERIC:
851 case DataType::LONGVARCHAR:
852 OSL_ENSURE(
m_aValue.m_pString,
"Value is null!");
853 rValue <<= OUString(
m_aValue.m_pString);
855 case DataType::FLOAT:
858 case DataType::DOUBLE:
863 OSL_ENSURE(
m_aValue.m_pValue,
"Value is null!");
864 rValue <<= *static_cast<Date*>(
m_aValue.m_pValue);
867 OSL_ENSURE(
m_aValue.m_pValue,
"Value is null!");
868 rValue <<= *static_cast<Time*>(
m_aValue.m_pValue);
870 case DataType::TIMESTAMP:
871 OSL_ENSURE(
m_aValue.m_pValue,
"Value is null!");
872 rValue <<= *static_cast<DateTime*>(
m_aValue.m_pValue);
874 case DataType::BINARY:
875 case DataType::VARBINARY:
876 case DataType::LONGVARBINARY:
877 OSL_ENSURE(
m_aValue.m_pValue,
"Value is null!");
878 rValue <<= *static_cast<Sequence<sal_Int8>*>(
m_aValue.m_pValue);
882 case DataType::OBJECT:
883 case DataType::OTHER:
887 case DataType::BOOLEAN:
890 case DataType::TINYINT:
898 rValue <<= static_cast<sal_uInt16>(
m_aValue.m_uInt8);
900 case DataType::SMALLINT:
908 case DataType::INTEGER:
916 case DataType::BIGINT:
925 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::makeAny(): UNSUPPORTED TYPE!");
941 case DataType::VARCHAR:
942 case DataType::DECIMAL:
943 case DataType::NUMERIC:
944 case DataType::LONGVARCHAR:
947 case DataType::FLOAT:
948 aRet = OUString::number(
getFloat());
950 case DataType::DOUBLE:
960 case DataType::TIMESTAMP:
963 case DataType::BINARY:
964 case DataType::VARBINARY:
965 case DataType::LONGVARBINARY:
967 OUStringBuffer sVal(
"0x");
971 for(;pBegin != pEnd;++pBegin)
972 sVal.append(
static_cast<sal_Int32
>(*pBegin),16);
973 aRet = sVal.makeStringAndClear();
977 aRet = OUString::number(
int(
getBool()));
979 case DataType::BOOLEAN:
980 aRet = OUString::boolean(
getBool());
982 case DataType::TINYINT:
983 case DataType::SMALLINT:
984 case DataType::INTEGER:
986 aRet = OUString::number(
getInt32());
990 case DataType::BIGINT:
992 aRet = OUString::number(
getLong());
994 aRet = OUString::number(
getULong());
999 Reference< XClob > xClob;
1000 if ( (aValue >>= xClob) && xClob.is() )
1002 aRet = xClob->getSubString(1,
static_cast<sal_Int32
>(xClob->length()) );
1024 case DataType::CHAR:
1025 case DataType::VARCHAR:
1026 case DataType::LONGVARCHAR:
1028 const OUString sValue(
m_aValue.m_pString);
1029 if ( sValue.equalsIgnoreAsciiCase(
"true") || (sValue ==
"1") )
1034 else if ( sValue.equalsIgnoreAsciiCase(
"false") || (sValue ==
"0") )
1041 case DataType::DECIMAL:
1042 case DataType::NUMERIC:
1044 bRet = OUString::unacquired(&
m_aValue.m_pString).toInt32() != 0;
1046 case DataType::FLOAT:
1049 case DataType::DOUBLE:
1050 case DataType::REAL:
1053 case DataType::DATE:
1054 case DataType::TIME:
1055 case DataType::TIMESTAMP:
1056 case DataType::BINARY:
1057 case DataType::VARBINARY:
1058 case DataType::LONGVARBINARY:
1059 OSL_FAIL(
"getBool() for this type is not allowed!");
1062 case DataType::BOOLEAN:
1065 case DataType::TINYINT:
1068 case DataType::SMALLINT:
1071 case DataType::INTEGER:
1074 case DataType::BIGINT:
1096 case DataType::CHAR:
1097 case DataType::VARCHAR:
1098 case DataType::DECIMAL:
1099 case DataType::NUMERIC:
1100 case DataType::LONGVARCHAR:
1103 case DataType::FLOAT:
1106 case DataType::DOUBLE:
1107 case DataType::REAL:
1110 case DataType::DATE:
1111 case DataType::TIME:
1112 case DataType::TIMESTAMP:
1113 case DataType::BINARY:
1114 case DataType::VARBINARY:
1115 case DataType::LONGVARBINARY:
1116 case DataType::BLOB:
1117 case DataType::CLOB:
1118 OSL_FAIL(
"getInt8() for this type is not allowed!");
1121 case DataType::BOOLEAN:
1124 case DataType::TINYINT:
1130 case DataType::SMALLINT:
1136 case DataType::INTEGER:
1142 case DataType::BIGINT:
1167 case DataType::CHAR:
1168 case DataType::VARCHAR:
1169 case DataType::DECIMAL:
1170 case DataType::NUMERIC:
1171 case DataType::LONGVARCHAR:
1174 case DataType::FLOAT:
1177 case DataType::DOUBLE:
1178 case DataType::REAL:
1181 case DataType::DATE:
1182 case DataType::TIME:
1183 case DataType::TIMESTAMP:
1184 case DataType::BINARY:
1185 case DataType::VARBINARY:
1186 case DataType::LONGVARBINARY:
1187 case DataType::BLOB:
1188 case DataType::CLOB:
1189 OSL_FAIL(
"getuInt8() for this type is not allowed!");
1192 case DataType::BOOLEAN:
1195 case DataType::TINYINT:
1201 case DataType::SMALLINT:
1207 case DataType::INTEGER:
1213 case DataType::BIGINT:
1242 case DataType::CHAR:
1243 case DataType::VARCHAR:
1244 case DataType::DECIMAL:
1245 case DataType::NUMERIC:
1246 case DataType::LONGVARCHAR:
1247 nRet = sal_Int16(OUString::unacquired(&
m_aValue.m_pString).toInt32());
1249 case DataType::FLOAT:
1250 nRet = sal_Int16(
m_aValue.m_nFloat);
1252 case DataType::DOUBLE:
1253 case DataType::REAL:
1254 nRet = sal_Int16(
m_aValue.m_nDouble);
1256 case DataType::DATE:
1257 case DataType::TIME:
1258 case DataType::TIMESTAMP:
1259 case DataType::BINARY:
1260 case DataType::VARBINARY:
1261 case DataType::LONGVARBINARY:
1262 case DataType::BLOB:
1263 case DataType::CLOB:
1264 OSL_FAIL(
"getInt16() for this type is not allowed!");
1267 case DataType::BOOLEAN:
1268 nRet = sal_Int16(
m_aValue.m_bBool);
1270 case DataType::TINYINT:
1276 case DataType::SMALLINT:
1280 nRet =
static_cast<sal_Int16
>(
m_aValue.m_uInt16);
1282 case DataType::INTEGER:
1284 nRet =
static_cast<sal_Int16
>(
m_aValue.m_nInt32);
1286 nRet =
static_cast<sal_Int16
>(
m_aValue.m_uInt32);
1288 case DataType::BIGINT:
1290 nRet =
static_cast<sal_Int16
>(
m_aValue.m_nInt64);
1292 nRet =
static_cast<sal_Int16
>(
m_aValue.m_uInt64);
1308 sal_uInt16 nRet = 0;
1313 case DataType::CHAR:
1314 case DataType::VARCHAR:
1315 case DataType::DECIMAL:
1316 case DataType::NUMERIC:
1317 case DataType::LONGVARCHAR:
1318 nRet = sal_uInt16(OUString::unacquired(&
m_aValue.m_pString).toInt32());
1320 case DataType::FLOAT:
1321 nRet = sal_uInt16(
m_aValue.m_nFloat);
1323 case DataType::DOUBLE:
1324 case DataType::REAL:
1325 nRet = sal_uInt16(
m_aValue.m_nDouble);
1327 case DataType::DATE:
1328 case DataType::TIME:
1329 case DataType::TIMESTAMP:
1330 case DataType::BINARY:
1331 case DataType::VARBINARY:
1332 case DataType::LONGVARBINARY:
1333 case DataType::BLOB:
1334 case DataType::CLOB:
1335 OSL_FAIL(
"getuInt16() for this type is not allowed!");
1338 case DataType::BOOLEAN:
1339 nRet = sal_uInt16(
m_aValue.m_bBool);
1341 case DataType::TINYINT:
1347 case DataType::SMALLINT:
1353 case DataType::INTEGER:
1355 nRet =
static_cast<sal_uInt16
>(
m_aValue.m_nInt32);
1357 nRet =
static_cast<sal_uInt16
>(
m_aValue.m_uInt32);
1359 case DataType::BIGINT:
1361 nRet =
static_cast<sal_uInt16
>(
m_aValue.m_nInt64);
1363 nRet =
static_cast<sal_uInt16
>(
m_aValue.m_uInt64);
1384 case DataType::CHAR:
1385 case DataType::VARCHAR:
1386 case DataType::DECIMAL:
1387 case DataType::NUMERIC:
1388 case DataType::LONGVARCHAR:
1389 nRet = OUString::unacquired(&
m_aValue.m_pString).toInt32();
1391 case DataType::FLOAT:
1392 nRet = sal_Int32(
m_aValue.m_nFloat);
1394 case DataType::DOUBLE:
1395 case DataType::REAL:
1396 nRet = sal_Int32(
m_aValue.m_nDouble);
1398 case DataType::DATE:
1401 case DataType::TIME:
1402 case DataType::TIMESTAMP:
1403 case DataType::BINARY:
1404 case DataType::VARBINARY:
1405 case DataType::LONGVARBINARY:
1406 case DataType::BLOB:
1407 case DataType::CLOB:
1408 OSL_FAIL(
"getInt32() for this type is not allowed!");
1411 case DataType::BOOLEAN:
1412 nRet = sal_Int32(
m_aValue.m_bBool);
1414 case DataType::TINYINT:
1420 case DataType::SMALLINT:
1426 case DataType::INTEGER:
1430 nRet =
static_cast<sal_Int32
>(
m_aValue.m_uInt32);
1432 case DataType::BIGINT:
1434 nRet =
static_cast<sal_Int32
>(
m_aValue.m_nInt64);
1436 nRet =
static_cast<sal_Int32
>(
m_aValue.m_uInt64);
1452 sal_uInt32 nRet = 0;
1457 case DataType::CHAR:
1458 case DataType::VARCHAR:
1459 case DataType::DECIMAL:
1460 case DataType::NUMERIC:
1461 case DataType::LONGVARCHAR:
1462 nRet = OUString::unacquired(&
m_aValue.m_pString).toUInt32();
1464 case DataType::FLOAT:
1465 nRet = sal_uInt32(
m_aValue.m_nFloat);
1467 case DataType::DOUBLE:
1468 case DataType::REAL:
1469 nRet = sal_uInt32(
m_aValue.m_nDouble);
1471 case DataType::DATE:
1474 case DataType::TIME:
1475 case DataType::TIMESTAMP:
1476 case DataType::BINARY:
1477 case DataType::VARBINARY:
1478 case DataType::LONGVARBINARY:
1479 case DataType::BLOB:
1480 case DataType::CLOB:
1481 OSL_FAIL(
"getuInt32() for this type is not allowed!");
1484 case DataType::BOOLEAN:
1485 nRet = sal_uInt32(
m_aValue.m_bBool);
1487 case DataType::TINYINT:
1493 case DataType::SMALLINT:
1499 case DataType::INTEGER:
1505 case DataType::BIGINT:
1507 nRet =
static_cast<sal_uInt32
>(
m_aValue.m_nInt64);
1509 nRet =
static_cast<sal_uInt32
>(
m_aValue.m_uInt64);
1530 case DataType::CHAR:
1531 case DataType::VARCHAR:
1532 case DataType::DECIMAL:
1533 case DataType::NUMERIC:
1534 case DataType::LONGVARCHAR:
1535 nRet = OUString::unacquired(&
m_aValue.m_pString).toInt64();
1537 case DataType::FLOAT:
1538 nRet = sal_Int64(
m_aValue.m_nFloat);
1540 case DataType::DOUBLE:
1541 case DataType::REAL:
1542 nRet = sal_Int64(
m_aValue.m_nDouble);
1544 case DataType::DATE:
1547 case DataType::TIME:
1548 case DataType::TIMESTAMP:
1549 case DataType::BINARY:
1550 case DataType::VARBINARY:
1551 case DataType::LONGVARBINARY:
1552 case DataType::BLOB:
1553 case DataType::CLOB:
1554 OSL_FAIL(
"getLong() for this type is not allowed!");
1557 case DataType::BOOLEAN:
1558 nRet = sal_Int64(
m_aValue.m_bBool);
1560 case DataType::TINYINT:
1566 case DataType::SMALLINT:
1572 case DataType::INTEGER:
1578 case DataType::BIGINT:
1582 nRet =
static_cast<sal_Int64
>(
m_aValue.m_uInt64);
1598 sal_uInt64 nRet = 0;
1603 case DataType::CHAR:
1604 case DataType::VARCHAR:
1605 case DataType::DECIMAL:
1606 case DataType::NUMERIC:
1607 case DataType::LONGVARCHAR:
1608 nRet = OUString::unacquired(&
m_aValue.m_pString).toUInt64();
1610 case DataType::FLOAT:
1611 nRet = sal_uInt64(
m_aValue.m_nFloat);
1613 case DataType::DOUBLE:
1614 case DataType::REAL:
1615 nRet = sal_uInt64(
m_aValue.m_nDouble);
1617 case DataType::DATE:
1620 case DataType::TIME:
1621 case DataType::TIMESTAMP:
1622 case DataType::BINARY:
1623 case DataType::VARBINARY:
1624 case DataType::LONGVARBINARY:
1625 case DataType::BLOB:
1626 case DataType::CLOB:
1627 OSL_FAIL(
"getULong() for this type is not allowed!");
1630 case DataType::BOOLEAN:
1631 nRet = sal_uInt64(
m_aValue.m_bBool);
1633 case DataType::TINYINT:
1639 case DataType::SMALLINT:
1645 case DataType::INTEGER:
1651 case DataType::BIGINT:
1676 case DataType::CHAR:
1677 case DataType::VARCHAR:
1678 case DataType::DECIMAL:
1679 case DataType::NUMERIC:
1680 case DataType::LONGVARCHAR:
1681 nRet = OUString::unacquired(&
m_aValue.m_pString).toFloat();
1683 case DataType::FLOAT:
1686 case DataType::DOUBLE:
1687 case DataType::REAL:
1688 nRet =
static_cast<float>(
m_aValue.m_nDouble);
1690 case DataType::DATE:
1693 case DataType::TIME:
1696 case DataType::TIMESTAMP:
1699 case DataType::BINARY:
1700 case DataType::VARBINARY:
1701 case DataType::LONGVARBINARY:
1702 case DataType::BLOB:
1703 case DataType::CLOB:
1704 OSL_FAIL(
"getDouble() for this type is not allowed!");
1707 case DataType::BOOLEAN:
1710 case DataType::TINYINT:
1716 case DataType::SMALLINT:
1720 nRet =
static_cast<float>(
m_aValue.m_uInt16);
1722 case DataType::INTEGER:
1724 nRet =
static_cast<float>(
m_aValue.m_nInt32);
1726 nRet =
static_cast<float>(
m_aValue.m_uInt32);
1728 case DataType::BIGINT:
1730 nRet =
static_cast<float>(
m_aValue.m_nInt64);
1732 nRet =
static_cast<float>(
m_aValue.m_uInt64);
1752 case DataType::CHAR:
1753 case DataType::VARCHAR:
1754 case DataType::DECIMAL:
1755 case DataType::NUMERIC:
1756 case DataType::LONGVARCHAR:
1757 nRet = OUString::unacquired(&
m_aValue.m_pString).toDouble();
1759 case DataType::FLOAT:
1762 case DataType::DOUBLE:
1763 case DataType::REAL:
1766 case DataType::DATE:
1769 case DataType::TIME:
1772 case DataType::TIMESTAMP:
1775 case DataType::BINARY:
1776 case DataType::VARBINARY:
1777 case DataType::LONGVARBINARY:
1778 case DataType::BLOB:
1779 case DataType::CLOB:
1780 OSL_FAIL(
"getDouble() for this type is not allowed!");
1783 case DataType::BOOLEAN:
1786 case DataType::TINYINT:
1792 case DataType::SMALLINT:
1798 case DataType::INTEGER:
1804 case DataType::BIGINT:
1823 Sequence<sal_Int8>
aSeq;
1828 case DataType::OBJECT:
1829 case DataType::CLOB:
1830 case DataType::BLOB:
1832 Reference<XInputStream>
xStream;
1834 if(aValue.hasValue())
1836 Reference<XBlob> xBlob(aValue,UNO_QUERY);
1838 xStream = xBlob->getBinaryStream();
1841 Reference<XClob> xClob(aValue,UNO_QUERY);
1843 xStream = xClob->getCharacterStream();
1847 const sal_uInt32 nBytesToRead = 65535;
1852 css::uno::Sequence< sal_Int8 > aReadSeq;
1854 nRead =
xStream->readSomeBytes( aReadSeq, nBytesToRead );
1858 const sal_uInt32 nOldLength =
aSeq.getLength();
1859 aSeq.realloc( nOldLength + nRead );
1860 memcpy(
aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
1863 while( nBytesToRead == nRead );
1869 case DataType::VARCHAR:
1870 case DataType::LONGVARCHAR:
1876 case DataType::BINARY:
1877 case DataType::VARBINARY:
1878 case DataType::LONGVARBINARY:
1879 aSeq = *
static_cast< Sequence<sal_Int8>*
>(
m_aValue.m_pValue);
1895 css::util::Date aValue;
1900 case DataType::CHAR:
1901 case DataType::VARCHAR:
1902 case DataType::LONGVARCHAR:
1905 case DataType::DECIMAL:
1906 case DataType::NUMERIC:
1907 case DataType::FLOAT:
1908 case DataType::DOUBLE:
1909 case DataType::REAL:
1913 case DataType::DATE:
1914 aValue = *
static_cast< css::util::Date*
>(
m_aValue.m_pValue);
1916 case DataType::TIMESTAMP:
1918 css::util::DateTime* pDateTime =
static_cast< css::util::DateTime*
>(
m_aValue.m_pValue);
1919 aValue.Day = pDateTime->Day;
1920 aValue.Month = pDateTime->Month;
1921 aValue.Year = pDateTime->Year;
1925 case DataType::BOOLEAN:
1926 case DataType::TINYINT:
1927 case DataType::SMALLINT:
1928 case DataType::INTEGER:
1929 case DataType::BIGINT:
1933 case DataType::BLOB:
1934 case DataType::CLOB:
1935 case DataType::OBJECT:
1937 OSL_ENSURE(
false,
"ORowSetValue::getDate: cannot retrieve the data!" );
1940 case DataType::BINARY:
1941 case DataType::VARBINARY:
1942 case DataType::LONGVARBINARY:
1943 case DataType::TIME:
1953 css::util::Time aValue;
1958 case DataType::CHAR:
1959 case DataType::VARCHAR:
1960 case DataType::LONGVARCHAR:
1963 case DataType::DECIMAL:
1964 case DataType::NUMERIC:
1967 case DataType::FLOAT:
1968 case DataType::DOUBLE:
1969 case DataType::REAL:
1972 case DataType::TIMESTAMP:
1974 css::util::DateTime* pDateTime =
static_cast< css::util::DateTime*
>(
m_aValue.m_pValue);
1975 aValue.NanoSeconds = pDateTime->NanoSeconds;
1976 aValue.Seconds = pDateTime->Seconds;
1977 aValue.Minutes = pDateTime->Minutes;
1978 aValue.Hours = pDateTime->Hours;
1981 case DataType::TIME:
1982 aValue = *
static_cast< css::util::Time*
>(
m_aValue.m_pValue);
1987 aAnyValue >>= aValue;
1997 css::util::DateTime aValue;
2002 case DataType::CHAR:
2003 case DataType::VARCHAR:
2004 case DataType::LONGVARCHAR:
2007 case DataType::DECIMAL:
2008 case DataType::NUMERIC:
2011 case DataType::FLOAT:
2012 case DataType::DOUBLE:
2013 case DataType::REAL:
2016 case DataType::DATE:
2018 css::util::Date* pDate =
static_cast< css::util::Date*
>(
m_aValue.m_pValue);
2019 aValue.Day = pDate->Day;
2020 aValue.Month = pDate->Month;
2021 aValue.Year = pDate->Year;
2024 case DataType::TIME:
2026 css::util::Time* pTime =
static_cast< css::util::Time*
>(
m_aValue.m_pValue);
2027 aValue.NanoSeconds = pTime->NanoSeconds;
2028 aValue.Seconds = pTime->Seconds;
2029 aValue.Minutes = pTime->Minutes;
2030 aValue.Hours = pTime->Hours;
2033 case DataType::TIMESTAMP:
2034 aValue = *
static_cast< css::util::DateTime*
>(
m_aValue.m_pValue);
2039 aAnyValue >>= aValue;
2059 case DataType::TINYINT:
2069 case DataType::SMALLINT:
2079 case DataType::INTEGER:
2089 case DataType::BIGINT:
2093 auto nTmp =
static_cast<sal_Int64
>(
m_aValue.m_uInt64);
2098 auto nTmp =
static_cast<sal_uInt64
>(
m_aValue.m_nInt64);
2135 class RowValue :
public IValueSource
2138 RowValue(
const Reference< XRow >& _xRow,
const sal_Int32 _nPos )
2146 virtual bool getBoolean()
const override {
return m_xRow->getBoolean(
m_nPos ); };
2148 virtual sal_Int16 getShort()
const override {
return m_xRow->getShort(
m_nPos ); }
2149 virtual sal_Int32 getInt()
const override {
return m_xRow->getInt(
m_nPos ); }
2150 virtual sal_Int64 getLong()
const override {
return m_xRow->getLong(
m_nPos ); }
2153 virtual Date getDate()
const override {
return m_xRow->getDate(
m_nPos ); };
2154 virtual css::util::Time getTime()
const override {
return m_xRow->getTime(
m_nPos ); };
2156 virtual Sequence< sal_Int8 > getBytes()
const override {
return m_xRow->getBytes(
m_nPos ); };
2157 virtual Reference< XBlob > getBlob()
const override {
return m_xRow->getBlob(
m_nPos ); };
2158 virtual Reference< XClob > getClob()
const override {
return m_xRow->getClob(
m_nPos ); };
2159 virtual Any getObject()
const override {
return m_xRow->getObject(
m_nPos ,
nullptr); };
2160 virtual bool wasNull()
const override {
return m_xRow->wasNull( ); };
2167 class ColumnValue :
public IValueSource
2170 explicit ColumnValue(
const Reference< XColumn >& _rxColumn )
2177 virtual bool getBoolean()
const override {
return m_xColumn->getBoolean(); };
2179 virtual sal_Int16 getShort()
const override {
return m_xColumn->getShort(); }
2180 virtual sal_Int32 getInt()
const override {
return m_xColumn->getInt(); }
2181 virtual sal_Int64 getLong()
const override {
return m_xColumn->getLong(); }
2184 virtual Date getDate()
const override {
return m_xColumn->getDate(); };
2185 virtual css::util::Time getTime()
const override {
return m_xColumn->getTime(); };
2186 virtual DateTime getTimestamp()
const override {
return m_xColumn->getTimestamp(); };
2187 virtual Sequence< sal_Int8 > getBytes()
const override {
return m_xColumn->getBytes(); };
2188 virtual Reference< XBlob > getBlob()
const override {
return m_xColumn->getBlob(); };
2189 virtual Reference< XClob > getClob()
const override {
return m_xColumn->getClob(); };
2190 virtual Any getObject()
const override {
return m_xColumn->getObject(
nullptr ); };
2191 virtual bool wasNull()
const override {
return m_xColumn->wasNull( ); };
2201void ORowSetValue::fill(
const sal_Int32 _nType,
const Reference< XColumn >& _rxColumn )
2203 detail::ColumnValue aColumnValue( _rxColumn );
2204 impl_fill( _nType,
true, aColumnValue );
2208void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType,
bool _bNullable,
const Reference< XRow>& _xRow )
2210 detail::RowValue aRowValue( _xRow, _nPos );
2211 impl_fill( _nType, _bNullable, aRowValue );
2217 const css::uno::Reference< css::sdbc::XRow>& _xRow)
2227 case DataType::CHAR:
2228 case DataType::VARCHAR:
2229 case DataType::DECIMAL:
2230 case DataType::NUMERIC:
2231 case DataType::LONGVARCHAR:
2234 case DataType::BIGINT:
2236 (*this) = _rValueSource.
getLong();
2242 (*this) = _rValueSource.
getString().toUInt64();
2244 case DataType::FLOAT:
2245 (*this) = _rValueSource.
getFloat();
2247 case DataType::DOUBLE:
2248 case DataType::REAL:
2251 case DataType::DATE:
2252 (*this) = _rValueSource.
getDate();
2254 case DataType::TIME:
2255 (*this) = _rValueSource.
getTime();
2257 case DataType::TIMESTAMP:
2260 case DataType::BINARY:
2261 case DataType::VARBINARY:
2262 case DataType::LONGVARBINARY:
2263 (*this) = _rValueSource.
getBytes();
2266 case DataType::BOOLEAN:
2269 case DataType::TINYINT:
2271 (*this) = _rValueSource.
getByte();
2273 (*
this) = _rValueSource.
getShort();
2275 case DataType::SMALLINT:
2277 (*this) = _rValueSource.
getShort();
2279 (*
this) = _rValueSource.
getInt();
2281 case DataType::INTEGER:
2283 (*this) = _rValueSource.
getInt();
2285 (*
this) = _rValueSource.
getLong();
2287 case DataType::CLOB:
2288 (*this) = css::uno::Any(_rValueSource.
getClob());
2291 case DataType::BLOB:
2292 (*this) = css::uno::Any(_rValueSource.
getBlob());
2295 case DataType::OTHER:
2300 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::fill: unsupported type!" );
2304 if ( _bNullable && _rValueSource.
wasNull() )
2311 switch (_rValue.getValueType().getTypeClass())
2313 case TypeClass_VOID:
2315 case TypeClass_BOOLEAN:
2317 bool bValue(
false );
2322 case TypeClass_CHAR:
2326 (*this) = OUString(aDummy);
2329 case TypeClass_STRING:
2336 case TypeClass_FLOAT:
2343 case TypeClass_DOUBLE:
2350 case TypeClass_BYTE:
2357 case TypeClass_SHORT:
2359 sal_Int16 aDummy(0);
2364 case TypeClass_UNSIGNED_SHORT:
2371 case TypeClass_LONG:
2373 sal_Int32 aDummy(0);
2378 case TypeClass_UNSIGNED_LONG:
2382 (*this) =
static_cast<sal_Int64
>(
nValue);
2386 case TypeClass_HYPER:
2393 case TypeClass_UNSIGNED_HYPER:
2401 case TypeClass_ENUM:
2403 sal_Int32 enumValue( 0 );
2404 ::cppu::enum2int( enumValue, _rValue );
2405 (*this) = enumValue;
2409 case TypeClass_SEQUENCE:
2411 Sequence<sal_Int8> aDummy;
2412 if ( _rValue >>= aDummy )
2415 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::fill: unsupported sequence type!" );
2419 case TypeClass_STRUCT:
2421 css::util::Date aDate;
2422 css::util::Time aTime;
2423 css::util::DateTime aDateTime;
2424 if ( _rValue >>= aDate )
2428 else if ( _rValue >>= aTime )
2432 else if ( _rValue >>= aDateTime )
2434 (*this) = aDateTime;
2437 SAL_WARN(
"connectivity.commontools",
"ORowSetValue::fill: unsupported structure!" );
2441 case TypeClass_INTERFACE:
2443 Reference< XClob > xClob;
2444 if ( _rValue >>= xClob )
2451 Reference< XBlob > xBlob;
2452 if ( _rValue >>= xBlob )
2466 SAL_WARN(
"connectivity.commontools",
"Unknown type");
const Reference< XRow > m_xRow
const Reference< XColumn > m_xColumn
sal_uInt16 getUInt16() const
css::util::Time getTime() const
sal_uInt64 getULong() const
sal_Int32 getInt32() const
sal_uInt8 getUInt8() const
OUString getString() const
void impl_fill(const sal_Int32 _nType, bool _bNullable, const detail::IValueSource &_rValueSource)
css::uno::Any makeAny() const
ORowSetValue & operator=(const ORowSetValue &_rRH)
bool operator==(const ORowSetValue &_rRH) const
sal_Int32 getTypeKind() const
sal_Int16 getInt16() const
void setTypeKind(sal_Int32 _eType)
css::util::Date getDate() const
css::util::DateTime getDateTime() const
void fill(sal_Int32 _nPos, sal_Int32 _nType, const css::uno::Reference< css::sdbc::XRow > &_xRow)
fetches a single value out of the row
void setSigned(bool _bSig)
sal_Int64 getLong() const
const css::uno::Any & getAny() const
union connectivity::ORowSetValue::@1 m_aValue
sal_uInt32 getUInt32() const
css::uno::Sequence< sal_Int8 > getSequence() const
virtual Date getDate() const =0
virtual bool wasNull() const =0
virtual OUString getString() const =0
virtual Any getObject() const =0
virtual sal_Int32 getInt() const =0
virtual css::util::Time getTime() const =0
virtual double getDouble() const =0
virtual Sequence< sal_Int8 > getBytes() const =0
virtual Reference< XBlob > getBlob() const =0
virtual sal_Int8 getByte() const =0
virtual Reference< XClob > getClob() const =0
virtual sal_Int16 getShort() const =0
virtual bool getBoolean() const =0
virtual float getFloat() const =0
virtual DateTime getTimestamp() const =0
virtual sal_Int64 getLong() const =0
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
double getDouble(const Any &_rAny)
float getFloat(const Any &_rAny)
OUString getString(const Any &_rAny)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int