From 61e0433fdf1bfd391378ff9fcbf697aec4c5e61a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 6 Jun 2016 09:47:01 +0200 Subject: Use o3tl/any.hxx in connectivity Change-Id: I5c0d84b20b9146c4fc65bfdc0e9c65a05c93d71c --- connectivity/source/commontools/dbexception.cxx | 17 ++--- connectivity/source/commontools/dbtools.cxx | 73 +++++++++++----------- .../source/commontools/warningscontainer.cxx | 3 +- .../source/drivers/postgresql/pq_tools.cxx | 35 ++++++----- 4 files changed, 66 insertions(+), 62 deletions(-) diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index f718a3ceb218..38251b71eee2 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -174,14 +175,14 @@ bool SQLExceptionInfo::isKindOf(TYPE _eType) const SQLExceptionInfo::operator const css::sdbc::SQLException*() const { OSL_ENSURE(isKindOf(TYPE::SQLException), "SQLExceptionInfo::operator SQLException* : invalid call !"); - return static_cast(m_aContent.getValue()); + return o3tl::doGet(m_aContent); } SQLExceptionInfo::operator const css::sdb::SQLContext*() const { OSL_ENSURE(isKindOf(TYPE::SQLContext), "SQLExceptionInfo::operator SQLException* : invalid call !"); - return static_cast(m_aContent.getValue()); + return o3tl::doGet(m_aContent); } @@ -212,10 +213,10 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons break; } - SQLException* pAppendException( static_cast< SQLException* >( const_cast< void* >( aAppend.getValue() ) ) ); - pAppendException->Message = _rErrorMessage; - pAppendException->SQLState = _rSQLState; - pAppendException->ErrorCode = _nErrorCode; + SQLException& pAppendException = const_cast(*o3tl::forceGet(aAppend)); + pAppendException.Message = _rErrorMessage; + pAppendException.SQLState = _rSQLState; + pAppendException.ErrorCode = _nErrorCode; // find the end of the current chain Any* pChainIterator = &m_aContent; @@ -229,7 +230,7 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) ) break; - pLastException = static_cast< SQLException* >( const_cast< void* >( pChainIterator->getValue() ) ); + pLastException = const_cast< SQLException* >( o3tl::doGet( *pChainIterator ) ); pChainIterator = &pLastException->NextException; } @@ -313,7 +314,7 @@ const css::sdbc::SQLException* SQLExceptionIteratorHelper::next() return pReturn; } - m_pCurrent = static_cast< const SQLException* >( m_pCurrent->NextException.getValue() ); + m_pCurrent = o3tl::doGet< SQLException >( m_pCurrent->NextException ); // no finally determine the proper type of the exception const Type aTypeContext( ::cppu::UnoType< SQLContext >::get() ); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 45e0e36659a2..b71ff9aa8cd0 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -1155,14 +1156,14 @@ try { Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) ); if (aDate.hasValue()) - aNewDefault <<= DBTypeConversion::toDouble(*static_cast(aDate.getValue())); + aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doGet(aDate)); } if (hasProperty(sPropDefaultTime, xOldProps)) { Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) ); if (aTime.hasValue()) - aNewDefault <<= DBTypeConversion::toDouble(*static_cast