diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-02 15:17:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-05-04 08:56:56 +0200 |
commit | 869683945a801e86590c165bc6f08832adb7ebb1 (patch) | |
tree | 030ef94da554a2a4a3a3ab8557727afe5e2ecced /connectivity | |
parent | de0a2f6ae7fdfccc17e2b93006a3d308ac15868b (diff) |
loplugin:useuniqueptr in connectivity::OSortIndex
Change-Id: Ie403862020e8fd1eba96d753e33e9fe5b556f949
Reviewed-on: https://gerrit.libreoffice.org/53764
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/commontools/TSortIndex.cxx | 14 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FNoException.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FResultSet.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MResultSet.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/inc/TKeyValue.hxx | 3 | ||||
-rw-r--r-- | connectivity/source/inc/TSortIndex.hxx | 8 | ||||
-rw-r--r-- | connectivity/source/inc/file/FResultSet.hxx | 2 |
7 files changed, 19 insertions, 20 deletions
diff --git a/connectivity/source/commontools/TSortIndex.cxx b/connectivity/source/commontools/TSortIndex.cxx index 63e5037a7279..0f06aa11e625 100644 --- a/connectivity/source/commontools/TSortIndex.cxx +++ b/connectivity/source/commontools/TSortIndex.cxx @@ -103,16 +103,15 @@ OSortIndex::~OSortIndex() { } -void OSortIndex::AddKeyValue(OKeyValue * pKeyValue) +void OSortIndex::AddKeyValue(std::unique_ptr<OKeyValue> pKeyValue) { assert(pKeyValue && "Can not be null here!"); if(m_bFrozen) { - m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),nullptr)); - delete pKeyValue; + m_aKeyValues.push_back({pKeyValue->getValue(),nullptr}); } else - m_aKeyValues.push_back(TIntValuePairVector::value_type(pKeyValue->getValue(),pKeyValue)); + m_aKeyValues.push_back({pKeyValue->getValue(),std::move(pKeyValue)}); } void OSortIndex::Freeze() @@ -125,8 +124,7 @@ void OSortIndex::Freeze() for (auto & keyValue : m_aKeyValues) { - delete keyValue.second; - keyValue.second = nullptr; + keyValue.second.reset(); } m_bFrozen = true; @@ -142,9 +140,9 @@ OKeyValue::~OKeyValue() { } -OKeyValue* OKeyValue::createKeyValue(sal_Int32 _nVal) +std::unique_ptr<OKeyValue> OKeyValue::createKeyValue(sal_Int32 _nVal) { - return new OKeyValue(_nVal); + return std::unique_ptr<OKeyValue>(new OKeyValue(_nVal)); } diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx index bc87c7d0535f..dfb080dc4ee3 100644 --- a/connectivity/source/drivers/file/FNoException.cxx +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -87,11 +87,11 @@ void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,std::vector< OS scanParameter(pParseNode->getChild(i),_rParaNodes); } -OKeyValue* OResultSet::GetOrderbyKeyValue(OValueRefRow const & _rRow) +std::unique_ptr<OKeyValue> OResultSet::GetOrderbyKeyValue(OValueRefRow const & _rRow) { sal_uInt32 nBookmarkValue = std::abs(static_cast<sal_Int32>((_rRow->get())[0]->getValue())); - OKeyValue* pKeyValue = OKeyValue::createKeyValue(nBookmarkValue); + std::unique_ptr<OKeyValue> pKeyValue = OKeyValue::createKeyValue(nBookmarkValue); for (auto const& elem : m_aOrderbyColumnNumber) { diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index a078e095a3fa..f2610657bf07 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -843,8 +843,8 @@ again: { if (m_pSortIndex) { - OKeyValue* pKeyValue = GetOrderbyKeyValue( m_aSelectRow ); - m_pSortIndex->AddKeyValue(pKeyValue); + std::unique_ptr<OKeyValue> pKeyValue = GetOrderbyKeyValue( m_aSelectRow ); + m_pSortIndex->AddKeyValue(std::move(pKeyValue)); } else if (m_pFileSet.is()) { diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx index 912341732d4f..72e8c3aa3d06 100644 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ b/connectivity/source/drivers/mork/MResultSet.cxx @@ -1136,7 +1136,7 @@ void OResultSet::executeQuery() #endif for ( sal_Int32 nRow = 1; nRow <= m_aQueryHelper.getResultCount(); nRow++ ) { - OKeyValue* pKeyValue = OKeyValue::createKeyValue(nRow); + std::unique_ptr<OKeyValue> pKeyValue = OKeyValue::createKeyValue(nRow); std::vector<sal_Int32>::const_iterator aIter = m_aOrderbyColumnNumber.begin(); for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter) @@ -1151,7 +1151,7 @@ void OResultSet::executeQuery() pKeyValue->pushKey(new ORowSetValueDecorator(value)); } - aSortIndex.AddKeyValue( pKeyValue ); + aSortIndex.AddKeyValue( std::move(pKeyValue) ); } m_pKeySet = aSortIndex.CreateKeySet(); diff --git a/connectivity/source/inc/TKeyValue.hxx b/connectivity/source/inc/TKeyValue.hxx index f1911b6c03f4..5837d0275c4a 100644 --- a/connectivity/source/inc/TKeyValue.hxx +++ b/connectivity/source/inc/TKeyValue.hxx @@ -34,8 +34,7 @@ namespace connectivity ~OKeyValue(); - static OKeyValue* createKeyValue(sal_Int32 nVal); - // static OKeyValue* createEmptyKeyValue(); + static std::unique_ptr<OKeyValue> createKeyValue(sal_Int32 nVal); void pushKey(const ORowSetValueDecoratorRef& _aValueRef) { diff --git a/connectivity/source/inc/TSortIndex.hxx b/connectivity/source/inc/TSortIndex.hxx index e03910ff5ac4..8d12cdd11d81 100644 --- a/connectivity/source/inc/TSortIndex.hxx +++ b/connectivity/source/inc/TSortIndex.hxx @@ -47,8 +47,8 @@ namespace connectivity class OOO_DLLPUBLIC_DBTOOLS OSortIndex { public: - typedef std::vector< std::pair<sal_Int32,OKeyValue*> > TIntValuePairVector; - typedef std::vector<OKeyType> TKeyTypeVector; + typedef std::vector<std::pair<sal_Int32, std::unique_ptr<OKeyValue>>> TIntValuePairVector; + typedef std::vector<OKeyType> TKeyTypeVector; private: TIntValuePairVector m_aKeyValues; @@ -60,6 +60,8 @@ namespace connectivity OSortIndex( const std::vector<OKeyType>& _aKeyType, const std::vector<TAscendingOrder>& _aAscending); + OSortIndex(OSortIndex const &) = delete; // MSVC2015 workaround + OSortIndex& operator=(OSortIndex const &) = delete; // MSVC2015 workaround ~OSortIndex(); @@ -69,7 +71,7 @@ namespace connectivity pKeyValue the keyvalue to be appended ATTENTION: when the sortindex is already frozen the parameter will be deleted */ - void AddKeyValue(OKeyValue * pKeyValue); + void AddKeyValue(std::unique_ptr<OKeyValue> pKeyValue); /** Freeze freezes the sortindex so that new values could only be appended by their value diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx index 5ccbbd369101..fae15e2c3bf2 100644 --- a/connectivity/source/inc/file/FResultSet.hxx +++ b/connectivity/source/inc/file/FResultSet.hxx @@ -129,7 +129,7 @@ namespace connectivity bool bEvaluate = true, bool bRetrieveData = true); - OKeyValue* GetOrderbyKeyValue(OValueRefRow const & _rRow); + std::unique_ptr<OKeyValue> GetOrderbyKeyValue(OValueRefRow const & _rRow); bool IsSorted() const { return !m_aOrderbyColumnNumber.empty() && m_aOrderbyColumnNumber[0] >= 0;} // return true when the select statement is "select count(*) from table" |