From 6e7c923d632c757c9a38a724cad2d55a84755570 Mon Sep 17 00:00:00 2001 From: Jorenz Paragas Date: Fri, 10 Jul 2015 21:07:51 -0700 Subject: tdf#91112 replace o3tl::compose1 with lambdas in connectivity Change-Id: I8f61471e08fe7f620d76bdcd72eb7f5c35931388 Reviewed-on: https://gerrit.libreoffice.org/16940 Tested-by: Jenkins Reviewed-by: Michael Stahl --- connectivity/source/drivers/ado/AColumn.cxx | 14 ++++---------- connectivity/source/drivers/ado/AColumns.cxx | 14 ++++---------- connectivity/source/drivers/ado/AConnection.cxx | 14 +++++--------- connectivity/source/drivers/hsqldb/HDriver.cxx | 16 ++++++++++------ connectivity/source/drivers/hsqldb/HStorageMap.cxx | 18 ++++++++++-------- connectivity/source/drivers/odbc/OResultSet.cxx | 4 +++- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index 7a9769f0a6ae..81e18c5b1193 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -215,16 +215,10 @@ void OAdoColumn::fillPropertyValues() else if ( eType == adVarBinary && ADOS::isJetEngine(m_pConnection->getEngineType()) ) { ::comphelper::UStringMixEqual aCase(sal_False); - OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), - pTypeInfoMap->end(), - ::o3tl::compose1( - ::std::bind2nd(aCase, OUString("VarBinary")), - ::o3tl::compose1( - ::std::mem_fun(&OExtendedTypeInfo::getDBName), - ::o3tl::select2nd()) - ) - - ); + OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), pTypeInfoMap->end(), + [&aCase] (OTypeInfoMap::value_type typeInfo) { + return aCase(typeInfo.second->getDBName(), OUString("VarBinary")); + }); if ( aFind != pTypeInfoMap->end() ) // change column type if necessary { diff --git a/connectivity/source/drivers/ado/AColumns.cxx b/connectivity/source/drivers/ado/AColumns.cxx index 936510f155e3..66af0bc58aeb 100644 --- a/connectivity/source/drivers/ado/AColumns.cxx +++ b/connectivity/source/drivers/ado/AColumns.cxx @@ -88,16 +88,10 @@ sdbcx::ObjectType OColumns::appendObject( const OUString&, const Reference< XPro const OTypeInfoMap* pTypeInfoMap = m_pConnection->getTypeInfo(); ::comphelper::UStringMixEqual aCase(sal_False); // search for typeinfo where the typename is equal sTypeName - OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), - pTypeInfoMap->end(), - ::o3tl::compose1( - ::std::bind2nd(aCase, sTypeName), - ::o3tl::compose1( - ::std::mem_fun(&OExtendedTypeInfo::getDBName), - ::o3tl::select2nd()) - ) - - ); + OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(), pTypeInfoMap->end(), + [&aCase, &sTypeName] (OTypeInfoMap::value_type typeInfo) { + return aCase(typeInfo.second->getDBName(), sTypeName); + }); if ( aFind != pTypeInfoMap->end() ) // change column type if necessary aColumn.put_Type(aFind->first); diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 319bc688769e..463db7f4f833 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -598,15 +598,11 @@ const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _r { ::comphelper::UStringMixEqual aCase(sal_False); // search for typeinfo where the typename is equal _sTypeName - OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(), - _rTypeInfo.end(), - ::o3tl::compose1( - ::std::bind2nd(aCase, _sTypeName), - ::o3tl::compose1( - ::std::mem_fun(&OExtendedTypeInfo::getDBName), - ::o3tl::select2nd()) - ) - ); + OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(), _rTypeInfo.end(), + [&aCase, &_sTypeName] (OTypeInfoMap::value_type typeInfo) { + return aCase(typeInfo.second->getDBName(), _sTypeName); + }); + if(aFind != _rTypeInfo.end()) pTypeInfo = aFind->second; } diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 87eb271ecd1c..373f0e81e593 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -583,9 +583,11 @@ namespace connectivity if ( xStorage.is() ) { OUString sKey = StorageContainer::getRegisteredKey(xStorage); - TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::o3tl::compose1( - ::std::bind2nd(::std::equal_to< OUString >(),sKey) - ,::o3tl::compose1(::o3tl::select1st(),::o3tl::select2nd< TWeakPair >()))); + TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(), + [&sKey] (TWeakPairVector::value_type conn) { + return conn.second.first == sKey; + }); + if ( i != m_aConnections.end() ) shutdownConnection(i); } @@ -637,9 +639,11 @@ namespace connectivity OUString sKey = StorageContainer::getRegisteredKey(xStorage); if ( !sKey.isEmpty() ) { - TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::o3tl::compose1( - ::std::bind2nd(::std::equal_to< OUString >(),sKey) - ,::o3tl::compose1(::o3tl::select1st(),::o3tl::select2nd< TWeakPair >()))); + TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(), m_aConnections.end(), + [&sKey] (TWeakPairVector::value_type conn) { + return conn.second.first == sKey; + }); + OSL_ENSURE( i != m_aConnections.end(), "ODriverDelegator::preCommit: they're committing a storage which I do not know!" ); if ( i != m_aConnections.end() ) { diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx index 64566b136e0e..dd84f849ec72 100644 --- a/connectivity/source/drivers/hsqldb/HStorageMap.cxx +++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx @@ -171,10 +171,11 @@ namespace connectivity TStorages& rMap = lcl_getStorageMap(); // check if the storage is already in our map TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(), - ::o3tl::compose1( - ::std::bind2nd(::std::equal_to >(),_xStorage) - ,::o3tl::compose1(::o3tl::select1st(),::o3tl::compose1(::o3tl::select1st(),::o3tl::select2nd()))) - ); + [&_xStorage] (TStorages::value_type storage) { + // TStoragePair (second) -> TStorageURLPair (first) -> uno::Reference (first) + return storage.second.first.first == _xStorage; + }); + if ( aFind == rMap.end() ) { aFind = rMap.insert(TStorages::value_type(lcl_getNextCount(),TStorages::mapped_type(TStorageURLPair(_xStorage,_sURL),TStreamMap()))).first; @@ -202,10 +203,11 @@ namespace connectivity TStorages& rMap = lcl_getStorageMap(); // check if the storage is already in our map TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(), - ::o3tl::compose1( - ::std::bind2nd(::std::equal_to >(),_xStorage) - ,::o3tl::compose1(::o3tl::select1st(),::o3tl::compose1(::o3tl::select1st(),::o3tl::select2nd()))) - ); + [&_xStorage] (TStorages::value_type storage) { + // TStoragePair (second) -> TStorageURLPair (first) -> uno::Reference (first) + return storage.second.first.first == _xStorage; + }); + if ( aFind != rMap.end() ) sKey = aFind->first; return sKey; diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index a62686b99272..260f0a6f02c2 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -1167,7 +1167,9 @@ Sequence OResultSet::impl_getBookmark( ) throw( SQLException, Runtim checkDisposed(OResultSet_BASE::rBHelper.bDisposed); TBookmarkPosMap::iterator aFind = ::std::find_if(m_aPosToBookmarks.begin(),m_aPosToBookmarks.end(), - ::o3tl::compose1(::std::bind2nd(::std::equal_to(),m_nRowPos),::o3tl::select2nd())); + [this] (TBookmarkPosMap::value_type bookmarkPos) { + return bookmarkPos.second == m_nRowPos; + }); if ( aFind == m_aPosToBookmarks.end() ) { -- cgit v1.2.3