summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2013-02-04 11:12:57 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2013-02-05 15:46:17 +0100
commit2bd856e643ef526c1283475c19cd355f7ef840f4 (patch)
treed6ff071ff68de3402b35bec4f8fc82d6c3587533
parent5e50b4d6616fa3831b3a7c72969ac81815768f7a (diff)
ORowSetValue: clean up sign/unsigned union member
Also switch BOOLEAN constructor from sal_Bool to bool. old/new signed/unsigned storage situation: ------------------------------------------------------- SQL type | signed | unsigned old | unsigned new ------------------------------------------------------- TINYINT | sal_Int8 | sal_Int16 | sal_uInt8 SMALLINT | sal_Int16 | sal_Int32 | sal_uInt16 INTEGER | sal_Int32 | sal_Int64 | sal_uInt32 BIGINT | sal_Int64 | pValue (String*) | sal_uInt64 ------------------------------------------------------- When sticking an UNSIGNED TINYINT into an Any, silently promote it to UNSIGNED SMALLINT (that is sal_uInt16), else Any would take it as a sal_Bool and normalise to sal_True (1) or sal_False (0). When constructing an ORowSetValue from a sal_Bool, silently keep it as an unsigned 8 bit integer (that is understand it as a sal_uInt8). This will work in most cases, since when asked back for a bool or sal_Bool, we'll give back the right value. Only code looking at the type tag could possibly make a "wrong" decision. The main (hopefully only?) path through which this would happen is through an implementation of XParameters::setBoolean XRowUpdate::updateBoolean that would use its sal_Bool argument to construct an ORowSetValue. So make sure each implementation constructs a proper BOOLEAN so as not to get confused. For authorship/copyright purposes, this patch is a cooperation between Lionel Elie Mamane <lionel@mamane.lu> and David Ostrovsky <david@ostrovsky.org> Change-Id: I3f1f08716127147f077bff4edb6ec558b1b09e09
-rw-r--r--connectivity/CppunitTest_connectivity_commontools.mk65
-rw-r--r--connectivity/Module_connectivity.mk5
-rw-r--r--connectivity/inc/connectivity/FValue.hxx259
-rw-r--r--connectivity/qa/connectivity/commontools/FValue_test.cxx248
-rw-r--r--connectivity/source/commontools/FValue.cxx747
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx2
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx2
-rw-r--r--connectivity/source/drivers/mork/MResultSet.cxx2
-rw-r--r--connectivity/source/drivers/mozab/MResultSet.cxx2
-rw-r--r--dbaccess/source/core/api/RowSet.cxx4
10 files changed, 1000 insertions, 336 deletions
diff --git a/connectivity/CppunitTest_connectivity_commontools.mk b/connectivity/CppunitTest_connectivity_commontools.mk
new file mode 100644
index 000000000000..1678e7b19e05
--- /dev/null
+++ b/connectivity/CppunitTest_connectivity_commontools.mk
@@ -0,0 +1,65 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,connectivity_commontools))
+
+$(eval $(call gb_CppunitTest_set_include,connectivity_commontools,\
+ -I$(SRCDIR)/connectivity/source/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,connectivity_commontools))
+
+$(eval $(call gb_CppunitTest_use_external,connectivity_commontools,boost_headers))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,connectivity_commontools))
+
+ifeq ($(COM),GCC)
+$(eval $(call gb_CppunitTest_add_cxxflags,connectivity_commontools,\
+ -fpermissive \
+))
+endif
+
+ifeq ($(WINDOWS_SDK_VERSION),80)
+$(eval $(call gb_CppunitTest_add_defs,connectivity_commontools,\
+ -DNTDDI_VERSION=0x0601 \
+))
+endif
+
+$(eval $(call gb_CppunitTest_add_exception_objects,connectivity_commontools, \
+ connectivity/qa/connectivity/commontools/FValue_test \
+))
+
+$(eval $(call gb_CppunitTest_use_library_objects,connectivity_commontools,dbtools))
+
+$(eval $(call gb_CppunitTest_use_libraries,connectivity_commontools, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ i18nisolang1 \
+ jvmaccess \
+ sal \
+ salhelper \
+ test \
+ unotest \
+ utl \
+ tl \
+ $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_components,connectivity_commontools,\
+ configmgr/source/configmgr \
+ i18npool/util/i18npool \
+ ucb/source/core/ucb1 \
+ ucb/source/ucp/file/ucpfile1 \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,connectivity_commontools))
+
+# vim: set noet sw=4 ts=4:
diff --git a/connectivity/Module_connectivity.mk b/connectivity/Module_connectivity.mk
index 0b5b22c54a1d..bef94383d3e8 100644
--- a/connectivity/Module_connectivity.mk
+++ b/connectivity/Module_connectivity.mk
@@ -160,6 +160,11 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,connectivity,\
endif
+# general tests
+$(eval $(call gb_Module_add_check_targets,connectivity,\
+ CppunitTest_connectivity_commontools \
+))
+
endif
# vim: set noet sw=4 ts=4:
diff --git a/connectivity/inc/connectivity/FValue.hxx b/connectivity/inc/connectivity/FValue.hxx
index 117d06ae80cb..3f72b41e7323 100644
--- a/connectivity/inc/connectivity/FValue.hxx
+++ b/connectivity/inc/connectivity/FValue.hxx
@@ -46,40 +46,50 @@ namespace connectivity
{
union
{
- sal_Bool m_bBool;
+ bool m_bBool;
+
sal_Int8 m_nInt8;
+ sal_uInt8 m_uInt8;
+
sal_Int16 m_nInt16;
+ sal_uInt16 m_uInt16;
+
sal_Int32 m_nInt32;
+ sal_uInt32 m_uInt32;
+
+ sal_Int64 m_nInt64;
+ sal_uInt64 m_uInt64;
+
rtl_uString* m_pString;
void* m_pValue; // can contains double, etc
} m_aValue;
sal_Int32 m_eTypeKind; // the database type
- sal_Bool m_bNull : 1; // value is null
- sal_Bool m_bBound : 1; // is bound
- sal_Bool m_bModified : 1; // value was changed
- sal_Bool m_bSigned : 1; // value is signed
+ bool m_bNull : 1; // value is null
+ bool m_bBound : 1; // is bound
+ bool m_bModified : 1; // value was changed
+ bool m_bSigned : 1; // value is signed
void free();
public:
ORowSetValue()
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
}
ORowSetValue(const ORowSetValue& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -87,10 +97,10 @@ namespace connectivity
ORowSetValue(const ::rtl::OUString& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::VARCHAR)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -98,10 +108,10 @@ namespace connectivity
ORowSetValue(const double& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::DOUBLE)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -109,10 +119,10 @@ namespace connectivity
ORowSetValue(const float& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::FLOAT)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -120,51 +130,92 @@ namespace connectivity
ORowSetValue(const sal_Int8& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TINYINT)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+
+ ORowSetValue(const sal_uInt8& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::TINYINT)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int16& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::SMALLINT)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_uInt16& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::SMALLINT)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int32& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::INTEGER)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_uInt32& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::INTEGER)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
ORowSetValue(const sal_Int64& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::BIGINT)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
+ {
+ m_aValue.m_pString = NULL;
+ operator=(_rRH);
+ }
+ ORowSetValue(const sal_uInt64& _rRH)
+ :m_eTypeKind(::com::sun::star::sdbc::DataType::BIGINT)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(false)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
}
- ORowSetValue(const sal_Bool& _rRH)
+ ORowSetValue(const bool& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::BIT)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -172,10 +223,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::Date& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::DATE)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -183,10 +234,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::Time& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TIME)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -194,10 +245,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::util::DateTime& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::TIMESTAMP)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -205,10 +256,10 @@ namespace connectivity
ORowSetValue(const ::com::sun::star::uno::Sequence<sal_Int8>& _rRH)
:m_eTypeKind(::com::sun::star::sdbc::DataType::LONGVARBINARY)
- ,m_bNull(sal_True)
- ,m_bBound(sal_True)
- ,m_bModified(sal_False)
- ,m_bSigned(sal_True)
+ ,m_bNull(true)
+ ,m_bBound(true)
+ ,m_bModified(false)
+ ,m_bSigned(true)
{
m_aValue.m_pString = NULL;
operator=(_rRH);
@@ -231,11 +282,20 @@ namespace connectivity
ORowSetValue& operator=(const ORowSetValue& _rRH);
// simple types
- ORowSetValue& operator=(const sal_Bool _rRH);
+ ORowSetValue& operator=(const bool _rRH);
+
ORowSetValue& operator=(const sal_Int8& _rRH);
+ ORowSetValue& operator=(const sal_uInt8& _rRH);
+
ORowSetValue& operator=(const sal_Int16& _rRH);
+ ORowSetValue& operator=(const sal_uInt16& _rRH);
+
ORowSetValue& operator=(const sal_Int32& _rRH);
+ ORowSetValue& operator=(const sal_uInt32& _rRH);
+
ORowSetValue& operator=(const sal_Int64& _rRH);
+ ORowSetValue& operator=(const sal_uInt64& _rRH);
+
ORowSetValue& operator=(const double& _rRH);
ORowSetValue& operator=(const float& _rRH);
@@ -250,11 +310,19 @@ namespace connectivity
// we the possiblity to save a any for bookmarks
ORowSetValue& operator=(const ::com::sun::star::uno::Any& _rAny);
- operator sal_Bool() const { return isNull() ? sal_False : getBool(); }
- operator sal_Int8() const { return isNull() ? static_cast<sal_Int8>(0) : getInt8(); }
+ operator bool() const { return isNull() ? false : getBool(); }
+ operator sal_Int8() const { return isNull() ? static_cast<sal_Int8>(0) : getInt8(); }
+ operator sal_uInt8() const { return isNull() ? static_cast<sal_uInt8>(0) : getUInt8(); }
+
operator sal_Int16() const { return isNull() ? static_cast<sal_Int16>(0) : getInt16(); }
+ operator sal_uInt16() const { return isNull() ? static_cast<sal_uInt16>(0) : getUInt16(); }
+
operator sal_Int32() const { return isNull() ? 0 : getInt32(); }
+ operator sal_uInt32() const { return isNull() ? 0 : getUInt32(); }
+
operator sal_Int64() const { return isNull() ? 0 : getLong(); }
+ operator sal_uInt64() const { return isNull() ? 0 : getULong(); }
+
operator float() const { return isNull() ? (float)0.0: getFloat(); }
operator double() const { return isNull() ? 0.0 : getDouble(); }
@@ -289,38 +357,47 @@ namespace connectivity
return !( *this == _rRH );
}
- sal_Bool isNull() const
+ bool isNull() const
{
return m_bNull;
}
void setNull()
{
free();
- m_bNull = sal_True;
+ m_bNull = true;
m_aValue.m_pString = NULL;
}
- sal_Bool isBound() const { return m_bBound; }
- void setBound(sal_Bool _bBound) { m_bBound = _bBound ? 1 : 0; }
+ bool isBound() const { return m_bBound; }
+ void setBound(bool _bBound) { m_bBound = _bBound ? 1 : 0; }
- sal_Bool isModified() const { return m_bModified; }
- void setModified(sal_Bool _bMod=sal_True){ m_bModified = _bMod ? 1 : 0; }
+ bool isModified() const { return m_bModified; }
+ void setModified(bool _bMod=true) { m_bModified = _bMod ? 1 : 0; }
- sal_Bool isSigned() const { return m_bSigned; }
- void setSigned(sal_Bool _bMod=sal_True);
+ bool isSigned() const { return m_bSigned; }
+ void setSigned(bool _bSig=true);
sal_Int32 getTypeKind() const { return m_eTypeKind; }
void setTypeKind(sal_Int32 _eType);
// before calling one of this methods, be sure that the value is not null
void* getValue() const { OSL_ENSURE(m_bBound,"Value is not bound!");return m_aValue.m_pValue; }
- sal_Bool getBool() const;
+ bool getBool() const;
+
sal_Int8 getInt8() const;
+ sal_uInt8 getUInt8() const;
+
sal_Int16 getInt16() const;
+ sal_uInt16 getUInt16() const;
+
sal_Int32 getInt32() const;
+ sal_uInt32 getUInt32() const;
+
sal_Int64 getLong() const;
+ sal_uInt64 getULong() const;
+
double getDouble() const;
- float getFloat() const;
+ float getFloat() const;
::rtl::OUString getString() const; // makes a automatic conversion if type isn't a string
::com::sun::star::util::Date getDate() const;
@@ -350,7 +427,7 @@ namespace connectivity
*/
void fill(sal_Int32 _nPos,
sal_Int32 _nType,
- sal_Bool _bNullable,
+ bool _bNullable,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRow>& _xRow);
void fill(const ::com::sun::star::uno::Any& _rValue);
@@ -359,7 +436,7 @@ namespace connectivity
const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XColumn >& _rxColumn );
private:
- void impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource );
+ void impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource );
};
/// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted"
@@ -367,8 +444,8 @@ namespace connectivity
{
ORowSetValue m_aValue; // my own value
public:
- ORowSetValueDecorator(){m_aValue.setBound(sal_True);}
- ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(sal_True);}
+ ORowSetValueDecorator(){m_aValue.setBound(true);}
+ ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(true);}
ORowSetValueDecorator& operator=(const ORowSetValue& _aValue);
inline operator const ORowSetValue&() const { return m_aValue; }
@@ -377,10 +454,10 @@ namespace connectivity
inline ORowSetValue& get() { return m_aValue; }
inline void setValue(const ORowSetValue& _aValue) { m_aValue = _aValue; }
inline void setNull() { m_aValue.setNull(); }
- inline void setBound(sal_Bool _bBound ) { m_aValue.setBound(_bBound);}
- inline sal_Bool isBound( ) const { return m_aValue.isBound();}
+ inline void setBound(bool _bBound ) { m_aValue.setBound(_bBound);}
+ inline bool isBound( ) const { return m_aValue.isBound();}
inline void setTypeKind(sal_Int32 _nType) { m_aValue.setTypeKind(_nType); }
- inline void setModified(sal_Bool _bModified) { m_aValue.setModified(_bModified); }
+ inline void setModified(bool _bModified) { m_aValue.setModified(_bModified); }
};
typedef ::rtl::Reference<ORowSetValueDecorator> ORowSetValueDecoratorRef;
@@ -389,8 +466,8 @@ namespace connectivity
/// TSetBound is a unary_function to set the bound value with e.q. for_each call
struct OOO_DLLPUBLIC_DBTOOLS TSetBound : ::std::unary_function<ORowSetValue,void>
{
- sal_Bool m_bBound;
- TSetBound(sal_Bool _bBound) : m_bBound(_bBound){}
+ bool m_bBound;
+ TSetBound(bool _bBound) : m_bBound(_bBound){}
void operator()(ORowSetValue& _rValue) const { _rValue.setBound(m_bBound); }
};
@@ -399,8 +476,8 @@ namespace connectivity
/// TSetBound is a unary_function to set the bound value with e.q. for_each call
struct OOO_DLLPUBLIC_DBTOOLS TSetRefBound : ::std::unary_function<ORowSetValueDecoratorRef,void>
{
- sal_Bool m_bBound;
- TSetRefBound(sal_Bool _bBound) : m_bBound(_bBound){}
+ bool m_bBound;
+ TSetRefBound(bool _bBound) : m_bBound(_bBound){}
void operator()(ORowSetValueDecoratorRef& _rValue) const { _rValue->setBound(m_bBound); }
};
@@ -410,13 +487,13 @@ namespace connectivity
// ----------------------------------------------------------------------------
template< class VectorVal > class ODeleteVector : public connectivity::ORowVector< VectorVal >
{
- sal_Bool m_bDeleted;
+ bool m_bDeleted;
public:
- ODeleteVector() : connectivity::ORowVector< VectorVal >() ,m_bDeleted(sal_False) {}
- ODeleteVector(size_t _st) : connectivity::ORowVector< VectorVal >(_st) ,m_bDeleted(sal_False) {}
+ ODeleteVector() : connectivity::ORowVector< VectorVal >() ,m_bDeleted(false) {}
+ ODeleteVector(size_t _st) : connectivity::ORowVector< VectorVal >(_st) ,m_bDeleted(false) {}
- sal_Bool isDeleted() const { return m_bDeleted; }
- void setDeleted(sal_Bool _bDeleted) { m_bDeleted = _bDeleted; }
+ bool isDeleted() const { return m_bDeleted; }
+ void setDeleted(bool _bDeleted) { m_bDeleted = _bDeleted; }
};
typedef ODeleteVector< ORowSetValue > OValueVector;
diff --git a/connectivity/qa/connectivity/commontools/FValue_test.cxx b/connectivity/qa/connectivity/commontools/FValue_test.cxx
new file mode 100644
index 000000000000..be3024e32c9d
--- /dev/null
+++ b/connectivity/qa/connectivity/commontools/FValue_test.cxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <test/bootstrapfixture.hxx>
+
+#include "connectivity/FValue.hxx"
+using namespace ::com::sun::star::uno;
+
+namespace connectivity { namespace commontools {
+
+class FValueTest: public test::BootstrapFixture
+{
+public:
+ FValueTest() : test::BootstrapFixture(false, false) {};
+
+ void test_Bool();
+
+ void test_Int8();
+ void test_uInt8();
+
+ void test_Int16();
+ void test_uInt16();
+
+ void test_Int32();
+ void test_uInt32();
+
+ void test_Int64();
+ void test_uInt64();
+
+ CPPUNIT_TEST_SUITE(FValueTest);
+
+ CPPUNIT_TEST(test_Bool);
+
+ CPPUNIT_TEST(test_Int8);
+ CPPUNIT_TEST(test_uInt8);
+
+ CPPUNIT_TEST(test_Int16);
+ CPPUNIT_TEST(test_uInt16);
+
+ CPPUNIT_TEST(test_Int32);
+ CPPUNIT_TEST(test_uInt32);
+
+ CPPUNIT_TEST(test_Int64);
+ CPPUNIT_TEST(test_uInt64);
+
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void FValueTest::test_Bool()
+{
+ bool src_Bool = true;
+ ORowSetValue v(src_Bool);
+ bool trg_Bool = v.getBool();
+
+ std::cerr << "src_Bool: " << src_Bool << std::endl;
+ std::cerr << "trg_Bool: " << trg_Bool << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool conversion to ORowSetValue didn't work", src_Bool == trg_Bool);
+
+ Any any_Bool = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_Bool);
+ trg_Bool = t.getBool();
+
+ std::cerr << "trg_Bool: " << trg_Bool << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("bool conversion from Any didn't work", src_Bool == trg_Bool);
+}
+
+void FValueTest::test_Int8()
+{
+ sal_Int8 src_salInt8 = 127;
+ ORowSetValue v(src_salInt8);
+ sal_Int8 trg_salInt8 = v.getInt8();
+
+ std::cerr << "src_salInt8: " << static_cast<short>(src_salInt8) << std::endl;
+ std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion to ORowSetValue didn't work", src_salInt8 == trg_salInt8);
+
+ Any any_Int8 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_Int8);
+ trg_salInt8 = t.getInt8();
+
+ std::cerr << "trg_salInt8: " << static_cast<short>(trg_salInt8) << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int8 conversion from Any didn't work", src_salInt8 == trg_salInt8);
+}
+
+void FValueTest::test_uInt8()
+{
+ sal_uInt8 src_saluInt8 = 255;
+ ORowSetValue v(src_saluInt8);
+ sal_uInt8 trg_saluInt8 = v.getUInt8();
+
+ std::cerr << "src_saluInt8: " << static_cast<short>(src_saluInt8) << std::endl;
+ std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion to ORowSetValue didn't work", src_saluInt8 == trg_saluInt8);
+
+ Any any_uInt8 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_uInt8);
+ trg_saluInt8 = t.getUInt8();
+
+ std::cerr << "trg_saluInt8: " << static_cast<short>(trg_saluInt8) << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt8 conversion from Any didn't work", src_saluInt8 == trg_saluInt8);
+}
+
+void FValueTest::test_Int16()
+{
+ sal_Int16 src_salInt16 = -10001;
+ ORowSetValue v(src_salInt16);
+ sal_Int16 trg_salInt16 = v.getInt16();
+
+ std::cerr << "src_salInt16: " << src_salInt16 << std::endl;
+ std::cerr << "trg_salInt16: " << trg_salInt16 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion to ORowSetValue didn't work", src_salInt16 == trg_salInt16);
+
+ Any any_Int16 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_Int16);
+ trg_salInt16 = t.getInt16();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int16 conversion from Any didn't work", src_salInt16 == trg_salInt16);
+}
+
+void FValueTest::test_uInt16()
+{
+ sal_uInt16 src_saluInt16 = 10001;
+ ORowSetValue v(src_saluInt16);
+ sal_uInt16 trg_saluInt16 = v.getUInt16();
+
+ std::cerr << "src_saluInt16: " << src_saluInt16 << std::endl;
+ std::cerr << "trg_saluInt16: " << trg_saluInt16 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion to ORowSetValue didn't work", src_saluInt16 == trg_saluInt16);
+
+ Any any_uInt16 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_uInt16);
+ trg_saluInt16 = t.getUInt16();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt16 conversion from Any didn't work", src_saluInt16 == trg_saluInt16);
+}
+
+void FValueTest::test_Int32()
+{
+ sal_Int32 src_salInt32 = -10000001;
+ ORowSetValue v(src_salInt32);
+ sal_Int32 trg_salInt32 = v.getInt32();
+
+ std::cerr << "src_salInt32: " << src_salInt32 << std::endl;
+ std::cerr << "trg_salInt32: " << trg_salInt32 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion to ORowSetValue didn't work", src_salInt32 == trg_salInt32);
+
+ Any any_Int32 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_Int32);
+ trg_salInt32 = t.getInt32();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int32 conversion from Any didn't work", src_salInt32 == trg_salInt32);
+}
+
+void FValueTest::test_uInt32()
+{
+ sal_uInt32 src_saluInt32 = 100000001;
+ ORowSetValue v(src_saluInt32);
+ sal_uInt32 trg_saluInt32 = v.getUInt32();
+
+ std::cerr << "src_saluInt32: " << src_saluInt32 << std::endl;
+ std::cerr << "trg_saluInt32: " << trg_saluInt32 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion to ORowSetValue didn't work", src_saluInt32 == trg_saluInt32);
+
+ Any any_uInt32 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_uInt32);
+ trg_saluInt32 = t.getUInt32();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt32 conversion from Any didn't work", src_saluInt32 == trg_saluInt32);
+}
+
+void FValueTest::test_Int64()
+{
+ sal_Int64 src_salInt64 = -1000000000000000001LL;
+ ORowSetValue v(src_salInt64);
+ sal_Int64 trg_salInt64 = v.getLong();
+
+ std::cerr << "src_salInt64: " << src_salInt64 << std::endl;
+ std::cerr << "trg_salInt64: " << trg_salInt64 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion to ORowSetValue didn't work", src_salInt64 == trg_salInt64);
+
+ Any any_Int64 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_Int64);
+ trg_salInt64 = t.getLong();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_Int64 conversion from Any didn't work", src_salInt64 == trg_salInt64);
+}
+
+void FValueTest::test_uInt64()
+{
+ sal_uInt64 src_saluInt64 = 10000000000000000001ULL;
+ ORowSetValue v(src_saluInt64);
+ sal_uInt64 trg_saluInt64 = v.getULong();
+
+ std::cerr << "src_saluInt64: " << src_saluInt64 << std::endl;
+ std::cerr << "trg_saluInt64: " << trg_saluInt64 << std::endl;
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion to ORowSetValue didn't work", src_saluInt64 == trg_saluInt64);
+
+ Any any_uInt64 = v.makeAny();
+ ORowSetValue t;
+ t.fill(any_uInt64);
+ trg_saluInt64 = t.getULong();
+
+ CPPUNIT_ASSERT_MESSAGE("sal_uInt64 conversion from Any didn't work", src_saluInt64 == trg_saluInt64);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(FValueTest);
+
+}}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx
index 5100cc05b418..e4580ddc52cd 100644
--- a/connectivity/source/commontools/FValue.cxx
+++ b/connectivity/source/commontools/FValue.cxx
@@ -39,10 +39,10 @@ namespace connectivity
{
namespace {
- static sal_Bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
+ static bool isStorageCompatible(sal_Int32 _eType1, sal_Int32 _eType2)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::isStorageCompatible" );
- sal_Bool bIsCompatible = sal_True;
+ bool bIsCompatible = sal_True;
if (_eType1 != _eType2)
{
@@ -274,28 +274,6 @@ void ORowSetValue::free()
rtl_uString_release(m_aValue.m_pString);
m_aValue.m_pString = NULL;
break;
- case DataType::INTEGER:
- if ( !m_bSigned )
- {
- delete (sal_Int64*)m_aValue.m_pValue;
- TRACE_FREE( sal_Int64 )
- m_aValue.m_pValue = NULL;
- }
- break;
- case DataType::BIGINT:
- if ( m_bSigned )
- {
- delete (sal_Int64*)m_aValue.m_pValue;
- TRACE_FREE( sal_Int64 )
- m_aValue.m_pValue = NULL;
- }
- else
- {
- OSL_ENSURE(m_aValue.m_pString,"String pointer is null!");
- rtl_uString_release(m_aValue.m_pString);
- m_aValue.m_pString = NULL;
- }
- break;
case DataType::FLOAT:
delete (float*)m_aValue.m_pValue;
TRACE_FREE( float )
@@ -339,6 +317,8 @@ void ORowSetValue::free()
case DataType::BIT:
case DataType::TINYINT:
case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::BIGINT:
case DataType::BOOLEAN:
break;
default:
@@ -379,18 +359,6 @@ ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
rtl_uString_acquire(_rRH.m_aValue.m_pString);
m_aValue.m_pString = _rRH.m_aValue.m_pString;
break;
- case DataType::BIGINT:
- if ( _rRH.m_bSigned )
- {
- m_aValue.m_pValue = new sal_Int64(*(sal_Int64*)_rRH.m_aValue.m_pValue);
- TRACE_ALLOC( sal_Int64 )
- }
- else
- {
- rtl_uString_acquire(_rRH.m_aValue.m_pString);
- m_aValue.m_pString = _rRH.m_aValue.m_pString;
- }
- break;
case DataType::FLOAT:
m_aValue.m_pValue = new float(*(float*)_rRH.m_aValue.m_pValue);
TRACE_ALLOC( float )
@@ -426,22 +394,25 @@ ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
if ( _rRH.m_bSigned )
m_aValue.m_nInt8 = _rRH.m_aValue.m_nInt8;
else
- m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ m_aValue.m_uInt8 = _rRH.m_aValue.m_uInt8;
break;
case DataType::SMALLINT:
if ( _rRH.m_bSigned )
m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
else
- m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ m_aValue.m_uInt16 = _rRH.m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( _rRH.m_bSigned )
m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
else
- {
- m_aValue.m_pValue = new sal_Int64(*(sal_Int64*)_rRH.m_aValue.m_pValue);
- TRACE_ALLOC( sal_Int64 )
- }
+ m_aValue.m_uInt32 = _rRH.m_aValue.m_uInt32;
+ break;
+ case DataType::BIGINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt64 = _rRH.m_aValue.m_nInt64;
+ else
+ m_aValue.m_uInt64 = _rRH.m_aValue.m_uInt64;
break;
default:
m_aValue.m_pValue = new Any(*(Any*)_rRH.m_aValue.m_pValue);
@@ -459,12 +430,6 @@ ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
case DataType::LONGVARCHAR:
(*this) = ::rtl::OUString(_rRH.m_aValue.m_pString);
break;
- case DataType::BIGINT:
- if ( _rRH.m_bSigned )
- (*this) = *(sal_Int64*)_rRH.m_aValue.m_pValue;
- else
- (*this) = ::rtl::OUString(_rRH.m_aValue.m_pString);
- break;
case DataType::FLOAT:
(*this) = *(float*)_rRH.m_aValue.m_pValue;
break;
@@ -494,19 +459,25 @@ ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH)
if ( _rRH.m_bSigned )
m_aValue.m_nInt8 = _rRH.m_aValue.m_nInt8;
else
- m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
+ m_aValue.m_nInt8 = _rRH.m_aValue.m_uInt8;
break;
case DataType::SMALLINT:
if ( _rRH.m_bSigned )
m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16;
else
- m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
+ m_aValue.m_uInt16 = _rRH.m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( _rRH.m_bSigned )
m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32;
else
- *static_cast<sal_Int64*>(m_aValue.m_pValue) = *(sal_Int64*)_rRH.m_aValue.m_pValue;
+ m_aValue.m_uInt32 = _rRH.m_aValue.m_uInt32;
+ break;
+ case DataType::BIGINT:
+ if ( _rRH.m_bSigned )
+ m_aValue.m_nInt64 = _rRH.m_aValue.m_nInt64;
+ else
+ m_aValue.m_uInt64 = _rRH.m_aValue.m_uInt64;
break;
default:
(*(Any*)m_aValue.m_pValue) = (*(Any*)_rRH.m_aValue.m_pValue);
@@ -636,6 +607,20 @@ ORowSetValue& ORowSetValue::operator=(const sal_Int8& _rRH)
m_aValue.m_nInt8 = _rRH;
m_eTypeKind = DataType::TINYINT;
m_bNull = sal_False;
+ m_bSigned = sal_True;
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_uInt8& _rRH)
+{
+ if(m_eTypeKind != DataType::TINYINT )
+ free();
+
+ m_aValue.m_uInt8 = _rRH;
+ m_eTypeKind = DataType::TINYINT;
+ m_bNull = sal_False;
+ m_bSigned = sal_False;
return *this;
}
// -------------------------------------------------------------------------
@@ -648,6 +633,21 @@ ORowSetValue& ORowSetValue::operator=(const sal_Int16& _rRH)
m_aValue.m_nInt16 = _rRH;
m_eTypeKind = DataType::SMALLINT;
m_bNull = sal_False;
+ m_bSigned = sal_True;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_uInt16& _rRH)
+{
+ if(m_eTypeKind != DataType::SMALLINT )
+ free();
+
+ m_aValue.m_uInt16 = _rRH;
+ m_eTypeKind = DataType::SMALLINT;
+ m_bNull = sal_False;
+ m_bSigned = sal_False;
return *this;
}
@@ -658,27 +658,32 @@ ORowSetValue& ORowSetValue::operator=(const sal_Int32& _rRH)
if(m_eTypeKind != DataType::INTEGER )
free();
- if ( m_bSigned )
- m_aValue.m_nInt32 = _rRH;
- else
- {
- if ( m_bNull )
- {
- m_aValue.m_pValue = new sal_Int64(_rRH);
- TRACE_ALLOC( sal_Int64 )
- }
- else
- *static_cast<sal_Int64*>(m_aValue.m_pValue) = static_cast<sal_Int64>(_rRH);
- }
+ m_aValue.m_nInt32 = _rRH;
+
+ m_eTypeKind = DataType::INTEGER;
+ m_bNull = sal_False;
+ m_bSigned = sal_True;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+
+ORowSetValue& ORowSetValue::operator=(const sal_uInt32& _rRH)
+{
+ if(m_eTypeKind != DataType::INTEGER )
+ free();
+
+ m_aValue.m_uInt32 = _rRH;
m_eTypeKind = DataType::INTEGER;
m_bNull = sal_False;
+ m_bSigned = sal_False;
return *this;
}
// -------------------------------------------------------------------------
-ORowSetValue& ORowSetValue::operator=(const sal_Bool _rRH)
+ORowSetValue& ORowSetValue::operator=(const bool _rRH)
{
if(m_eTypeKind != DataType::BIT && DataType::BOOLEAN != m_eTypeKind )
free();
@@ -692,28 +697,26 @@ ORowSetValue& ORowSetValue::operator=(const sal_Bool _rRH)
// -------------------------------------------------------------------------
ORowSetValue& ORowSetValue::operator=(const sal_Int64& _rRH)
{
- if ( DataType::BIGINT != m_eTypeKind || !m_bSigned )
+ if ( DataType::BIGINT != m_eTypeKind)
free();
- if ( m_bSigned )
- {
- if(m_bNull)
- {
- m_aValue.m_pValue = new sal_Int64(_rRH);
- TRACE_ALLOC( sal_Int64 )
- }
- else
- *static_cast<sal_Int64*>(m_aValue.m_pValue) = _rRH;
- }
- else
- {
- ::rtl::OUString aVal = ::rtl::OUString::valueOf(_rRH);
- m_aValue.m_pString = aVal.pData;
- rtl_uString_acquire(m_aValue.m_pString);
- }
+ m_aValue.m_nInt64 = _rRH;
+ m_eTypeKind = DataType::BIGINT;
+ m_bNull = sal_False;
+ m_bSigned = sal_True;
+
+ return *this;
+}
+// -------------------------------------------------------------------------
+ORowSetValue& ORowSetValue::operator=(const sal_uInt64& _rRH)
+{
+ if ( DataType::BIGINT != m_eTypeKind)
+ free();
+ m_aValue.m_uInt64 = _rRH;
m_eTypeKind = DataType::BIGINT;
m_bNull = sal_False;
+ m_bSigned = sal_False;
return *this;
}
@@ -757,19 +760,19 @@ ORowSetValue& ORowSetValue::operator=(const Any& _rAny)
}
// -------------------------------------------------------------------------
-sal_Bool operator==(const Date& _rLH,const Date& _rRH)
+bool operator==(const Date& _rLH,const Date& _rRH)
{
return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year;
}
// -------------------------------------------------------------------------
-sal_Bool operator==(const Time& _rLH,const Time& _rRH)
+bool operator==(const Time& _rLH,const Time& _rRH)
{
return _rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
}
// -------------------------------------------------------------------------
-sal_Bool operator==(const DateTime& _rLH,const DateTime& _rRH)
+bool operator==(const DateTime& _rLH,const DateTime& _rRH)
{
return _rLH.Day == _rRH.Day && _rLH.Month == _rRH.Month && _rLH.Year == _rRH.Year &&
_rLH.Minutes == _rRH.Minutes && _rLH.Hours == _rRH.Hours && _rLH.Seconds == _rRH.Seconds && _rLH.HundredthSeconds == _rRH.HundredthSeconds;
@@ -843,23 +846,16 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const
bRet = *(double*)m_aValue.m_pValue == *(double*)_rRH.m_aValue.m_pValue;
break;
case DataType::TINYINT:
- bRet = m_bSigned ? ( m_aValue.m_nInt8 == _rRH.m_aValue.m_nInt8 ) : (m_aValue.m_nInt16 == _rRH.m_aValue.m_nInt16);
+ 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_nInt32 == _rRH.m_aValue.m_nInt32);
+ 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 ) : (*(sal_Int64*)m_aValue.m_pValue == *(sal_Int64*)_rRH.m_aValue.m_pValue);
+ 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:
- if ( m_bSigned )
- bRet = *(sal_Int64*)m_aValue.m_pValue == *(sal_Int64*)_rRH.m_aValue.m_pValue;
- else
- {
- ::rtl::OUString aVal1(m_aValue.m_pString);
- ::rtl::OUString aVal2(_rRH.m_aValue.m_pString);
- bRet = aVal1 == aVal2;
- }
+ 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:
@@ -909,18 +905,6 @@ Any ORowSetValue::makeAny() const
OSL_ENSURE(m_aValue.m_pString,"Value is null!");
rValue <<= (::rtl::OUString)m_aValue.m_pString;
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- {
- OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
- rValue <<= *(sal_Int64*)m_aValue.m_pValue;
- }
- else
- {
- OSL_ENSURE(m_aValue.m_pString,"Value is null!");
- rValue <<= (::rtl::OUString)m_aValue.m_pString;
- }
- break;
case DataType::FLOAT:
OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
rValue <<= *(float*)m_aValue.m_pValue;
@@ -960,24 +944,37 @@ Any ORowSetValue::makeAny() const
break;
case DataType::TINYINT:
if ( m_bSigned )
+ // TypeClass_BYTE
rValue <<= m_aValue.m_nInt8;
else
- rValue <<= m_aValue.m_nInt16;
+ // 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
- rValue <<= m_aValue.m_nInt32;
+ // TypeClass_UNSIGNED_SHORT
+ rValue <<= m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( m_bSigned )
+ // TypeClass_LONG
rValue <<= m_aValue.m_nInt32;
else
- {
- OSL_ENSURE(m_aValue.m_pValue,"Value is null!");
- rValue <<= *(sal_Int64*)m_aValue.m_pValue;
- }
+ // 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:
OSL_FAIL("ORowSetValue::makeAny(): UNSPUPPORTED TYPE!");
@@ -1003,18 +1000,12 @@ Any ORowSetValue::makeAny() const
case DataType::LONGVARCHAR:
aRet = m_aValue.m_pString;
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
- else
- aRet = m_aValue.m_pString;
- break;
case DataType::FLOAT:
- aRet = ::rtl::OUString::valueOf((float)*this);
+ aRet = OUString::number(static_cast<float>(*this));
break;
case DataType::DOUBLE:
case DataType::REAL:
- aRet = ::rtl::OUString::valueOf((double)*this);
+ aRet = OUString::number(static_cast<double>(*this));
break;
case DataType::DATE:
aRet = connectivity::toDateString(*this);
@@ -1040,25 +1031,21 @@ Any ORowSetValue::makeAny() const
break;
case DataType::BIT:
case DataType::BOOLEAN:
- aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Bool)*this);
+ aRet = OUString::boolean(static_cast<bool>(*this));
break;
case DataType::TINYINT:
- if ( m_bSigned )
- aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int8)*this);
- else
- aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int16)*this);
- break;
case DataType::SMALLINT:
+ case DataType::INTEGER:
if ( m_bSigned )
- aRet = ::rtl::OUString::valueOf((sal_Int32)(sal_Int16)*this);
+ aRet = OUString::number(static_cast<sal_Int32>(*this));
else
- aRet = ::rtl::OUString::valueOf((sal_Int32)*this);
+ aRet = OUString::number(static_cast<sal_uInt32>(*this));
break;
- case DataType::INTEGER:
+ case DataType::BIGINT:
if ( m_bSigned )
- aRet = ::rtl::OUString::valueOf((sal_Int32)*this);
+ aRet = OUString::number(static_cast<sal_Int64>(*this));
else
- aRet = ::rtl::OUString::valueOf((sal_Int64)*this);
+ aRet = OUString::number(static_cast<sal_uInt64>(*this));
break;
case DataType::CLOB:
{
@@ -1084,10 +1071,10 @@ Any ORowSetValue::makeAny() const
return aRet;
}
// -------------------------------------------------------------------------
-sal_Bool ORowSetValue::getBool() const
+bool ORowSetValue::getBool() const
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getBool" );
- sal_Bool bRet = sal_False;
+ bool bRet = sal_False;
if(!m_bNull)
{
switch(getTypeKind())
@@ -1116,12 +1103,6 @@ sal_Bool ORowSetValue::getBool() const
bRet = ::rtl::OUString(m_aValue.m_pString).toInt32() != 0;
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- bRet = *(sal_Int64*)m_aValue.m_pValue != 0;
- else
- bRet = ::rtl::OUString(m_aValue.m_pString).toInt64() != 0;
- break;
case DataType::FLOAT:
bRet = *(float*)m_aValue.m_pValue != 0.0;
break;
@@ -1142,13 +1123,16 @@ sal_Bool ORowSetValue::getBool() const
bRet = m_aValue.m_bBool;
break;
case DataType::TINYINT:
- bRet = m_bSigned ? (m_aValue.m_nInt8 != 0) : (m_aValue.m_nInt16 != 0);
+ 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_nInt32 != 0);
+ 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) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0));
+ 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:
{
@@ -1161,6 +1145,7 @@ sal_Bool ORowSetValue::getBool() const
return bRet;
}
// -------------------------------------------------------------------------
+
sal_Int8 ORowSetValue::getInt8() const
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt8" );
@@ -1178,12 +1163,6 @@ sal_Int8 ORowSetValue::getInt8() const
case DataType::LONGVARCHAR:
nRet = sal_Int8(::rtl::OUString(m_aValue.m_pString).toInt32());
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- nRet = sal_Int8(*(sal_Int64*)m_aValue.m_pValue);
- else
- nRet = sal_Int8(::rtl::OUString(m_aValue.m_pString).toInt32());
- break;
case DataType::FLOAT:
nRet = sal_Int8(*(float*)m_aValue.m_pValue);
break;
@@ -1209,19 +1188,96 @@ sal_Int8 ORowSetValue::getInt8() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = static_cast<sal_Int8>(m_aValue.m_nInt16);
+ 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_nInt32);
+ 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>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ 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 = getAny();
+ 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(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::FLOAT:
+ nRet = sal_uInt8(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_uInt8(*(double*)m_aValue.m_pValue);
+ 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_ASSERT(!"getuInt8() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = 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:
{
@@ -1233,7 +1289,9 @@ sal_Int8 ORowSetValue::getInt8() const
}
return nRet;
}
+
// -------------------------------------------------------------------------
+
sal_Int16 ORowSetValue::getInt16() const
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt16" );
@@ -1251,12 +1309,6 @@ sal_Int16 ORowSetValue::getInt16() const
case DataType::LONGVARCHAR:
nRet = sal_Int16(::rtl::OUString(m_aValue.m_pString).toInt32());
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- nRet = sal_Int16(*(sal_Int64*)m_aValue.m_pValue);
- else
- nRet = sal_Int16(::rtl::OUString(m_aValue.m_pString).toInt32());
- break;
case DataType::FLOAT:
nRet = sal_Int16(*(float*)m_aValue.m_pValue);
break;
@@ -1282,19 +1334,25 @@ sal_Int16 ORowSetValue::getInt16() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = m_aValue.m_nInt16;
+ 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_nInt32);
+ 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>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ 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:
{
@@ -1307,10 +1365,10 @@ sal_Int16 ORowSetValue::getInt16() const
return nRet;
}
// -------------------------------------------------------------------------
-sal_Int32 ORowSetValue::getInt32() const
+
+sal_uInt16 ORowSetValue::getUInt16() const
{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt32" );
- sal_Int32 nRet = 0;
+ sal_uInt16 nRet = 0;
if(!m_bNull)
{
switch(getTypeKind())
@@ -1320,13 +1378,79 @@ sal_Int32 ORowSetValue::getInt32() const
case DataType::DECIMAL:
case DataType::NUMERIC:
case DataType::LONGVARCHAR:
- nRet = ::rtl::OUString(m_aValue.m_pString).toInt32();
+ nRet = sal_uInt16(::rtl::OUString(m_aValue.m_pString).toInt32());
+ break;
+ case DataType::FLOAT:
+ nRet = sal_uInt16(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_uInt16(*(double*)m_aValue.m_pValue);
+ 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_ASSERT(!"getuInt16() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = 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 = sal_Int32(*(sal_Int64*)m_aValue.m_pValue);
+ nRet = static_cast<sal_uInt16>(m_aValue.m_nInt64);
else
- nRet = ::rtl::OUString(m_aValue.m_pString).toInt32();
+ nRet = static_cast<sal_uInt16>(m_aValue.m_uInt64);
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ aValue >>= nRet;
+ break;
+ }
+ }
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 ORowSetValue::getInt32() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getInt32" );
+ 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 = ::rtl::OUString(m_aValue.m_pString).toInt32();
break;
case DataType::FLOAT:
nRet = sal_Int32(*(float*)m_aValue.m_pValue);
@@ -1355,19 +1479,98 @@ sal_Int32 ORowSetValue::getInt32() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = m_aValue.m_nInt16;
+ 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 = getAny();
+ 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 = ::rtl::OUString(m_aValue.m_pString).toInt32();
+ break;
+ case DataType::FLOAT:
+ nRet = sal_uInt32(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_uInt32(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::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_ASSERT(!"getuInt32() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = 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>(*static_cast<sal_Int64*>(m_aValue.m_pValue));
+ nRet = 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:
{
@@ -1380,6 +1583,7 @@ sal_Int32 ORowSetValue::getInt32() const
return nRet;
}
// -------------------------------------------------------------------------
+
sal_Int64 ORowSetValue::getLong() const
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::getLong" );
@@ -1395,18 +1599,85 @@ sal_Int64 ORowSetValue::getLong() const
case DataType::LONGVARCHAR:
nRet = ::rtl::OUString(m_aValue.m_pString).toInt64();
break;
+ case DataType::FLOAT:
+ nRet = sal_Int64(*(float*)m_aValue.m_pValue);
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ nRet = sal_Int64(*(double*)m_aValue.m_pValue);
+ break;
+ case DataType::DATE:
+ nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::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_ASSERT(!"getLong() for this type is not allowed!");
+ break;
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ nRet = 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 = *(sal_Int64*)m_aValue.m_pValue;
+ nRet = m_aValue.m_nInt64;
else
- nRet = ::rtl::OUString(m_aValue.m_pString).toInt64();
+ nRet = static_cast<sal_Int64>(m_aValue.m_uInt64);
+ break;
+ default:
+ {
+ Any aValue = getAny();
+ 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 = static_cast<sal_uInt64>(::rtl::OUString(m_aValue.m_pString).toInt64());
break;
case DataType::FLOAT:
- nRet = sal_Int64(*(float*)m_aValue.m_pValue);
+ nRet = sal_uInt64(*(float*)m_aValue.m_pValue);
break;
case DataType::DOUBLE:
case DataType::REAL:
- nRet = sal_Int64(*(double*)m_aValue.m_pValue);
+ nRet = sal_uInt64(*(double*)m_aValue.m_pValue);
break;
case DataType::DATE:
nRet = dbtools::DBTypeConversion::toDays(*(::com::sun::star::util::Date*)m_aValue.m_pValue);
@@ -1418,7 +1689,7 @@ sal_Int64 ORowSetValue::getLong() const
case DataType::LONGVARBINARY:
case DataType::BLOB:
case DataType::CLOB:
- OSL_ASSERT(!"getInt32() for this type is not allowed!");
+ OSL_ASSERT(!"getULong() for this type is not allowed!");
break;
case DataType::BIT:
case DataType::BOOLEAN:
@@ -1428,19 +1699,25 @@ sal_Int64 ORowSetValue::getLong() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = m_aValue.m_nInt16;
+ nRet = m_aValue.m_uInt16;
break;
case DataType::SMALLINT:
if ( m_bSigned )
nRet = m_aValue.m_nInt16;
else
- nRet = m_aValue.m_nInt32;
+ nRet = m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( m_bSigned )
nRet = m_aValue.m_nInt32;
else
- nRet = *(sal_Int64*)m_aValue.m_pValue;
+ 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:
{
@@ -1452,6 +1729,7 @@ sal_Int64 ORowSetValue::getLong() const
}
return nRet;
}
+
// -------------------------------------------------------------------------
float ORowSetValue::getFloat() const
{
@@ -1468,12 +1746,6 @@ float ORowSetValue::getFloat() const
case DataType::LONGVARCHAR:
nRet = ::rtl::OUString(m_aValue.m_pString).toFloat();
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- nRet = float(*(sal_Int64*)m_aValue.m_pValue);
- else
- nRet = ::rtl::OUString(m_aValue.m_pString).toFloat();
- break;
case DataType::FLOAT:
nRet = *(float*)m_aValue.m_pValue;
break;
@@ -1505,19 +1777,25 @@ float ORowSetValue::getFloat() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = m_aValue.m_nInt16;
+ nRet = m_aValue.m_uInt8;
break;
case DataType::SMALLINT:
if ( m_bSigned )
nRet = m_aValue.m_nInt16;
else
- nRet = (float)m_aValue.m_nInt32;
+ nRet = (float)m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( m_bSigned )
nRet = (float)m_aValue.m_nInt32;
else
- nRet = float(*(sal_Int64*)m_aValue.m_pValue);
+ nRet = (float)m_aValue.m_uInt32;
+ break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ nRet = (float)m_aValue.m_nInt64;
+ else
+ nRet = (float)m_aValue.m_uInt64;
break;
default:
{
@@ -1547,12 +1825,6 @@ double ORowSetValue::getDouble() const
case DataType::LONGVARCHAR:
nRet = ::rtl::OUString(m_aValue.m_pString).toDouble();
break;
- case DataType::BIGINT:
- if ( m_bSigned )
- nRet = double(*(sal_Int64*)m_aValue.m_pValue);
- else
- nRet = ::rtl::OUString(m_aValue.m_pString).toDouble();
- break;
case DataType::FLOAT:
nRet = *(float*)m_aValue.m_pValue;
break;
@@ -1584,19 +1856,25 @@ double ORowSetValue::getDouble() const
if ( m_bSigned )
nRet = m_aValue.m_nInt8;
else
- nRet = m_aValue.m_nInt16;
+ nRet = m_aValue.m_uInt8;
break;
case DataType::SMALLINT:
if ( m_bSigned )
nRet = m_aValue.m_nInt16;
else
- nRet = m_aValue.m_nInt32;
+ nRet = m_aValue.m_uInt16;
break;
case DataType::INTEGER:
if ( m_bSigned )
nRet = m_aValue.m_nInt32;
else
- nRet = double(*(sal_Int64*)m_aValue.m_pValue);
+ 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:
{
@@ -1839,7 +2117,7 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const
return aValue;
}
// -----------------------------------------------------------------------------
-void ORowSetValue::setSigned(sal_Bool _bMod)
+void ORowSetValue::setSigned(bool _bMod)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::setSigned" );
if ( m_bSigned != _bMod )
@@ -1850,24 +2128,6 @@ void ORowSetValue::setSigned(sal_Bool _bMod)
sal_Int32 nType = m_eTypeKind;
switch(m_eTypeKind)
{
- case DataType::BIGINT:
- if ( m_bSigned ) // now we are signed, so we were unsigned and need to call getString()
- {
- m_bSigned = !m_bSigned;
- const ::rtl::OUString sValue = getString();
- free();
- m_bSigned = !m_bSigned;
- (*this) = sValue;
- }
- else
- {
- m_bSigned = !m_bSigned;
- const sal_Int64 nValue = getLong();
- free();
- m_bSigned = !m_bSigned;
- (*this) = nValue;
- }
- break;
case DataType::TINYINT:
if ( m_bSigned )
(*this) = getInt8();
@@ -1898,6 +2158,12 @@ void ORowSetValue::setSigned(sal_Bool _bMod)
m_bSigned = !m_bSigned;
}
break;
+ case DataType::BIGINT:
+ if ( m_bSigned )
+ m_aValue.m_nInt64 = static_cast<sal_Int64>(m_aValue.m_uInt64);
+ else
+ m_aValue.m_uInt64 = static_cast<sal_uInt64>(m_aValue.m_nInt64);
+ break;
}
m_eTypeKind = nType;
}
@@ -1911,7 +2177,7 @@ namespace detail
{
public:
virtual ::rtl::OUString getString() const = 0;
- virtual sal_Bool getBoolean() const = 0;
+ virtual bool getBoolean() const = 0;
virtual sal_Int8 getByte() const = 0;
virtual sal_Int16 getShort() const = 0;
virtual sal_Int32 getInt() const = 0;
@@ -1927,7 +2193,7 @@ namespace detail
virtual Reference< XBlob > getBlob() const = 0;
virtual Reference< XClob > getClob() const = 0;
virtual Any getObject() const = 0;
- virtual sal_Bool wasNull() const = 0;
+ virtual bool wasNull() const = 0;
virtual ~IValueSource() { }
};
@@ -1943,7 +2209,7 @@ namespace detail
// IValueSource
virtual ::rtl::OUString getString() const { return m_xRow->getString( m_nPos ); };
- virtual sal_Bool getBoolean() const { return m_xRow->getBoolean( m_nPos ); };
+ virtual bool getBoolean() const { return m_xRow->getBoolean( m_nPos ); };
virtual sal_Int8 getByte() const { return m_xRow->getByte( m_nPos ); };
virtual sal_Int16 getShort() const { return m_xRow->getShort( m_nPos ); }
virtual sal_Int32 getInt() const { return m_xRow->getInt( m_nPos ); }
@@ -1959,7 +2225,7 @@ namespace detail
virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); };
virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); };
virtual Any getObject() const { return m_xRow->getObject( m_nPos ,NULL); };
- virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); };
+ virtual bool wasNull() const { return m_xRow->wasNull( ); };
private:
const Reference< XRow > m_xRow;
@@ -1976,7 +2242,7 @@ namespace detail
// IValueSource
virtual ::rtl::OUString getString() const { return m_xColumn->getString(); };
- virtual sal_Bool getBoolean() const { return m_xColumn->getBoolean(); };
+ virtual bool getBoolean() const { return m_xColumn->getBoolean(); };
virtual sal_Int8 getByte() const { return m_xColumn->getByte(); };
virtual sal_Int16 getShort() const { return m_xColumn->getShort(); }
virtual sal_Int32 getInt() const { return m_xColumn->getInt(); }
@@ -1992,7 +2258,7 @@ namespace detail
virtual Reference< XBlob > getBlob() const { return m_xColumn->getBlob(); };
virtual Reference< XClob > getClob() const { return m_xColumn->getClob(); };
virtual Any getObject() const { return m_xColumn->getObject( NULL ); };
- virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); };
+ virtual bool wasNull() const { return m_xColumn->wasNull( ); };
private:
const Reference< XColumn > m_xColumn;
@@ -2007,7 +2273,7 @@ void ORowSetValue::fill( const sal_Int32 _nType, const Reference< XColumn >& _rx
}
// -----------------------------------------------------------------------------
-void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, sal_Bool _bNullable, const Reference< XRow>& _xRow )
+void ORowSetValue::fill( sal_Int32 _nPos, sal_Int32 _nType, bool _bNullable, const Reference< XRow>& _xRow )
{
detail::RowValue aRowValue( _xRow, _nPos );
impl_fill( _nType, _bNullable, aRowValue );
@@ -2023,11 +2289,11 @@ void ORowSetValue::fill(sal_Int32 _nPos,
}
// -----------------------------------------------------------------------------
-void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const detail::IValueSource& _rValueSource )
+void ORowSetValue::impl_fill( const sal_Int32 _nType, bool _bNullable, const detail::IValueSource& _rValueSource )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbtools", "Ocke.Janssen@sun.com", "ORowSetValue::fill (2)" );
- sal_Bool bReadData = sal_True;
+ bool bReadData = sal_True;
switch(_nType)
{
case DataType::CHAR:
@@ -2041,7 +2307,11 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const
if ( isSigned() )
(*this) = _rValueSource.getLong();
else
- (*this) = _rValueSource.getString();
+ // TODO: this is rather horrible performance-wise
+ // but fixing it needs extending the ::com::sun::star::sdbc::XRow API
+ // to have a getULong(), and needs updating all drivers :-|
+ // When doing that, add getUByte, getUShort, getUInt for symmetry/completeness
+ (*this) = _rValueSource.getString().toUInt64();
break;
case DataType::FLOAT:
(*this) = _rValueSource.getFloat();
@@ -2114,11 +2384,10 @@ void ORowSetValue::fill(const Any& _rValue)
switch (_rValue.getValueType().getTypeClass())
{
case TypeClass_VOID:
- setNull();
- break;
+ setNull(); break;
case TypeClass_BOOLEAN:
{
- sal_Bool bValue( sal_False );
+ bool bValue( sal_False );
_rValue >>= bValue;
(*this) = bValue;
break;
@@ -2165,6 +2434,14 @@ void ORowSetValue::fill(const Any& _rValue)
(*this) = aDummy;
break;
}
+ case TypeClass_UNSIGNED_SHORT:
+ {
+ sal_uInt16 nValue(0);
+ _rValue >>= nValue;
+ (*this) = static_cast<sal_Int32>(nValue);
+ setSigned(sal_False);
+ break;
+ }
case TypeClass_LONG:
{
sal_Int32 aDummy(0);
@@ -2172,11 +2449,11 @@ void ORowSetValue::fill(const Any& _rValue)
(*this) = aDummy;
break;
}
- case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_UNSIGNED_LONG:
{
- sal_uInt16 nValue(0);
+ sal_uInt32 nValue(0);
_rValue >>= nValue;
- (*this) = static_cast<sal_Int32>(nValue);
+ (*this) = static_cast<sal_Int64>(nValue);
setSigned(sal_False);
break;
}
@@ -2191,15 +2468,7 @@ void ORowSetValue::fill(const Any& _rValue)
{
sal_uInt64 nValue(0);
_rValue >>= nValue;
- (*this) = static_cast<sal_Int64>(nValue);
- setSigned(sal_False);
- break;
- }
- case TypeClass_UNSIGNED_LONG:
- {
- sal_uInt32 nValue(0);
- _rValue >>= nValue;
- (*this) = static_cast<sal_Int64>(nValue);
+ (*this) = nValue;
setSigned(sal_False);
break;
}
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
index bd256d5d79df..37307f6dd7ae 100644
--- a/connectivity/source/drivers/file/FPreparedStatement.cxx
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -221,7 +221,7 @@ Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLE
void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBoolean" );
- setParameter(parameterIndex,x);
+ setParameter(parameterIndex,static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
index 0987eb68e936..b59042e1bde9 100644
--- a/connectivity/source/drivers/file/FResultSet.cxx
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -757,7 +757,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
- updateValue(columnIndex,x);
+ updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx
index 03f1c1bfba49..6cca9c218926 100644
--- a/connectivity/source/drivers/mork/MResultSet.cxx
+++ b/connectivity/source/drivers/mork/MResultSet.cxx
@@ -1699,7 +1699,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
- updateValue(columnIndex,x);
+ updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx
index 80471538a9d7..b0711fccf017 100644
--- a/connectivity/source/drivers/mozab/MResultSet.cxx
+++ b/connectivity/source/drivers/mozab/MResultSet.cxx
@@ -1696,7 +1696,7 @@ void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException
void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
- updateValue(columnIndex,x);
+ updateValue(columnIndex, static_cast<bool>(x));
}
// -------------------------------------------------------------------------
void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 50b9aa322640..9d6489942fc4 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -719,7 +719,7 @@ void SAL_CALL ORowSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, R
void SAL_CALL ORowSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
- updateValue(columnIndex,x);
+ updateValue(columnIndex, static_cast<bool>(x));
}
void SAL_CALL ORowSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
@@ -2475,7 +2475,7 @@ void ORowSet::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
void SAL_CALL ORowSet::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
{
- setParameter(parameterIndex,x);
+ setParameter(parameterIndex, static_cast<bool>(x));
}
void SAL_CALL ORowSet::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)