Change deprecated auto_ptr to unique_ptr

pull/90/merge
Vitaliy Filippov 2016-09-01 16:19:14 +03:00
parent 195e5091c7
commit 199a050099
23 changed files with 50 additions and 54 deletions

View File

@ -66,12 +66,13 @@ void InitGCrypt()
void InitLog( const po::variables_map& vm )
{
std::auto_ptr<log::CompositeLog> comp_log(new log::CompositeLog) ;
LogBase* console_log = comp_log->Add( std::auto_ptr<LogBase>( new log::DefaultLog ) ) ;
std::unique_ptr<log::CompositeLog> comp_log( new log::CompositeLog ) ;
std::unique_ptr<LogBase> def_log( new log::DefaultLog );
LogBase* console_log = comp_log->Add( def_log ) ;
if ( vm.count( "log" ) )
{
std::auto_ptr<LogBase> file_log(new log::DefaultLog( vm["log"].as<std::string>() )) ;
std::unique_ptr<LogBase> file_log( new log::DefaultLog( vm["log"].as<std::string>() ) ) ;
file_log->Enable( log::debug ) ;
file_log->Enable( log::verbose ) ;
file_log->Enable( log::info ) ;
@ -96,7 +97,7 @@ void InitLog( const po::variables_map& vm )
console_log->Enable( log::verbose ) ;
console_log->Enable( log::debug ) ;
}
LogBase::Inst( std::auto_ptr<LogBase>(comp_log.release()) ) ;
LogBase::Inst( comp_log.release() ) ;
}
int Main( int argc, char **argv )
@ -151,7 +152,7 @@ int Main( int argc, char **argv )
Log( "config file name %1%", config.Filename(), log::verbose );
std::auto_ptr<http::Agent> http( new http::CurlAgent );
std::unique_ptr<http::Agent> http( new http::CurlAgent );
if ( vm.count( "log-http" ) )
http->SetLog( new http::ResponseLog( vm["log-http"].as<std::string>(), ".txt" ) );

View File

