Don't use std::auto_ptr<> in the test to avoid warnings

When compiling with g++ or clang in C++11 mode, the use of std::auto_ptr<>
triggers warnings about its deprecation, so replace it with wxScopedPtr<> as
this is simpler than choosing between auto_ptr<> and unique_ptr<>.
This commit is contained in:
Vadim Zeitlin 2016-02-13 13:36:58 +01:00
parent 35f35ea407
commit b08985ac24

View File

@ -20,13 +20,13 @@
#include "archivetest.h" #include "archivetest.h"
#include "wx/dir.h" #include "wx/dir.h"
#include "wx/scopedptr.h"
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
#include <sys/stat.h> #include <sys/stat.h>
using std::string; using std::string;
using std::auto_ptr;
// Check whether member templates can be used // Check whether member templates can be used
@ -550,7 +550,7 @@ TestEntry& ArchiveTestCase<ClassFactoryT>::Add(const char *name,
template <class ClassFactoryT> template <class ClassFactoryT>
void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out) void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out)
{ {
auto_ptr<OutputStreamT> arc(m_factory->NewStream(out)); wxScopedPtr<OutputStreamT> arc(m_factory->NewStream(out));
TestEntries::iterator it; TestEntries::iterator it;
OnCreateArchive(*arc); OnCreateArchive(*arc);
@ -578,7 +578,7 @@ void ArchiveTestCase<ClassFactoryT>::CreateArchive(wxOutputStream& out)
if ((choices & 2) || testEntry.IsText()) { if ((choices & 2) || testEntry.IsText()) {
// try PutNextEntry(EntryT *pEntry) // try PutNextEntry(EntryT *pEntry)
auto_ptr<EntryT> entry(m_factory->NewEntry()); wxScopedPtr<EntryT> entry(m_factory->NewEntry());
entry->SetName(name, wxPATH_UNIX); entry->SetName(name, wxPATH_UNIX);
if (setIsDir) if (setIsDir)
entry->SetIsDir(); entry->SetIsDir();
@ -692,8 +692,8 @@ template <class ClassFactoryT>
void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in, void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
wxOutputStream& out) wxOutputStream& out)
{ {
auto_ptr<InputStreamT> arcIn(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arcIn(m_factory->NewStream(in));
auto_ptr<OutputStreamT> arcOut(m_factory->NewStream(out)); wxScopedPtr<OutputStreamT> arcOut(m_factory->NewStream(out));
EntryT *pEntry; EntryT *pEntry;
const wxString deleteName = wxT("bin/bin1000"); const wxString deleteName = wxT("bin/bin1000");
@ -705,7 +705,7 @@ void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
arcOut->CopyArchiveMetaData(*arcIn); arcOut->CopyArchiveMetaData(*arcIn);
while ((pEntry = arcIn->GetNextEntry()) != NULL) { while ((pEntry = arcIn->GetNextEntry()) != NULL) {
auto_ptr<EntryT> entry(pEntry); wxScopedPtr<EntryT> entry(pEntry);
OnSetNotifier(*entry); OnSetNotifier(*entry);
wxString name = entry->GetName(wxPATH_UNIX); wxString name = entry->GetName(wxPATH_UNIX);
@ -750,7 +750,7 @@ void ArchiveTestCase<ClassFactoryT>::ModifyArchive(wxInputStream& in,
// try adding a new entry // try adding a new entry
TestEntry& testEntry = Add(newName.mb_str(), newData); TestEntry& testEntry = Add(newName.mb_str(), newData);
auto_ptr<EntryT> newentry(m_factory->NewEntry()); wxScopedPtr<EntryT> newentry(m_factory->NewEntry());
newentry->SetName(newName); newentry->SetName(newName);
newentry->SetDateTime(testEntry.GetDateTime()); newentry->SetDateTime(testEntry.GetDateTime());
newentry->SetSize(testEntry.GetLength()); newentry->SetSize(testEntry.GetLength());
@ -773,7 +773,7 @@ void ArchiveTestCase<ClassFactoryT>::ExtractArchive(wxInputStream& in)
typedef std::list<EntryPtr> Entries; typedef std::list<EntryPtr> Entries;
typedef typename Entries::iterator EntryIter; typedef typename Entries::iterator EntryIter;
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
int expectedTotal = m_testEntries.size(); int expectedTotal = m_testEntries.size();
EntryPtr entry; EntryPtr entry;
Entries entries; Entries entries;
@ -982,7 +982,7 @@ void ArchiveTestCase<ClassFactoryT>::TestIterator(wxInputStream& in)
typedef std::list<EntryT*> ArchiveCatalog; typedef std::list<EntryT*> ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter; typedef typename ArchiveCatalog::iterator CatalogIter;
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
size_t count = 0; size_t count = 0;
#ifdef WXARC_MEMBER_TEMPLATES #ifdef WXARC_MEMBER_TEMPLATES
@ -994,7 +994,7 @@ void ArchiveTestCase<ClassFactoryT>::TestIterator(wxInputStream& in)
#endif #endif
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
auto_ptr<EntryT> entry(*it); wxScopedPtr<EntryT> entry(*it);
count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
} }
@ -1011,7 +1011,7 @@ void ArchiveTestCase<ClassFactoryT>::TestPairIterator(wxInputStream& in)
typedef std::map<wxString, EntryT*> ArchiveCatalog; typedef std::map<wxString, EntryT*> ArchiveCatalog;
typedef typename ArchiveCatalog::iterator CatalogIter; typedef typename ArchiveCatalog::iterator CatalogIter;
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
size_t count = 0; size_t count = 0;
#ifdef WXARC_MEMBER_TEMPLATES #ifdef WXARC_MEMBER_TEMPLATES
@ -1023,7 +1023,7 @@ void ArchiveTestCase<ClassFactoryT>::TestPairIterator(wxInputStream& in)
#endif #endif
for (CatalogIter it = cat.begin(); it != cat.end(); ++it) { for (CatalogIter it = cat.begin(); it != cat.end(); ++it) {
auto_ptr<EntryT> entry(it->second); wxScopedPtr<EntryT> entry(it->second);
count += m_testEntries.count(entry->GetName(wxPATH_UNIX)); count += m_testEntries.count(entry->GetName(wxPATH_UNIX));
} }
@ -1040,7 +1040,7 @@ void ArchiveTestCase<ClassFactoryT>::TestSmartIterator(wxInputStream& in)
typedef typename ArchiveCatalog::iterator CatalogIter; typedef typename ArchiveCatalog::iterator CatalogIter;
typedef wxArchiveIterator<InputStreamT, Ptr<EntryT> > Iter; typedef wxArchiveIterator<InputStreamT, Ptr<EntryT> > Iter;
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
#ifdef WXARC_MEMBER_TEMPLATES #ifdef WXARC_MEMBER_TEMPLATES
ArchiveCatalog cat((Iter)*arc, Iter()); ArchiveCatalog cat((Iter)*arc, Iter());
@ -1071,7 +1071,7 @@ void ArchiveTestCase<ClassFactoryT>::TestSmartPairIterator(wxInputStream& in)
typedef wxArchiveIterator<InputStreamT, typedef wxArchiveIterator<InputStreamT,
std::pair<wxString, Ptr<EntryT> > > PairIter; std::pair<wxString, Ptr<EntryT> > > PairIter;
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
#ifdef WXARC_MEMBER_TEMPLATES #ifdef WXARC_MEMBER_TEMPLATES
ArchiveCatalog cat((PairIter)*arc, PairIter()); ArchiveCatalog cat((PairIter)*arc, PairIter());
@ -1099,8 +1099,8 @@ void ArchiveTestCase<ClassFactoryT>::ReadSimultaneous(TestInputStream& in)
// create two archive input streams // create two archive input streams
TestInputStream in2(in); TestInputStream in2(in);
auto_ptr<InputStreamT> arc(m_factory->NewStream(in)); wxScopedPtr<InputStreamT> arc(m_factory->NewStream(in));
auto_ptr<InputStreamT> arc2(m_factory->NewStream(in2)); wxScopedPtr<InputStreamT> arc2(m_factory->NewStream(in2));
// load the catalog // load the catalog
#ifdef WXARC_MEMBER_TEMPLATES #ifdef WXARC_MEMBER_TEMPLATES
@ -1192,7 +1192,7 @@ protected:
void CreateArchive(wxOutputStream& out); void CreateArchive(wxOutputStream& out);
void ExtractArchive(wxInputStream& in); void ExtractArchive(wxInputStream& in);
auto_ptr<wxArchiveClassFactory> m_factory; // factory to make classes wxScopedPtr<wxArchiveClassFactory> m_factory; // factory to make classes
int m_options; // test options int m_options; // test options
}; };
@ -1232,7 +1232,7 @@ void CorruptionTestCase::runTest()
void CorruptionTestCase::CreateArchive(wxOutputStream& out) void CorruptionTestCase::CreateArchive(wxOutputStream& out)
{ {
auto_ptr<wxArchiveOutputStream> arc(m_factory->NewStream(out)); wxScopedPtr<wxArchiveOutputStream> arc(m_factory->NewStream(out));
arc->PutNextDirEntry(wxT("dir")); arc->PutNextDirEntry(wxT("dir"));
arc->PutNextEntry(wxT("file")); arc->PutNextEntry(wxT("file"));
@ -1241,8 +1241,8 @@ void CorruptionTestCase::CreateArchive(wxOutputStream& out)
void CorruptionTestCase::ExtractArchive(wxInputStream& in) void CorruptionTestCase::ExtractArchive(wxInputStream& in)
{ {
auto_ptr<wxArchiveInputStream> arc(m_factory->NewStream(in)); wxScopedPtr<wxArchiveInputStream> arc(m_factory->NewStream(in));
auto_ptr<wxArchiveEntry> entry(arc->GetNextEntry()); wxScopedPtr<wxArchiveEntry> entry(arc->GetNextEntry());
while (entry.get() != NULL) { while (entry.get() != NULL) {
char buf[1024]; char buf[1024];
@ -1250,8 +1250,7 @@ void CorruptionTestCase::ExtractArchive(wxInputStream& in)
while (arc->IsOk()) while (arc->IsOk())
arc->Read(buf, sizeof(buf)); arc->Read(buf, sizeof(buf));
auto_ptr<wxArchiveEntry> next(arc->GetNextEntry()); entry.reset(arc->GetNextEntry());
entry = next;
} }
} }