switch(m_eTypeKind)
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
rtl_uString_release(m_aValue.m_pString);
m_aValue.m_pString = nullptr; break; case DataType::DATE: deletestatic_cast<css::util::Date*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr; break; case DataType::TIME: deletestatic_cast<css::util::Time*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr; break; case DataType::TIMESTAMP: deletestatic_cast<css::util::DateTime*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr; break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: deletestatic_cast<Sequence<sal_Int8>*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr; break; case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: deletestatic_cast<Any*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr; break; case DataType::BIT: case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: case DataType::BIGINT: case DataType::BOOLEAN: case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: break; default: if ( m_aValue.m_pValue )
{ deletestatic_cast<Any*>(m_aValue.m_pValue);
m_aValue.m_pValue = nullptr;
} break;
if ( !isStorageComparable(m_eTypeKind, _rRH.m_eTypeKind ))
{ switch(m_eTypeKind)
{ case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); default: switch(_rRH.m_eTypeKind)
{ case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL: return getDouble() == _rRH.getDouble(); default: break;
} break;
} returnfalse;
}
bool bRet = false;
OSL_ENSURE(!m_bNull,"Should not be null!"); switch(m_eTypeKind)
{ case DataType::VARCHAR: case DataType::CHAR: case DataType::LONGVARCHAR:
{
OUString aVal1(m_aValue.m_pString);
OUString aVal2(_rRH.m_aValue.m_pString); return aVal1 == aVal2;
} default: if ( m_bSigned != _rRH.m_bSigned ) returnfalse; break;
}
switch(m_eTypeKind)
{ case DataType::DECIMAL: case DataType::NUMERIC:
{
OUString aVal1(m_aValue.m_pString);
OUString aVal2(_rRH.m_aValue.m_pString);
bRet = aVal1 == aVal2;
} break; case DataType::FLOAT:
bRet = m_aValue.m_nFloat == _rRH.m_aValue.m_nFloat; break; case DataType::DOUBLE: case DataType::REAL:
bRet = m_aValue.m_nDouble == _rRH.m_aValue.m_nDouble; break; case DataType::TINYINT:
bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_uInt8 == _rRH.m_aValue.m_uInt8); break; case DataType::SMALLINT:
bRet = m_bSigned ? ( m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16 ) : (m_aValue.m_uInt16 == _rRH.m_aValue.m_uInt16); break; case DataType::INTEGER:
bRet = m_bSigned ? ( m_aValue.m_nInt32 == _rRH.m_aValue.m_nInt32 ) : (m_aValue.m_uInt32 == _rRH.m_aValue.m_uInt32); break; case DataType::BIGINT:
bRet = m_bSigned ? ( m_aValue.m_nInt64 == _rRH.m_aValue.m_nInt64 ) : (m_aValue.m_uInt64 == _rRH.m_aValue.m_uInt64); break; case DataType::BIT: case DataType::BOOLEAN:
bRet = m_aValue.m_bBool == _rRH.m_aValue.m_bBool; break; case DataType::DATE:
bRet = *static_cast<Date*>(m_aValue.m_pValue) == *static_cast<Date*>(_rRH.m_aValue.m_pValue); break; case DataType::TIME:
bRet = *static_cast<Time*>(m_aValue.m_pValue) == *static_cast<Time*>(_rRH.m_aValue.m_pValue); break; case DataType::TIMESTAMP:
bRet = *static_cast<DateTime*>(m_aValue.m_pValue) == *static_cast<DateTime*>(_rRH.m_aValue.m_pValue); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: case DataType::OTHER:
bRet = false; break; default:
bRet = false;
SAL_WARN( "connectivity.commontools","ORowSetValue::operator==(): UNSUPPORTED TYPE!"); break;
} return bRet;
}
Any ORowSetValue::makeAny() const
{
Any rValue; if(isBound() && !isNull())
{ switch(getTypeKind())
{ case DataType::SQLNULL:
assert(rValue == Any()); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
OSL_ENSURE(m_aValue.m_pString,"Value is null!");
rValue <<= OUString(m_aValue.m_pString); break; case DataType::FLOAT:
rValue <<= m_aValue.m_nFloat; break; case DataType::DOUBLE: case DataType::REAL:
rValue <<= m_aValue.m_nDouble; break; case DataType::DATE:
assert(m_aValue.m_pValue && "Value is null!");
rValue <<= *static_cast<Date*>(m_aValue.m_pValue); break; case DataType::TIME:
assert(m_aValue.m_pValue && "Value is null!");
rValue <<= *static_cast<Time*>(m_aValue.m_pValue); break; case DataType::TIMESTAMP:
assert(m_aValue.m_pValue && "Value is null!");
rValue <<= *static_cast<DateTime*>(m_aValue.m_pValue); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY:
assert(m_aValue.m_pValue && "Value is null!");
rValue <<= *static_cast<Sequence<sal_Int8>*>(m_aValue.m_pValue); break; case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: case DataType::OTHER:
rValue = getAny(); break; case DataType::BIT: case DataType::BOOLEAN:
rValue <<= m_aValue.m_bBool; break; case DataType::TINYINT: if ( m_bSigned ) // TypeClass_BYTE
rValue <<= m_aValue.m_nInt8; else // There is no TypeClass_UNSIGNED_BYTE, // so silently promote it to a 16-bit integer, // that is TypeClass_UNSIGNED_SHORT
rValue <<= static_cast<sal_uInt16>(m_aValue.m_uInt8); break; case DataType::SMALLINT: if ( m_bSigned ) // TypeClass_SHORT
rValue <<= m_aValue.m_nInt16; else // TypeClass_UNSIGNED_SHORT
rValue <<= m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned ) // TypeClass_LONG
rValue <<= m_aValue.m_nInt32; else // TypeClass_UNSIGNED_LONG
rValue <<= m_aValue.m_uInt32; break; case DataType::BIGINT: if ( m_bSigned ) // TypeClass_HYPER
rValue <<= m_aValue.m_nInt64; else // TypeClass_UNSIGNED_HYPER
rValue <<= m_aValue.m_uInt64; break; default:
SAL_WARN( "connectivity.commontools","ORowSetValue::makeAny(): UNSUPPORTED TYPE!");
rValue = getAny(); break;
}
} return rValue;
}
OUString ORowSetValue::getString( ) const
{
OUString aRet; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
aRet = m_aValue.m_pString; break; case DataType::FLOAT:
aRet = OUString::number(getFloat()); break; case DataType::DOUBLE: case DataType::REAL:
aRet = OUString::number(getDouble()); break; case DataType::DATE:
aRet = DBTypeConversion::toDateString(getDate()); break; case DataType::TIME:
aRet = DBTypeConversion::toTimeString(getTime()); break; case DataType::TIMESTAMP:
aRet = DBTypeConversion::toDateTimeString(getDateTime()); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY:
{
OUStringBuffer sVal("0x"); for (sal_Int32 byte : getSequence())
sVal.append(byte, 16);
aRet = sVal.makeStringAndClear();
} break; case DataType::BIT:
aRet = OUString::number(int(getBool())); break; case DataType::BOOLEAN:
aRet = OUString::boolean(getBool()); break; case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: if ( m_bSigned )
aRet = OUString::number(getInt32()); else
aRet = OUString::number(getUInt32()); break; case DataType::BIGINT: if ( m_bSigned )
aRet = OUString::number(getLong()); else
aRet = OUString::number(getULong()); break; case DataType::CLOB:
{
Any aValue( getAny() );
Reference< XClob > xClob; if ( (aValue >>= xClob) && xClob.is() )
{
aRet = xClob->getSubString(1,static_cast<sal_Int32>(xClob->length()) );
}
} break; default:
{
Any aValue = makeAny();
aValue >>= aRet; break;
}
}
} return aRet;
}
bool ORowSetValue::getBool() const
{ bool bRet = false; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR:
{ const OUString sValue(m_aValue.m_pString); if ( sValue.equalsIgnoreAsciiCase("true") || (sValue == "1") )
{
bRet = true; break;
} elseif ( sValue.equalsIgnoreAsciiCase("false") || (sValue == "0") )
{
bRet = false; break;
}
}
[[fallthrough]]; case DataType::DECIMAL: case DataType::NUMERIC:
bRet = OUString::unacquired(&m_aValue.m_pString).toInt32() != 0; break; case DataType::FLOAT:
bRet = m_aValue.m_nFloat != 0.0; break; case DataType::DOUBLE: case DataType::REAL:
bRet = m_aValue.m_nDouble != 0.0; break; case DataType::DATE: case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY:
OSL_FAIL("getBool() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
bRet = m_aValue.m_bBool; break; case DataType::TINYINT:
bRet = m_bSigned ? (m_aValue.m_nInt8 != 0) : (m_aValue.m_uInt8 != 0); break; case DataType::SMALLINT:
bRet = m_bSigned ? (m_aValue.m_nInt16 != 0) : (m_aValue.m_uInt16 != 0); break; case DataType::INTEGER:
bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (m_aValue.m_uInt32 != 0); break; case DataType::BIGINT:
bRet = m_bSigned ? (m_aValue.m_nInt64 != 0) : (m_aValue.m_uInt64 != 0); break; default:
{
Any aValue = makeAny();
aValue >>= bRet; break;
}
}
} return bRet;
}
sal_Int8 ORowSetValue::getInt8() const
{
sal_Int8 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = sal_Int8(OUString::unacquired(&m_aValue.m_pString).toInt32()); break; case DataType::FLOAT:
nRet = sal_Int8(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_Int8(m_aValue.m_nDouble); break; case DataType::DATE: case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getInt8() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_Int8(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = static_cast<sal_Int8>(m_aValue.m_uInt8); break; case DataType::SMALLINT: if ( m_bSigned )
nRet = static_cast<sal_Int8>(m_aValue.m_nInt16); else
nRet = static_cast<sal_Int8>(m_aValue.m_uInt16); break; case DataType::INTEGER: if ( m_bSigned )
nRet = static_cast<sal_Int8>(m_aValue.m_nInt32); else
nRet = static_cast<sal_Int8>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_Int8>(m_aValue.m_nInt64); else
nRet = static_cast<sal_Int8>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_uInt8 ORowSetValue::getUInt8() const
{
sal_uInt8 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = sal_uInt8(OUString::unacquired(&m_aValue.m_pString).toInt32()); break; case DataType::FLOAT:
nRet = sal_uInt8(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_uInt8(m_aValue.m_nDouble); break; case DataType::DATE: case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getuInt8() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = int(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = static_cast<sal_uInt8>(m_aValue.m_nInt16); else
nRet = static_cast<sal_uInt8>(m_aValue.m_uInt16); break; case DataType::INTEGER: if ( m_bSigned )
nRet = static_cast<sal_uInt8>(m_aValue.m_nInt32); else
nRet = static_cast<sal_uInt8>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_uInt8>(m_aValue.m_nInt64); else
nRet = static_cast<sal_uInt8>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny(); // Cf. "There is no TypeClass_UNSIGNED_BYTE" in makeAny:
sal_uInt16 n; if (aValue >>= n) {
nRet = static_cast<sal_uInt8>(n);
} break;
}
}
} return nRet;
}
sal_Int16 ORowSetValue::getInt16() const
{
sal_Int16 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = sal_Int16(OUString::unacquired(&m_aValue.m_pString).toInt32()); break; case DataType::FLOAT:
nRet = sal_Int16(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_Int16(m_aValue.m_nDouble); break; case DataType::DATE: case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getInt16() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_Int16(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = static_cast<sal_Int16>(m_aValue.m_uInt16); break; case DataType::INTEGER: if ( m_bSigned )
nRet = static_cast<sal_Int16>(m_aValue.m_nInt32); else
nRet = static_cast<sal_Int16>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_Int16>(m_aValue.m_nInt64); else
nRet = static_cast<sal_Int16>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_uInt16 ORowSetValue::getUInt16() const
{
sal_uInt16 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = sal_uInt16(OUString::unacquired(&m_aValue.m_pString).toInt32()); break; case DataType::FLOAT:
nRet = sal_uInt16(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_uInt16(m_aValue.m_nDouble); break; case DataType::DATE: case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getuInt16() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_uInt16(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = static_cast<sal_uInt16>(m_aValue.m_nInt32); else
nRet = static_cast<sal_uInt16>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_uInt16>(m_aValue.m_nInt64); else
nRet = static_cast<sal_uInt16>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_Int32 ORowSetValue::getInt32() const
{
sal_Int32 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toInt32(); break; case DataType::FLOAT:
nRet = sal_Int32(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_Int32(m_aValue.m_nDouble); break; case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue)); break; case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getInt32() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_Int32(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = m_aValue.m_nInt32; else
nRet = static_cast<sal_Int32>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_Int32>(m_aValue.m_nInt64); else
nRet = static_cast<sal_Int32>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_uInt32 ORowSetValue::getUInt32() const
{
sal_uInt32 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toUInt32(); break; case DataType::FLOAT:
nRet = sal_uInt32(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_uInt32(m_aValue.m_nDouble); break; case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue)); break; case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getuInt32() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_uInt32(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = m_aValue.m_nInt32; else
nRet = m_aValue.m_uInt32; break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<sal_uInt32>(m_aValue.m_nInt64); else
nRet = static_cast<sal_uInt32>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_Int64 ORowSetValue::getLong() const
{
sal_Int64 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toInt64(); break; case DataType::FLOAT:
nRet = sal_Int64(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_Int64(m_aValue.m_nDouble); break; case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue)); break; case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getLong() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_Int64(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = m_aValue.m_nInt32; else
nRet = m_aValue.m_uInt32; break; case DataType::BIGINT: if ( m_bSigned )
nRet = m_aValue.m_nInt64; else
nRet = static_cast<sal_Int64>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
sal_uInt64 ORowSetValue::getULong() const
{
sal_uInt64 nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toUInt64(); break; case DataType::FLOAT:
nRet = sal_uInt64(m_aValue.m_nFloat); break; case DataType::DOUBLE: case DataType::REAL:
nRet = sal_uInt64(m_aValue.m_nDouble); break; case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDays(*static_cast<css::util::Date*>(m_aValue.m_pValue)); break; case DataType::TIME: case DataType::TIMESTAMP: case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getULong() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = sal_uInt64(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = m_aValue.m_nInt32; else
nRet = m_aValue.m_uInt32; break; case DataType::BIGINT: if ( m_bSigned )
nRet = m_aValue.m_nInt64; else
nRet = m_aValue.m_uInt64; break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
float ORowSetValue::getFloat() const
{ float nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toFloat(); break; case DataType::FLOAT:
nRet = m_aValue.m_nFloat; break; case DataType::DOUBLE: case DataType::REAL:
nRet = static_cast<float>(m_aValue.m_nDouble); break; case DataType::DATE:
nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue))); break; case DataType::TIME:
nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue))); break; case DataType::TIMESTAMP:
nRet = static_cast<float>(dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue))); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getDouble() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = float(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = static_cast<float>(m_aValue.m_uInt16); break; case DataType::INTEGER: if ( m_bSigned )
nRet = static_cast<float>(m_aValue.m_nInt32); else
nRet = static_cast<float>(m_aValue.m_uInt32); break; case DataType::BIGINT: if ( m_bSigned )
nRet = static_cast<float>(m_aValue.m_nInt64); else
nRet = static_cast<float>(m_aValue.m_uInt64); break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
double ORowSetValue::getDouble() const
{ double nRet = 0; if(!m_bNull)
{ switch(getTypeKind())
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR:
nRet = OUString::unacquired(&m_aValue.m_pString).toDouble(); break; case DataType::FLOAT:
nRet = m_aValue.m_nFloat; break; case DataType::DOUBLE: case DataType::REAL:
nRet = m_aValue.m_nDouble; break; case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Date*>(m_aValue.m_pValue)); break; case DataType::TIME:
nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::Time*>(m_aValue.m_pValue)); break; case DataType::TIMESTAMP:
nRet = dbtools::DBTypeConversion::toDouble(*static_cast<css::util::DateTime*>(m_aValue.m_pValue)); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::BLOB: case DataType::CLOB:
OSL_FAIL("getDouble() for this type is not allowed!"); break; case DataType::BIT: case DataType::BOOLEAN:
nRet = double(m_aValue.m_bBool); break; case DataType::TINYINT: if ( m_bSigned )
nRet = m_aValue.m_nInt8; else
nRet = m_aValue.m_uInt8; break; case DataType::SMALLINT: if ( m_bSigned )
nRet = m_aValue.m_nInt16; else
nRet = m_aValue.m_uInt16; break; case DataType::INTEGER: if ( m_bSigned )
nRet = m_aValue.m_nInt32; else
nRet = m_aValue.m_uInt32; break; case DataType::BIGINT: if ( m_bSigned )
nRet = m_aValue.m_nInt64; else
nRet = m_aValue.m_uInt64; break; default:
{
Any aValue = makeAny();
aValue >>= nRet; break;
}
}
} return nRet;
}
Sequence<sal_Int8> ORowSetValue::getSequence() const
{
Sequence<sal_Int8> aSeq; if (!m_bNull)
{ switch(m_eTypeKind)
{ case DataType::OBJECT: case DataType::CLOB: case DataType::BLOB:
{
Reference<XInputStream> xStream; const Any aValue = makeAny(); if(aValue.hasValue())
{
Reference<XBlob> xBlob(aValue,UNO_QUERY); if ( xBlob.is() )
xStream = xBlob->getBinaryStream(); else
{
Reference<XClob> xClob(aValue,UNO_QUERY); if ( xClob.is() )
xStream = xClob->getCharacterStream();
} if(xStream.is())
{ const sal_uInt32 nBytesToRead = 65535;
sal_uInt32 nRead;
css::util::Date ORowSetValue::getDate() const
{
css::util::Date aValue; if(!m_bNull)
{ switch(m_eTypeKind)
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR:
aValue = DBTypeConversion::toDate(getString()); break; case DataType::DECIMAL: case DataType::NUMERIC: case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL:
aValue = DBTypeConversion::toDate(getDouble()); break;
case DataType::DATE:
aValue = *static_cast< css::util::Date*>(m_aValue.m_pValue); break; case DataType::TIMESTAMP:
{
css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue);
aValue.Day = pDateTime->Day;
aValue.Month = pDateTime->Month;
aValue.Year = pDateTime->Year;
} break; case DataType::BIT: case DataType::BOOLEAN: case DataType::TINYINT: case DataType::SMALLINT: case DataType::INTEGER: case DataType::BIGINT:
aValue = DBTypeConversion::toDate( double( getLong() ) ); break;
case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: default:
OSL_ENSURE( false, "ORowSetValue::getDate: cannot retrieve the data!" );
[[fallthrough]];
case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: case DataType::TIME:
aValue = DBTypeConversion::toDate( double(0) ); break;
}
} return aValue;
}
css::util::Time ORowSetValue::getTime() const
{
css::util::Time aValue; if(!m_bNull)
{ switch(m_eTypeKind)
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR:
aValue = DBTypeConversion::toTime(getString()); break; case DataType::DECIMAL: case DataType::NUMERIC: case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL:
aValue = DBTypeConversion::toTime(getDouble()); break; case DataType::TIMESTAMP:
{
css::util::DateTime* pDateTime = static_cast< css::util::DateTime*>(m_aValue.m_pValue);
aValue.NanoSeconds = pDateTime->NanoSeconds;
aValue.Seconds = pDateTime->Seconds;
aValue.Minutes = pDateTime->Minutes;
aValue.Hours = pDateTime->Hours;
} break; case DataType::TIME:
aValue = *static_cast< css::util::Time*>(m_aValue.m_pValue); break; default:
{
Any aAnyValue = makeAny();
aAnyValue >>= aValue; break;
}
}
} return aValue;
}
css::util::DateTime ORowSetValue::getDateTime() const
{
css::util::DateTime aValue; if(!m_bNull)
{ switch(m_eTypeKind)
{ case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR:
aValue = DBTypeConversion::toDateTime(getString()); break; case DataType::DECIMAL: case DataType::NUMERIC: case DataType::FLOAT: case DataType::DOUBLE: case DataType::REAL:
aValue = DBTypeConversion::toDateTime(getDouble()); break; case DataType::DATE:
{
css::util::Date* pDate = static_cast< css::util::Date*>(m_aValue.m_pValue);
aValue.Day = pDate->Day;
aValue.Month = pDate->Month;
aValue.Year = pDate->Year;
} break; case DataType::TIME:
{
css::util::Time* pTime = static_cast< css::util::Time*>(m_aValue.m_pValue);
aValue.NanoSeconds = pTime->NanoSeconds;
aValue.Seconds = pTime->Seconds;
aValue.Minutes = pTime->Minutes;
aValue.Hours = pTime->Hours;
} break; case DataType::TIMESTAMP:
aValue = *static_cast< css::util::DateTime*>(m_aValue.m_pValue); break; default:
{
Any aAnyValue = makeAny();
aAnyValue >>= aValue; break;
}
}
} return aValue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.