summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-10 15:52:05 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-06-10 15:52:05 +0200
commit8132d7f9d71d9f6418855d2d6241dae804beeb8b (patch)
tree7394f094265efdfaaa4ce02ce287da39c1a43f1a /connectivity
parent285744fef87f4ca0278834b97d7f618bdba5f4c0 (diff)
o3tl::tryGet on a temporary is dangerous
...so rename to o3tl::tryAccess to make it more obvious that the returned proxy points into the internals of the given Any, and forbid calling o3tl::tryAccess on a temporary Change-Id: Ia412c6b2b06693811b9b7f0076a08bbf97142df9
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/commontools/dbexception.cxx10
-rw-r--r--connectivity/source/commontools/dbtools.cxx52
-rw-r--r--connectivity/source/commontools/warningscontainer.cxx2
-rw-r--r--connectivity/source/drivers/postgresql/pq_tools.cxx24
4 files changed, 44 insertions, 44 deletions
diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx
index 38251b71eee2..d1b6baf56411 100644
--- a/connectivity/source/commontools/dbexception.cxx
+++ b/connectivity/source/commontools/dbexception.cxx
@@ -175,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 o3tl::doGet<css::sdbc::SQLException>(m_aContent);
+ return o3tl::doAccess<css::sdbc::SQLException>(m_aContent);
}
SQLExceptionInfo::operator const css::sdb::SQLContext*() const
{
OSL_ENSURE(isKindOf(TYPE::SQLContext), "SQLExceptionInfo::operator SQLException* : invalid call !");
- return o3tl::doGet<css::sdb::SQLContext>(m_aContent);
+ return o3tl::doAccess<css::sdb::SQLContext>(m_aContent);
}
@@ -213,7 +213,7 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons
break;
}
- SQLException& pAppendException = const_cast<SQLException &>(*o3tl::forceGet<SQLException>(aAppend));
+ SQLException& pAppendException = const_cast<SQLException &>(*o3tl::forceAccess<SQLException>(aAppend));
pAppendException.Message = _rErrorMessage;
pAppendException.SQLState = _rSQLState;
pAppendException.ErrorCode = _nErrorCode;
@@ -230,7 +230,7 @@ void SQLExceptionInfo::append( TYPE _eType, const OUString& _rErrorMessage, cons
if ( !isAssignableFrom( aSQLExceptionType, pChainIterator->getValueType() ) )
break;
- pLastException = const_cast< SQLException* >( o3tl::doGet<SQLException>( *pChainIterator ) );
+ pLastException = const_cast< SQLException* >( o3tl::doAccess<SQLException>( *pChainIterator ) );
pChainIterator = &pLastException->NextException;
}
@@ -314,7 +314,7 @@ const css::sdbc::SQLException* SQLExceptionIteratorHelper::next()
return pReturn;
}
- m_pCurrent = o3tl::doGet< SQLException >( m_pCurrent->NextException );
+ m_pCurrent = o3tl::doAccess< 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 b71ff9aa8cd0..701c64d7e63d 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -1156,14 +1156,14 @@ try
{
Any aDate( xOldProps->getPropertyValue(sPropDefaultDate) );
if (aDate.hasValue())
- aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doGet<Date>(aDate));
+ aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess<Date>(aDate));
}
if (hasProperty(sPropDefaultTime, xOldProps))
{
Any aTime( xOldProps->getPropertyValue(sPropDefaultTime) );
if (aTime.hasValue())
- aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doGet<Time>(aTime));
+ aNewDefault <<= DBTypeConversion::toDouble(*o3tl::doAccess<Time>(aTime));
}
// double or OUString will be copied directly
@@ -1450,29 +1450,29 @@ bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
break;
case TypeClass_STRING:
- _rxUpdatedObject->updateString(_nColumnIndex, *o3tl::forceGet<OUString>(_rValue));
+ _rxUpdatedObject->updateString(_nColumnIndex, *o3tl::forceAccess<OUString>(_rValue));
break;
case TypeClass_BOOLEAN:
- _rxUpdatedObject->updateBoolean(_nColumnIndex, *o3tl::forceGet<bool>(_rValue));
+ _rxUpdatedObject->updateBoolean(_nColumnIndex, *o3tl::forceAccess<bool>(_rValue));
break;
case TypeClass_BYTE:
- _rxUpdatedObject->updateByte(_nColumnIndex, *o3tl::forceGet<sal_Int8>(_rValue));
+ _rxUpdatedObject->updateByte(_nColumnIndex, *o3tl::forceAccess<sal_Int8>(_rValue));
break;
case TypeClass_UNSIGNED_SHORT:
case TypeClass_SHORT:
- _rxUpdatedObject->updateShort(_nColumnIndex, *o3tl::forceGet<sal_Int16>(_rValue));
+ _rxUpdatedObject->updateShort(_nColumnIndex, *o3tl::forceAccess<sal_Int16>(_rValue));
break;
case TypeClass_CHAR:
- _rxUpdatedObject->updateString(_nColumnIndex,OUString(*o3tl::forceGet<sal_Unicode>(_rValue)));
+ _rxUpdatedObject->updateString(_nColumnIndex,OUString(*o3tl::forceAccess<sal_Unicode>(_rValue)));
break;
case TypeClass_UNSIGNED_LONG:
case TypeClass_LONG:
- _rxUpdatedObject->updateInt(_nColumnIndex, *o3tl::forceGet<sal_Int32>(_rValue));
+ _rxUpdatedObject->updateInt(_nColumnIndex, *o3tl::forceAccess<sal_Int32>(_rValue));
break;
case TypeClass_HYPER:
@@ -1484,32 +1484,32 @@ bool implUpdateObject(const Reference< XRowUpdate >& _rxUpdatedObject,
break;
case TypeClass_FLOAT:
- _rxUpdatedObject->updateFloat(_nColumnIndex, *o3tl::forceGet<float>(_rValue));
+ _rxUpdatedObject->updateFloat(_nColumnIndex, *o3tl::forceAccess<float>(_rValue));
break;
case TypeClass_DOUBLE:
- _rxUpdatedObject->updateDouble(_nColumnIndex, *o3tl::forceGet<double>(_rValue));
+ _rxUpdatedObject->updateDouble(_nColumnIndex, *o3tl::forceAccess<double>(_rValue));
break;
case TypeClass_SEQUENCE:
- if (auto s = o3tl::tryGet<Sequence< sal_Int8 >>(_rValue))
+ if (auto s = o3tl::tryAccess<Sequence< sal_Int8 >>(_rValue))
_rxUpdatedObject->updateBytes(_nColumnIndex, *s);
else
bSuccessfullyReRouted = false;
break;
case TypeClass_STRUCT:
- if (auto s1 = o3tl::tryGet<DateTime>(_rValue))
+ if (auto s1 = o3tl::tryAccess<DateTime>(_rValue))
_rxUpdatedObject->updateTimestamp(_nColumnIndex, *s1);
- else if (auto s2 = o3tl::tryGet<Date>(_rValue))
+ else if (auto s2 = o3tl::tryAccess<Date>(_rValue))
_rxUpdatedObject->updateDate(_nColumnIndex, *s2);
- else if (auto s3 = o3tl::tryGet<Time>(_rValue))
+ else if (auto s3 = o3tl::tryAccess<Time>(_rValue))
_rxUpdatedObject->updateTime(_nColumnIndex, *s3);
else
bSuccessfullyReRouted = false;
break;
case TypeClass_INTERFACE:
- if (auto xStream = o3tl::tryGet<Reference<XInputStream>>(_rValue))
+ if (auto xStream = o3tl::tryAccess<Reference<XInputStream>>(_rValue))
{
_rxUpdatedObject->updateBinaryStream(_nColumnIndex, *xStream, (*xStream)->available());
break;
@@ -1558,23 +1558,23 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
break;
case TypeClass_STRING:
- _rxParameters->setString(_nColumnIndex, *o3tl::forceGet<OUString>(_rValue));
+ _rxParameters->setString(_nColumnIndex, *o3tl::forceAccess<OUString>(_rValue));
break;
case TypeClass_BOOLEAN:
- _rxParameters->setBoolean(_nColumnIndex, *o3tl::forceGet<bool>(_rValue));
+ _rxParameters->setBoolean(_nColumnIndex, *o3tl::forceAccess<bool>(_rValue));
break;
case TypeClass_BYTE:
- _rxParameters->setByte(_nColumnIndex, *o3tl::forceGet<sal_Int8>(_rValue));
+ _rxParameters->setByte(_nColumnIndex, *o3tl::forceAccess<sal_Int8>(_rValue));
break;
case TypeClass_SHORT:
- _rxParameters->setShort(_nColumnIndex, *o3tl::forceGet<sal_Int16>(_rValue));
+ _rxParameters->setShort(_nColumnIndex, *o3tl::forceAccess<sal_Int16>(_rValue));
break;
case TypeClass_CHAR:
- _rxParameters->setString(_nColumnIndex, OUString(*o3tl::forceGet<sal_Unicode>(_rValue)));
+ _rxParameters->setString(_nColumnIndex, OUString(*o3tl::forceAccess<sal_Unicode>(_rValue)));
break;
case TypeClass_UNSIGNED_SHORT:
@@ -1587,15 +1587,15 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
}
case TypeClass_FLOAT:
- _rxParameters->setFloat(_nColumnIndex, *o3tl::forceGet<float>(_rValue));
+ _rxParameters->setFloat(_nColumnIndex, *o3tl::forceAccess<float>(_rValue));
break;
case TypeClass_DOUBLE:
- _rxParameters->setDouble(_nColumnIndex, *o3tl::forceGet<double>(_rValue));
+ _rxParameters->setDouble(_nColumnIndex, *o3tl::forceAccess<double>(_rValue));
break;
case TypeClass_SEQUENCE:
- if (auto s = o3tl::tryGet<Sequence< sal_Int8 >>(_rValue))
+ if (auto s = o3tl::tryAccess<Sequence< sal_Int8 >>(_rValue))
{
_rxParameters->setBytes(_nColumnIndex, *s);
}
@@ -1603,11 +1603,11 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
bSuccessfullyReRouted = false;
break;
case TypeClass_STRUCT:
- if (auto s1 = o3tl::tryGet<DateTime>(_rValue))
+ if (auto s1 = o3tl::tryAccess<DateTime>(_rValue))
_rxParameters->setTimestamp(_nColumnIndex, *s1);
- else if (auto s2 = o3tl::tryGet<Date>(_rValue))
+ else if (auto s2 = o3tl::tryAccess<Date>(_rValue))
_rxParameters->setDate(_nColumnIndex, *s2);
- else if (auto s3 = o3tl::tryGet<Time>(_rValue))
+ else if (auto s3 = o3tl::tryAccess<Time>(_rValue))
_rxParameters->setTime(_nColumnIndex, *s3);
else
bSuccessfullyReRouted = false;
diff --git a/connectivity/source/commontools/warningscontainer.cxx b/connectivity/source/commontools/warningscontainer.cxx
index 787b6cf8f9e3..2e7d6244c052 100644
--- a/connectivity/source/commontools/warningscontainer.cxx
+++ b/connectivity/source/commontools/warningscontainer.cxx
@@ -45,7 +45,7 @@ namespace dbtools
OSL_ENSURE( SQLExceptionInfo( _rChainLeft ).isValid(),
"lcl_concatWarnings: invalid warnings chain (this will crash)!" );
- const SQLException* pChainTravel = o3tl::doGet<SQLException>( _rChainLeft );
+ const SQLException* pChainTravel = o3tl::doAccess<SQLException>( _rChainLeft );
SQLExceptionIteratorHelper aReferenceIterHelper( *pChainTravel );
while ( aReferenceIterHelper.hasMoreElements() )
pChainTravel = aReferenceIterHelper.next();
diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx
index 06898e9f82e1..4e6df8b0fdf2 100644
--- a/connectivity/source/drivers/postgresql/pq_tools.cxx
+++ b/connectivity/source/drivers/postgresql/pq_tools.cxx
@@ -1166,41 +1166,41 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
break;
case typelib_TypeClass_STRING:
- _rxParameters->setString(_nColumnIndex, *o3tl::forceGet<OUString>(_rValue));
+ _rxParameters->setString(_nColumnIndex, *o3tl::forceAccess<OUString>(_rValue));
break;
case typelib_TypeClass_BOOLEAN:
- _rxParameters->setBoolean(_nColumnIndex, *o3tl::forceGet<bool>(_rValue));
+ _rxParameters->setBoolean(_nColumnIndex, *o3tl::forceAccess<bool>(_rValue));
break;
case typelib_TypeClass_BYTE:
- _rxParameters->setByte(_nColumnIndex, *o3tl::forceGet<sal_Int8>(_rValue));
+ _rxParameters->setByte(_nColumnIndex, *o3tl::forceAccess<sal_Int8>(_rValue));
break;
case typelib_TypeClass_UNSIGNED_SHORT:
case typelib_TypeClass_SHORT:
- _rxParameters->setShort(_nColumnIndex, *o3tl::forceGet<sal_Int16>(_rValue));
+ _rxParameters->setShort(_nColumnIndex, *o3tl::forceAccess<sal_Int16>(_rValue));
break;
case typelib_TypeClass_CHAR:
- _rxParameters->setString(_nColumnIndex, OUString(*o3tl::forceGet<sal_Unicode>(_rValue)));
+ _rxParameters->setString(_nColumnIndex, OUString(*o3tl::forceAccess<sal_Unicode>(_rValue)));
break;
case typelib_TypeClass_UNSIGNED_LONG:
case typelib_TypeClass_LONG:
- _rxParameters->setInt(_nColumnIndex, *o3tl::forceGet<sal_Int32>(_rValue));
+ _rxParameters->setInt(_nColumnIndex, *o3tl::forceAccess<sal_Int32>(_rValue));
break;
case typelib_TypeClass_FLOAT:
- _rxParameters->setFloat(_nColumnIndex, *o3tl::forceGet<float>(_rValue));
+ _rxParameters->setFloat(_nColumnIndex, *o3tl::forceAccess<float>(_rValue));
break;
case typelib_TypeClass_DOUBLE:
- _rxParameters->setDouble(_nColumnIndex, *o3tl::forceGet<double>(_rValue));
+ _rxParameters->setDouble(_nColumnIndex, *o3tl::forceAccess<double>(_rValue));
break;
case typelib_TypeClass_SEQUENCE:
- if (auto s = o3tl::tryGet<Sequence< sal_Int8 >>(_rValue))
+ if (auto s = o3tl::tryAccess<Sequence< sal_Int8 >>(_rValue))
{
_rxParameters->setBytes(_nColumnIndex, *s);
}
@@ -1208,11 +1208,11 @@ bool implSetObject( const Reference< XParameters >& _rxParameters,
bSuccessfullyReRouted = false;
break;
case typelib_TypeClass_STRUCT:
- if (auto s1 = o3tl::tryGet<css::util::DateTime>(_rValue))
+ if (auto s1 = o3tl::tryAccess<css::util::DateTime>(_rValue))
_rxParameters->setTimestamp(_nColumnIndex, *s1);
- else if (auto s2 = o3tl::tryGet<css::util::Date>(_rValue))
+ else if (auto s2 = o3tl::tryAccess<css::util::Date>(_rValue))
_rxParameters->setDate(_nColumnIndex, *s2);
- else if (auto s3 = o3tl::tryGet<css::util::Time>(_rValue))
+ else if (auto s3 = o3tl::tryAccess<css::util::Time>(_rValue))
_rxParameters->setTime(_nColumnIndex, *s3);
else
bSuccessfullyReRouted = false;