@ -81,7 +81,7 @@ void Drive::DetectChanges()
m_state.FromLocal( m_root ) ;
Log( "Reading remote server file list", log::info ) ;
std::auto_ptr<Feed> feed = m_syncer->GetAll() ;
std::unique_ptr<Feed> feed = m_syncer->GetAll() ;
while ( feed->GetNext( m_syncer->Agent() ) )
{
@ -101,7 +101,7 @@ void Drive::ReadChanges()
{
Trace( "previous change stamp is %1%", prev_stamp ) ;
Log( "Detecting changes from last sync", log::info ) ;
std::auto_ptr<Feed> feed = m_syncer->GetChanges( prev_stamp+1 ) ;
std::unique_ptr<Feed> feed = m_syncer->GetChanges( prev_stamp+1 ) ;
while ( feed->GetNext( m_syncer->Agent() ) )
{
std::for_each(

View File

@ -55,9 +55,9 @@ public :
virtual bool Create( Resource *res ) = 0;
virtual bool Move( Resource* res, Resource* newParent, std::string newFilename ) = 0;
virtual std::auto_ptr<Feed> GetFolders() = 0;
virtual std::auto_ptr<Feed> GetAll() = 0;
virtual std::auto_ptr<Feed> GetChanges( long min_cstamp ) = 0;
virtual std::unique_ptr<Feed> GetFolders() = 0;
virtual std::unique_ptr<Feed> GetAll() = 0;
virtual std::unique_ptr<Feed> GetChanges( long min_cstamp ) = 0;
virtual long GetChangeStamp( long min_cstamp ) = 0;
protected:

View File

@ -54,7 +54,7 @@ public :
private :
struct Impl ;
const std::auto_ptr<Impl> m_impl ;
const std::unique_ptr<Impl> m_impl ;
struct BacktraceInfo ;
friend struct BacktraceInfo ;

View File

@ -239,14 +239,14 @@ bool Syncer1::Upload( Resource *res,
return true ;
}
std::auto_ptr<Feed> Syncer1::GetFolders()
std::unique_ptr<Feed> Syncer1::GetFolders()
{
return std::auto_ptr<Feed>( new Feed1( feed_base + "/-/folder?max-results=50&showroot=true" ) );
return std::unique_ptr<Feed>( new Feed1( feed_base + "/-/folder?max-results=50&showroot=true" ) );
}
std::auto_ptr<Feed> Syncer1::GetAll()
std::unique_ptr<Feed> Syncer1::GetAll()
{
return std::auto_ptr<Feed>( new Feed1( feed_base + "?showfolders=true&showroot=true" ) );
return std::unique_ptr<Feed>( new Feed1( feed_base + "?showfolders=true&showroot=true" ) );
}
std::string ChangesFeed( int changestamp )
@ -255,9 +255,9 @@ std::string ChangesFeed( int changestamp )
return changestamp > 0 ? ( feed % changestamp ).str() : feed_changes ;
}
std::auto_ptr<Feed> Syncer1::GetChanges( long min_cstamp )
std::unique_ptr<Feed> Syncer1::GetChanges( long min_cstamp )
{
return std::auto_ptr<Feed>( new Feed1( ChangesFeed( min_cstamp ) ) );
return std::unique_ptr<Feed>( new Feed1( ChangesFeed( min_cstamp ) ) );
}
long Syncer1::GetChangeStamp( long min_cstamp )

View File

@ -38,9 +38,9 @@ public :
bool EditContent( Resource *res, bool new_rev );
bool Create( Resource *res );
std::auto_ptr<Feed> GetFolders();
std::auto_ptr<Feed> GetAll();
std::auto_ptr<Feed> GetChanges( long min_cstamp );
std::unique_ptr<Feed> GetFolders();
std::unique_ptr<Feed> GetAll();
std::unique_ptr<Feed> GetChanges( long min_cstamp );
long GetChangeStamp( long min_cstamp );
private :

View File

@ -211,14 +211,14 @@ bool Syncer2::Upload( Resource *res, bool new_rev )
return true ;
}
std::auto_ptr<Feed> Syncer2::GetFolders()
std::unique_ptr<Feed> Syncer2::GetFolders()
{
return std::auto_ptr<Feed>( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse+and+mimeType%3d%27" + mime_types::folder + "%27" ) );
return std::unique_ptr<Feed>( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse+and+mimeType%3d%27" + mime_types::folder + "%27" ) );
}
std::auto_ptr<Feed> Syncer2::GetAll()
std::unique_ptr<Feed> Syncer2::GetAll()
{
return std::auto_ptr<Feed>( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse" ) );
return std::unique_ptr<Feed>( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse" ) );
}
std::string ChangesFeed( long changestamp, int maxResults = 1000 )
@ -227,9 +227,9 @@ std::string ChangesFeed( long changestamp, int maxResults = 1000 )
return ( changestamp > 0 ? feed % maxResults % changestamp : feed % maxResults ).str() ;
}
std::auto_ptr<Feed> Syncer2::GetChanges( long min_cstamp )
std::unique_ptr<Feed> Syncer2::GetChanges( long min_cstamp )
{
return std::auto_ptr<Feed>( new Feed2( ChangesFeed( min_cstamp ) ) );
return std::unique_ptr<Feed>( new Feed2( ChangesFeed( min_cstamp ) ) );
}
long Syncer2::GetChangeStamp( long min_cstamp )

View File

@ -39,9 +39,9 @@ public :
bool Create( Resource *res );
bool Move( Resource* res, Resource* newParent, std::string newFilename );
std::auto_ptr<Feed> GetFolders();
std::auto_ptr<Feed> GetAll();
std::auto_ptr<Feed> GetChanges( long min_cstamp );
std::unique_ptr<Feed> GetFolders();
std::unique_ptr<Feed> GetAll();
std::unique_ptr<Feed> GetChanges( long min_cstamp );
long GetChangeStamp( long min_cstamp );
private :

View File

@ -72,8 +72,8 @@ private :
private :
struct Impl ;
std::auto_ptr<Impl> m_pimpl ;
std::auto_ptr<ResponseLog> m_log ;
std::unique_ptr<Impl> m_pimpl ;
std::unique_ptr<ResponseLog> m_log ;
} ;
} } // end of namespace

View File

@ -48,7 +48,7 @@ public :
private :
File m_file ;
std::auto_ptr<crypt::MD5> m_crypt ;
std::unique_ptr<crypt::MD5> m_crypt ;
} ;
} } // end of namespace

View File

