summaryrefslogtreecommitdiff
path: root/sd/inc/customshowlist.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-30 14:22:23 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-02 08:14:10 +0100
commitb6df5604e2eafbe5857efcf9a5cb6440c47ffd16 (patch)
tree73df60947a299a2af3cc3182aeaea4a159faeaa7 /sd/inc/customshowlist.hxx
parent13449ddc667008bfe0486e5e70110f4556609c3a (diff)
loplugin:useuniqueptr in SdCustomShowList
Change-Id: I604f4cd616ec6eb31198806456a660e7a1e915ca Reviewed-on: https://gerrit.libreoffice.org/62662 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd/inc/customshowlist.hxx')
-rw-r--r--sd/inc/customshowlist.hxx34
1 files changed, 19 insertions, 15 deletions
diff --git a/sd/inc/customshowlist.hxx b/sd/inc/customshowlist.hxx
index 1d30473e5050..5c70f8a63522 100644
--- a/sd/inc/customshowlist.hxx
+++ b/sd/inc/customshowlist.hxx
@@ -20,14 +20,15 @@
#ifndef INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
#define INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
+#include "sddllapi.h"
#include <vector>
class SdCustomShow;
-class SdCustomShowList
+class SD_DLLPUBLIC SdCustomShowList
{
private:
- std::vector<SdCustomShow*> mShows;
+ std::vector<std::unique_ptr<SdCustomShow>> mShows;
sal_uInt16 mnCurPos;
public:
SdCustomShowList()
@@ -35,17 +36,20 @@ public:
{
}
+ SdCustomShowList& operator=( SdCustomShowList const & ) = delete; // MSVC2017 workaround
+ SdCustomShowList( SdCustomShowList const & ) = delete; // MSVC2017 workaround
+
bool empty() const {return mShows.empty();}
size_t size() const {return mShows.size();}
- SdCustomShow* &operator[](size_t i) {return mShows[i];}
+ std::unique_ptr<SdCustomShow>& operator[](size_t i) {return mShows[i];}
- std::vector<SdCustomShow*>::iterator begin() {return mShows.begin();}
+ std::vector<std::unique_ptr<SdCustomShow>>::iterator begin() {return mShows.begin();}
- void erase(std::vector<SdCustomShow*>::iterator it) {mShows.erase(it);}
+ void erase(std::vector<std::unique_ptr<SdCustomShow>>::iterator it);
- void push_back(SdCustomShow* p) {mShows.push_back(p);}
+ void push_back(std::unique_ptr<SdCustomShow> p) {mShows.push_back(std::move(p));}
sal_uInt16 GetCurPos() const { return mnCurPos; }
void Seek(sal_uInt16 nNewPos) { mnCurPos = nNewPos; }
@@ -55,12 +59,12 @@ public:
if( mShows.empty() )
return nullptr;
mnCurPos = 0;
- return mShows[mnCurPos];
+ return mShows[mnCurPos].get();
}
SdCustomShow* Next()
{
++mnCurPos;
- return mnCurPos >= mShows.size() ? nullptr : mShows[mnCurPos];
+ return mnCurPos >= mShows.size() ? nullptr : mShows[mnCurPos].get();
}
void Last()
{
@@ -69,15 +73,15 @@ public:
}
SdCustomShow* GetCurObject()
{
- return mShows.empty() ? nullptr : mShows[mnCurPos];
+ return mShows.empty() ? nullptr : mShows[mnCurPos].get();
}
- SdCustomShow* Remove(SdCustomShow* p)
+ void erase(SdCustomShow* p)
{
- std::vector<SdCustomShow*>::iterator it = std::find(mShows.begin(), mShows.end(), p);
- if( it == mShows.end() )
- return nullptr;
- mShows.erase(it);
- return p;
+ auto it = std::find_if(mShows.begin(), mShows.end(),
+ [&] (std::unique_ptr<SdCustomShow> const &i) { return i.get() == p; });
+ assert( it != mShows.end() );
+ if( it != mShows.end() )
+ mShows.erase(it);
}
};