From 199a0500996bb3bb8b0349a28e996f269ee747e4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 1 Sep 2016 16:19:14 +0300 Subject: [PATCH] Change deprecated auto_ptr to unique_ptr --- grive/src/main.cc | 11 ++++++----- libgrive/src/base/Drive.cc | 4 ++-- libgrive/src/base/Syncer.hh | 6 +++--- libgrive/src/bfd/SymbolInfo.hh | 2 +- libgrive/src/drive/Syncer1.cc | 12 ++++++------ libgrive/src/drive/Syncer1.hh | 6 +++--- libgrive/src/drive2/Syncer2.cc | 12 ++++++------ libgrive/src/drive2/Syncer2.hh | 6 +++--- libgrive/src/http/CurlAgent.hh | 4 ++-- libgrive/src/http/Download.hh | 2 +- libgrive/src/http/XmlResponse.cc | 2 +- libgrive/src/http/XmlResponse.hh | 9 ++------- libgrive/src/json/JsonParser.hh | 2 +- libgrive/src/json/JsonWriter.hh | 2 +- libgrive/src/json/Val.hh | 2 +- libgrive/src/util/Crypt.hh | 2 +- libgrive/src/util/Function.hh | 2 +- libgrive/src/util/log/CompositeLog.cc | 2 +- libgrive/src/util/log/CompositeLog.hh | 2 +- libgrive/src/util/log/Log.cc | 8 ++++---- libgrive/src/util/log/Log.hh | 2 +- libgrive/src/xml/TreeBuilder.hh | 2 +- libgrive/test/UnitTest.cc | 2 +- 23 files changed, 50 insertions(+), 54 deletions(-) diff --git a/grive/src/main.cc b/grive/src/main.cc index 0894545..eef90d3 100644 --- a/grive/src/main.cc +++ b/grive/src/main.cc @@ -66,12 +66,13 @@ void InitGCrypt() void InitLog( const po::variables_map& vm ) { - std::auto_ptr comp_log(new log::CompositeLog) ; - LogBase* console_log = comp_log->Add( std::auto_ptr( new log::DefaultLog ) ) ; + std::unique_ptr comp_log( new log::CompositeLog ) ; + std::unique_ptr def_log( new log::DefaultLog ); + LogBase* console_log = comp_log->Add( def_log ) ; if ( vm.count( "log" ) ) { - std::auto_ptr file_log(new log::DefaultLog( vm["log"].as() )) ; + std::unique_ptr file_log( new log::DefaultLog( vm["log"].as() ) ) ; 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(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( new http::CurlAgent ); + std::unique_ptr http( new http::CurlAgent ); if ( vm.count( "log-http" ) ) http->SetLog( new http::ResponseLog( vm["log-http"].as(), ".txt" ) ); diff --git a/libgrive/src/base/Drive.cc b/libgrive/src/base/Drive.cc index 5e3eaaf..fd26225 100644 --- a/libgrive/src/base/Drive.cc +++ b/libgrive/src/base/Drive.cc @@ -81,7 +81,7 @@ void Drive::DetectChanges() m_state.FromLocal( m_root ) ; Log( "Reading remote server file list", log::info ) ; - std::auto_ptr feed = m_syncer->GetAll() ; + std::unique_ptr 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 = m_syncer->GetChanges( prev_stamp+1 ) ; + std::unique_ptr feed = m_syncer->GetChanges( prev_stamp+1 ) ; while ( feed->GetNext( m_syncer->Agent() ) ) { std::for_each( diff --git a/libgrive/src/base/Syncer.hh b/libgrive/src/base/Syncer.hh index 29de4b9..237b894 100644 --- a/libgrive/src/base/Syncer.hh +++ b/libgrive/src/base/Syncer.hh @@ -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 GetFolders() = 0; - virtual std::auto_ptr GetAll() = 0; - virtual std::auto_ptr GetChanges( long min_cstamp ) = 0; + virtual std::unique_ptr GetFolders() = 0; + virtual std::unique_ptr GetAll() = 0; + virtual std::unique_ptr GetChanges( long min_cstamp ) = 0; virtual long GetChangeStamp( long min_cstamp ) = 0; protected: diff --git a/libgrive/src/bfd/SymbolInfo.hh b/libgrive/src/bfd/SymbolInfo.hh index bcbc3b1..9284612 100644 --- a/libgrive/src/bfd/SymbolInfo.hh +++ b/libgrive/src/bfd/SymbolInfo.hh @@ -54,7 +54,7 @@ public : private : struct Impl ; - const std::auto_ptr m_impl ; + const std::unique_ptr m_impl ; struct BacktraceInfo ; friend struct BacktraceInfo ; diff --git a/libgrive/src/drive/Syncer1.cc b/libgrive/src/drive/Syncer1.cc index 8eaa9bd..94997e7 100644 --- a/libgrive/src/drive/Syncer1.cc +++ b/libgrive/src/drive/Syncer1.cc @@ -239,14 +239,14 @@ bool Syncer1::Upload( Resource *res, return true ; } -std::auto_ptr Syncer1::GetFolders() +std::unique_ptr Syncer1::GetFolders() { - return std::auto_ptr( new Feed1( feed_base + "/-/folder?max-results=50&showroot=true" ) ); + return std::unique_ptr( new Feed1( feed_base + "/-/folder?max-results=50&showroot=true" ) ); } -std::auto_ptr Syncer1::GetAll() +std::unique_ptr Syncer1::GetAll() { - return std::auto_ptr( new Feed1( feed_base + "?showfolders=true&showroot=true" ) ); + return std::unique_ptr( 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 Syncer1::GetChanges( long min_cstamp ) +std::unique_ptr Syncer1::GetChanges( long min_cstamp ) { - return std::auto_ptr( new Feed1( ChangesFeed( min_cstamp ) ) ); + return std::unique_ptr( new Feed1( ChangesFeed( min_cstamp ) ) ); } long Syncer1::GetChangeStamp( long min_cstamp ) diff --git a/libgrive/src/drive/Syncer1.hh b/libgrive/src/drive/Syncer1.hh index d11c48b..8c6580d 100644 --- a/libgrive/src/drive/Syncer1.hh +++ b/libgrive/src/drive/Syncer1.hh @@ -38,9 +38,9 @@ public : bool EditContent( Resource *res, bool new_rev ); bool Create( Resource *res ); - std::auto_ptr GetFolders(); - std::auto_ptr GetAll(); - std::auto_ptr GetChanges( long min_cstamp ); + std::unique_ptr GetFolders(); + std::unique_ptr GetAll(); + std::unique_ptr GetChanges( long min_cstamp ); long GetChangeStamp( long min_cstamp ); private : diff --git a/libgrive/src/drive2/Syncer2.cc b/libgrive/src/drive2/Syncer2.cc index fda18e4..f7c21d2 100644 --- a/libgrive/src/drive2/Syncer2.cc +++ b/libgrive/src/drive2/Syncer2.cc @@ -211,14 +211,14 @@ bool Syncer2::Upload( Resource *res, bool new_rev ) return true ; } -std::auto_ptr Syncer2::GetFolders() +std::unique_ptr Syncer2::GetFolders() { - return std::auto_ptr( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse+and+mimeType%3d%27" + mime_types::folder + "%27" ) ); + return std::unique_ptr( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse+and+mimeType%3d%27" + mime_types::folder + "%27" ) ); } -std::auto_ptr Syncer2::GetAll() +std::unique_ptr Syncer2::GetAll() { - return std::auto_ptr( new Feed2( feeds::files + "?maxResults=1000&q=trashed%3dfalse" ) ); + return std::unique_ptr( 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 Syncer2::GetChanges( long min_cstamp ) +std::unique_ptr Syncer2::GetChanges( long min_cstamp ) { - return std::auto_ptr( new Feed2( ChangesFeed( min_cstamp ) ) ); + return std::unique_ptr( new Feed2( ChangesFeed( min_cstamp ) ) ); } long Syncer2::GetChangeStamp( long min_cstamp ) diff --git a/libgrive/src/drive2/Syncer2.hh b/libgrive/src/drive2/Syncer2.hh index 8a34757..e62d8b5 100644 --- a/libgrive/src/drive2/Syncer2.hh +++ b/libgrive/src/drive2/Syncer2.hh @@ -39,9 +39,9 @@ public : bool Create( Resource *res ); bool Move( Resource* res, Resource* newParent, std::string newFilename ); - std::auto_ptr GetFolders(); - std::auto_ptr GetAll(); - std::auto_ptr GetChanges( long min_cstamp ); + std::unique_ptr GetFolders(); + std::unique_ptr GetAll(); + std::unique_ptr GetChanges( long min_cstamp ); long GetChangeStamp( long min_cstamp ); private : diff --git a/libgrive/src/http/CurlAgent.hh b/libgrive/src/http/CurlAgent.hh index ac7fe5b..c25fa1a 100644 --- a/libgrive/src/http/CurlAgent.hh +++ b/libgrive/src/http/CurlAgent.hh @@ -72,8 +72,8 @@ private : private : struct Impl ; - std::auto_ptr m_pimpl ; - std::auto_ptr m_log ; + std::unique_ptr m_pimpl ; + std::unique_ptr m_log ; } ; } } // end of namespace diff --git a/libgrive/src/http/Download.hh b/libgrive/src/http/Download.hh index 77cc1ae..fdb7580 100644 --- a/libgrive/src/http/Download.hh +++ b/libgrive/src/http/Download.hh @@ -48,7 +48,7 @@ public : private : File m_file ; - std::auto_ptr m_crypt ; + std::unique_ptr m_crypt ; } ; } } // end of namespace diff --git a/libgrive/src/http/XmlResponse.cc b/libgrive/src/http/XmlResponse.cc index 3df42f9..3c9d6f3 100644 --- a/libgrive/src/http/XmlResponse.cc +++ b/libgrive/src/http/XmlResponse.cc @@ -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 ) diff --git a/libgrive/src/http/XmlResponse.hh b/libgrive/src/http/XmlResponse.hh index b150509..26736e4 100644 --- a/libgrive/src/http/XmlResponse.hh +++ b/libgrive/src/http/XmlResponse.hh @@ -20,15 +20,10 @@ #pragma once #include "util/DataStream.hh" +#include "xml/TreeBuilder.hh" #include -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 m_tb ; + std::unique_ptr m_tb ; } ; } } // end of namespace diff --git a/libgrive/src/json/JsonParser.hh b/libgrive/src/json/JsonParser.hh index ea9e09e..5842699 100644 --- a/libgrive/src/json/JsonParser.hh +++ b/libgrive/src/json/JsonParser.hh @@ -50,7 +50,7 @@ public : private : struct Impl ; - std::auto_ptr m_impl ; + std::unique_ptr m_impl ; } ; } // end of namespace diff --git a/libgrive/src/json/JsonWriter.hh b/libgrive/src/json/JsonWriter.hh index 66f95bf..595f8e0 100644 --- a/libgrive/src/json/JsonWriter.hh +++ b/libgrive/src/json/JsonWriter.hh @@ -51,7 +51,7 @@ private : private : struct Impl ; - std::auto_ptr m_impl ; + std::unique_ptr m_impl ; } ; std::string WriteJson( const Val& val ); diff --git a/libgrive/src/json/Val.hh b/libgrive/src/json/Val.hh index 4c8b9cc..eace6a2 100644 --- a/libgrive/src/json/Val.hh +++ b/libgrive/src/json/Val.hh @@ -130,7 +130,7 @@ private : template struct Impl ; - std::auto_ptr m_base ; + std::unique_ptr m_base ; private : void Select( const Object& obj, const std::string& key, std::vector& result ) const ; diff --git a/libgrive/src/util/Crypt.hh b/libgrive/src/util/Crypt.hh index dcd8dd3..a955809 100644 --- a/libgrive/src/util/Crypt.hh +++ b/libgrive/src/util/Crypt.hh @@ -50,7 +50,7 @@ public : private : struct Impl ; - std::auto_ptr m_impl ; + std::unique_ptr m_impl ; } ; } } // end of namespace gr diff --git a/libgrive/src/util/Function.hh b/libgrive/src/util/Function.hh index 197418f..d5d9114 100644 --- a/libgrive/src/util/Function.hh +++ b/libgrive/src/util/Function.hh @@ -178,7 +178,7 @@ public : private : typedef impl::FuncImpl Impl ; - std::auto_ptr m_pimpl ; + std::unique_ptr m_pimpl ; } ; } // end of namespace diff --git a/libgrive/src/util/log/CompositeLog.cc b/libgrive/src/util/log/CompositeLog.cc index 6c9140a..9de6468 100644 --- a/libgrive/src/util/log/CompositeLog.cc +++ b/libgrive/src/util/log/CompositeLog.cc @@ -39,7 +39,7 @@ CompositeLog::~CompositeLog() std::for_each( m_logs.begin(), m_logs.end(), Destroy() ) ; } -LogBase* CompositeLog::Add( std::auto_ptr log ) +LogBase* CompositeLog::Add( std::unique_ptr& log ) { m_logs.push_back( log.get() ) ; return log.release() ; diff --git a/libgrive/src/util/log/CompositeLog.hh b/libgrive/src/util/log/CompositeLog.hh index 6efe3be..80b41e4 100644 --- a/libgrive/src/util/log/CompositeLog.hh +++ b/libgrive/src/util/log/CompositeLog.hh @@ -32,7 +32,7 @@ public : CompositeLog() ; ~CompositeLog() ; - LogBase* Add( std::auto_ptr log ) ; + LogBase* Add( std::unique_ptr& log ) ; void Log( const log::Fmt& msg, log::Serverity s ) ; diff --git a/libgrive/src/util/log/Log.cc b/libgrive/src/util/log/Log.cc index b93e1b7..07bc086 100644 --- a/libgrive/src/util/log/Log.cc +++ b/libgrive/src/util/log/Log.cc @@ -40,12 +40,12 @@ public : } } ; -LogBase* LogBase::Inst( std::auto_ptr log ) +LogBase* LogBase::Inst( LogBase *log ) { - static std::auto_ptr inst( new MockLog ) ; + static std::unique_ptr inst( new MockLog ) ; - if ( log.get() != 0 ) - inst = log ; + if ( log != 0 ) + inst.reset( log ) ; assert( inst.get() != 0 ) ; return inst.get() ; diff --git a/libgrive/src/util/log/Log.hh b/libgrive/src/util/log/Log.hh index 762320c..25760e5 100644 --- a/libgrive/src/util/log/Log.hh +++ b/libgrive/src/util/log/Log.hh @@ -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 log = std::auto_ptr() ) ; + static LogBase* Inst( LogBase *log = 0 ) ; virtual ~LogBase() ; protected : diff --git a/libgrive/src/xml/TreeBuilder.hh b/libgrive/src/xml/TreeBuilder.hh index fe71a99..2e958e7 100644 --- a/libgrive/src/xml/TreeBuilder.hh +++ b/libgrive/src/xml/TreeBuilder.hh @@ -55,7 +55,7 @@ private : private : struct Impl ; - std::auto_ptr m_impl ; + std::unique_ptr m_impl ; } ; } } // end of namespace diff --git a/libgrive/test/UnitTest.cc b/libgrive/test/UnitTest.cc index c229ae6..7dfbf77 100644 --- a/libgrive/test/UnitTest.cc +++ b/libgrive/test/UnitTest.cc @@ -35,7 +35,7 @@ int main( int argc, char **argv ) { using namespace grut ; - gr::LogBase::Inst( std::auto_ptr(new gr::log::DefaultLog) ) ; + gr::LogBase::Inst( new gr::log::DefaultLog ) ; CppUnit::TextUi::TestRunner runner; runner.addTest( Entry1Test::suite( ) ) ;