[Libreoffice-commits] core.git: dbaccess/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Mar 13 10:27:29 UTC 2018
dbaccess/source/core/api/HelperCollections.cxx | 4 +-
dbaccess/source/core/api/HelperCollections.hxx | 2 -
dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 34 ++++++-----------
dbaccess/source/core/api/query.cxx | 2 -
dbaccess/source/core/inc/SingleSelectQueryComposer.hxx | 10 +++--
5 files changed, 23 insertions(+), 29 deletions(-)
New commits:
commit e0d59468b156e5cc474b5540e05a6aa92ab5cfa0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Tue Mar 13 10:42:32 2018 +0200
loplugin:useuniqueptr in OSingleSelectQueryComposer
Change-Id: I02eb65c7a5a1dfd768e35b596303eb3e49c3dfd0
Reviewed-on: https://gerrit.libreoffice.org/51196
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/dbaccess/source/core/api/HelperCollections.cxx b/dbaccess/source/core/api/HelperCollections.cxx
index edf1a60c0a1c..c55392c4db98 100644
--- a/dbaccess/source/core/api/HelperCollections.cxx
+++ b/dbaccess/source/core/api/HelperCollections.cxx
@@ -49,7 +49,7 @@ namespace dbaccess
{
}
- OPrivateColumns* OPrivateColumns::createWithIntrinsicNames( const ::rtl::Reference< ::connectivity::OSQLColumns >& _rColumns,
+ std::unique_ptr<OPrivateColumns> OPrivateColumns::createWithIntrinsicNames( const ::rtl::Reference< ::connectivity::OSQLColumns >& _rColumns,
bool _bCase, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex )
{
std::vector< OUString > aNames; aNames.reserve( _rColumns->get().size() );
@@ -61,7 +61,7 @@ namespace dbaccess
xColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumName;
aNames.push_back( sColumName );
}
- return new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, false );
+ return std::unique_ptr<OPrivateColumns>(new OPrivateColumns( _rColumns, _bCase, _rParent, _rMutex, aNames, false ));
}
void OPrivateColumns::disposing()
diff --git a/dbaccess/source/core/api/HelperCollections.hxx b/dbaccess/source/core/api/HelperCollections.hxx
index 1e6da30e68b7..dceecbc73158 100644
--- a/dbaccess/source/core/api/HelperCollections.hxx
+++ b/dbaccess/source/core/api/HelperCollections.hxx
@@ -63,7 +63,7 @@ namespace dbaccess
/** creates a columns instance as above, but taking the names from the columns itself
*/
- static OPrivateColumns* createWithIntrinsicNames(
+ static std::unique_ptr<OPrivateColumns> createWithIntrinsicNames(
const ::rtl::Reference< ::connectivity::OSQLColumns >& _rColumns,
bool _bCase,
::cppu::OWeakObject& _rParent,
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 04b3bb40e51b..dcd61f42f7e8 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -264,11 +264,6 @@ OSingleSelectQueryComposer::OSingleSelectQueryComposer(const Reference< XNameAcc
OSingleSelectQueryComposer::~OSingleSelectQueryComposer()
{
- for (auto const& columnCollection : m_aColumnsCollection)
- delete columnCollection;
-
- for (auto const& tableCollection : m_aTablesCollection)
- delete tableCollection;
}
// OComponentHelper
@@ -727,10 +722,10 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getTables( )
for (auto const& elem : aTables)
aNames.push_back(elem.first);
- m_pTables = new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames);
+ m_pTables.reset( new OPrivateTables(aTables,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames) );
}
- return m_pTables;
+ return m_pTables.get();
}
// XColumnsSupplier
@@ -739,7 +734,7 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( )
::connectivity::checkDisposed(OSubComponent::rBHelper.bDisposed);
::osl::MutexGuard aGuard( m_aMutex );
if ( !!m_aCurrentColumns[SelectColumns] )
- return m_aCurrentColumns[SelectColumns];
+ return m_aCurrentColumns[SelectColumns].get();
std::vector< OUString> aNames;
::rtl::Reference< OSQLColumns> aSelectColumns;
@@ -948,9 +943,9 @@ Reference< XNameAccess > SAL_CALL OSingleSelectQueryComposer::getColumns( )
if ( aNames.empty() )
m_aCurrentColumns[ SelectColumns ] = OPrivateColumns::createWithIntrinsicNames( aSelectColumns, bCase, *this, m_aMutex );
else
- m_aCurrentColumns[ SelectColumns ] = new OPrivateColumns( aSelectColumns, bCase, *this, m_aMutex, aNames );
+ m_aCurrentColumns[ SelectColumns ].reset( new OPrivateColumns( aSelectColumns, bCase, *this, m_aMutex, aNames ) );
- return m_aCurrentColumns[SelectColumns];
+ return m_aCurrentColumns[SelectColumns].get();
}
bool OSingleSelectQueryComposer::setORCriteria(OSQLParseNode const * pCondition, OSQLParseTreeIterator& _rIterator,
@@ -1330,20 +1325,19 @@ Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getParameters( )
std::vector< OUString> aNames;
for (auto const& elem : aCols->get())
aNames.push_back(getString(elem->getPropertyValue(PROPERTY_NAME)));
- m_aCurrentColumns[ParameterColumns] = new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true);
+ m_aCurrentColumns[ParameterColumns].reset( new OPrivateColumns(aCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true) );
}
- return m_aCurrentColumns[ParameterColumns];
+ return m_aCurrentColumns[ParameterColumns].get();
}
void OSingleSelectQueryComposer::clearColumns( const EColumnType _eType )
{
- OPrivateColumns* pColumns = m_aCurrentColumns[ _eType ];
+ OPrivateColumns* pColumns = m_aCurrentColumns[ _eType ].get();
if ( pColumns != nullptr )
{
pColumns->disposing();
- m_aColumnsCollection.push_back( pColumns );
- m_aCurrentColumns[ _eType ] = nullptr;
+ m_aColumnsCollection.push_back( std::move(m_aCurrentColumns[ _eType ]) );
}
}
@@ -1354,16 +1348,14 @@ void OSingleSelectQueryComposer::clearCurrentCollections()
if (currentColumn)
{
currentColumn->disposing();
- m_aColumnsCollection.push_back(currentColumn);
- currentColumn = nullptr;
+ m_aColumnsCollection.push_back(std::move(currentColumn));
}
}
if(m_pTables)
{
m_pTables->disposing();
- m_aTablesCollection.push_back(m_pTables);
- m_pTables = nullptr;
+ m_aTablesCollection.push_back(std::move(m_pTables));
}
}
@@ -1379,10 +1371,10 @@ Reference< XIndexAccess > OSingleSelectQueryComposer::setCurrentColumns( EColumn
std::vector< OUString> aNames;
for (auto const& elem : _rCols->get())
aNames.push_back(getString(elem->getPropertyValue(PROPERTY_NAME)));
- m_aCurrentColumns[_eType] = new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true);
+ m_aCurrentColumns[_eType].reset( new OPrivateColumns(_rCols,m_xMetaData->supportsMixedCaseQuotedIdentifiers(),*this,m_aMutex,aNames,true) );
}
- return m_aCurrentColumns[_eType];
+ return m_aCurrentColumns[_eType].get();
}
Reference< XIndexAccess > SAL_CALL OSingleSelectQueryComposer::getGroupColumns( )
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx
index d5234c7929dd..f05569d9ba75 100644
--- a/dbaccess/source/core/api/query.cxx
+++ b/dbaccess/source/core/api/query.cxx
@@ -165,7 +165,7 @@ void OQuery::rebuildColumns()
::rtl::Reference< OSQLColumns > aParseColumns(
::connectivity::parse::OParseColumn::createColumnsForResultSet( xResultSetMeta, xDBMeta,xColumnDefinitions ) );
xColumns = OPrivateColumns::createWithIntrinsicNames(
- aParseColumns, xDBMeta->supportsMixedCaseQuotedIdentifiers(), *this, m_aMutex );
+ aParseColumns, xDBMeta->supportsMixedCaseQuotedIdentifiers(), *this, m_aMutex ).release();
if ( !xColumns.is() )
throw RuntimeException();
}
diff --git a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
index d17add7850ea..524ca93cdcca 100644
--- a/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
+++ b/dbaccess/source/core/inc/SingleSelectQueryComposer.hxx
@@ -80,8 +80,10 @@ namespace dbaccess
::connectivity::OSQLParser m_aSqlParser;
::connectivity::OSQLParseTreeIterator m_aSqlIterator; // the iterator for the complete statement
::connectivity::OSQLParseTreeIterator m_aAdditiveIterator; // the iterator for the "additive statement" (means without the clauses of the elementary statement)
- std::vector<OPrivateColumns*> m_aColumnsCollection; // used for columns and parameters of old queries
- std::vector<OPrivateTables*> m_aTablesCollection;
+ std::vector<std::unique_ptr<OPrivateColumns>>
+ m_aColumnsCollection; // used for columns and parameters of old queries
+ std::vector<std::unique_ptr<OPrivateTables>>
+ m_aTablesCollection;
std::vector< OUString > m_aElementaryParts; // the filter/groupby/having/order of the elementary statement
@@ -93,8 +95,8 @@ namespace dbaccess
css::uno::Reference< css::uno::XComponentContext> m_aContext;
css::uno::Reference< css::script::XTypeConverter > m_xTypeConverter;
- std::vector<OPrivateColumns*> m_aCurrentColumns;
- OPrivateTables* m_pTables; // currently used tables
+ std::vector<std::unique_ptr<OPrivateColumns>> m_aCurrentColumns;
+ std::unique_ptr<OPrivateTables> m_pTables; // currently used tables
OUString m_aPureSelectSQL; // the pure select statement, without filter/order/groupby/having
OUString m_sDecimalSep;
More information about the Libreoffice-commits
mailing list