@ -30,7 +30,7 @@ XmlResponse::XmlResponse() : m_tb( new xml::TreeBuilder )
void XmlResponse::Clear()
{
m_tb.reset(new xml::TreeBuilder);
m_tb.reset(new xml::TreeBuilder);
}
std::size_t XmlResponse::Write( const char *data, std::size_t count )

View File

@ -20,15 +20,10 @@
#pragma once
#include "util/DataStream.hh"
#include "xml/TreeBuilder.hh"
#include <memory>
namespace gr { namespace xml
{
class Node ;
class TreeBuilder ;
} }
namespace gr { namespace http {
class XmlResponse : public DataStream
@ -44,7 +39,7 @@ public :
xml::Node Response() const ;
private :
std::auto_ptr<xml::TreeBuilder> m_tb ;
std::unique_ptr<xml::TreeBuilder> m_tb ;
} ;
} } // end of namespace

View File

@ -50,7 +50,7 @@ public :
private :
struct Impl ;
std::auto_ptr<Impl> m_impl ;
std::unique_ptr<Impl> m_impl ;
} ;
} // end of namespace

View File

@ -51,7 +51,7 @@ private :
private :
struct Impl ;
std::auto_ptr<Impl> m_impl ;
std::unique_ptr<Impl> m_impl ;
} ;
std::string WriteJson( const Val& val );

View File

@ -130,7 +130,7 @@ private :
template <typename T>
struct Impl ;
std::auto_ptr<Base> m_base ;
std::unique_ptr<Base> m_base ;
private :
void Select( const Object& obj, const std::string& key, std::vector<Val>& result ) const ;

View File

@ -50,7 +50,7 @@ public :
private :
struct Impl ;
std::auto_ptr<Impl> m_impl ;
std::unique_ptr<Impl> m_impl ;
} ;
} } // end of namespace gr

View File

@ -178,7 +178,7 @@ public :
private :
typedef impl::FuncImpl<Type> Impl ;
std::auto_ptr<Impl> m_pimpl ;
std::unique_ptr<Impl> m_pimpl ;
} ;
} // end of namespace

View File

@ -39,7 +39,7 @@ CompositeLog::~CompositeLog()
std::for_each( m_logs.begin(), m_logs.end(), Destroy() ) ;
}
LogBase* CompositeLog::Add( std::auto_ptr<LogBase> log )
LogBase* CompositeLog::Add( std::unique_ptr<LogBase>& log )
{
m_logs.push_back( log.get() ) ;
return log.release() ;

View File

@ -32,7 +32,7 @@ public :
CompositeLog() ;
~CompositeLog() ;
LogBase* Add( std::auto_ptr<LogBase> log ) ;
LogBase* Add( std::unique_ptr<LogBase>& log ) ;
void Log( const log::Fmt& msg, log::Serverity s ) ;

View File

@ -40,12 +40,12 @@ public :
}
} ;
LogBase* LogBase::Inst( std::auto_ptr<LogBase> log )
LogBase* LogBase::Inst( LogBase *log )
{
static std::auto_ptr<LogBase> inst( new MockLog ) ;
static std::unique_ptr<LogBase> inst( new MockLog ) ;
if ( log.get() != 0 )
inst = log ;
if ( log != 0 )
inst.reset( log ) ;
assert( inst.get() != 0 ) ;
return inst.get() ;

View File

@ -65,7 +65,7 @@ public :
virtual bool Enable( log::Serverity s, bool enable = true ) = 0 ;
virtual bool IsEnabled( log::Serverity s ) const = 0 ;
static LogBase* Inst( std::auto_ptr<LogBase> log = std::auto_ptr<LogBase>() ) ;
static LogBase* Inst( LogBase *log = 0 ) ;
virtual ~LogBase() ;
protected :

View File

@ -55,7 +55,7 @@ private :
private :
struct Impl ;
std::auto_ptr<Impl> m_impl ;
std::unique_ptr<Impl> m_impl ;
} ;
} } // end of namespace

View File

@ -35,7 +35,7 @@ int main( int argc, char **argv )
{
using namespace grut ;
gr::LogBase::Inst( std::auto_ptr<gr::LogBase>(new gr::log::DefaultLog) ) ;
gr::LogBase::Inst( new gr::log::DefaultLog ) ;
CppUnit::TextUi::TestRunner runner;
runner.addTest( Entry1Test::suite( ) ) ;