Skip to content

Commit

Permalink
[C++11] replace deprecated auto_ptr by unique_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Feb 10, 2015
1 parent e7fe8f0 commit 8999ff7
Show file tree
Hide file tree
Showing 50 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2983,7 +2983,7 @@ bool CApplication::PlayMedia(const CFileItem& item, int iPlaylist)
CGUIDialogCache* dlgCache = new CGUIDialogCache(5000, g_localizeStrings.Get(10214), item.GetLabel());

//is or could be a playlist
auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(item));
unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(item));
bool gotPlayList = (pPlayList.get() && pPlayList->Load(item.GetPath()));

if (dlgCache)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/Autorun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ bool CAutorun::PlayDisc(const std::string& path, bool bypassSettings, bool start
mediaPath = g_mediaManager.GetDiscPath();

const CURL pathToUrl(mediaPath);
auto_ptr<IDirectory> pDir ( CDirectoryFactory::Create( pathToUrl ));
unique_ptr<IDirectory> pDir ( CDirectoryFactory::Create( pathToUrl ));
bool bPlaying = RunDisc(pDir.get(), mediaPath, nAddedToPlaylist, true, bypassSettings, startFromBeginning);

if ( !bPlaying && nAddedToPlaylist > 0 )
Expand Down
4 changes: 2 additions & 2 deletions xbmc/FileItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ void CFileItemList::FilterCueItems()
itemstodelete.push_back(strMediaFile);
// get the additional stuff (year, genre etc.) from the underlying media files tag.
CMusicInfoTag tag;
auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(strMediaFile));
unique_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(strMediaFile));
if (NULL != pLoader.get())
{
// get id3tag
Expand Down Expand Up @@ -2997,7 +2997,7 @@ bool CFileItem::LoadMusicTag()
// load tag from file
CLog::Log(LOGDEBUG, "%s: loading tag information for file: %s", __FUNCTION__, m_strPath.c_str());
CMusicInfoTagLoaderFactory factory;
auto_ptr<IMusicInfoTagLoader> pLoader (factory.CreateLoader(m_strPath));
unique_ptr<IMusicInfoTagLoader> pLoader (factory.CreateLoader(m_strPath));
if (NULL != pLoader.get())
{
if (pLoader->Load(m_strPath, *GetMusicInfoTag()))
Expand Down
4 changes: 2 additions & 2 deletions xbmc/addons/Visualisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ void CVisualisation::OnAudioData(const float* pAudioData, int iAudioDataLength)
return;

// Save our audio data in the buffers
auto_ptr<CAudioBuffer> pBuffer ( new CAudioBuffer(AUDIO_BUFFER_SIZE) );
unique_ptr<CAudioBuffer> pBuffer ( new CAudioBuffer(AUDIO_BUFFER_SIZE) );
pBuffer->Set(pAudioData, iAudioDataLength);
m_vecBuffers.push_back( pBuffer.release() );

if ( (int)m_vecBuffers.size() < m_iNumBuffers) return ;

auto_ptr<CAudioBuffer> ptrAudioBuffer ( m_vecBuffers.front() );
unique_ptr<CAudioBuffer> ptrAudioBuffer ( m_vecBuffers.front() );
m_vecBuffers.pop_front();
// Fourier transform the data if the vis wants it...
if (m_bWantsFreq)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cdrip/CDDARipper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool CCDDARipper::RipCD()
{
CFileItemPtr pItem = vecItems[i];
CMusicInfoTagLoaderFactory factory;
auto_ptr<IMusicInfoTagLoader> pLoader (factory.CreateLoader(pItem->GetPath()));
unique_ptr<IMusicInfoTagLoader> pLoader (factory.CreateLoader(pItem->GetPath()));
if (NULL != pLoader.get())
{
pLoader->Load(pItem->GetPath(), *pItem->GetMusicInfoTag()); // get tag from file
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxVobsub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool CDVDDemuxVobsub::Open(const string& filename, const string& subfilename)
{
m_Filename = filename;

auto_ptr<CDVDSubtitleStream> pStream(new CDVDSubtitleStream());
unique_ptr<CDVDSubtitleStream> pStream(new CDVDSubtitleStream());
if(!pStream->Open(filename))
return false;

Expand Down Expand Up @@ -195,7 +195,7 @@ bool CDVDDemuxVobsub::ParseDelay(SState& state, char* line)

bool CDVDDemuxVobsub::ParseId(SState& state, char* line)
{
auto_ptr<CStream> stream(new CStream(this));
unique_ptr<CStream> stream(new CStream(this));

while(*line == ' ') line++;
strncpy(stream->language, line, 2);
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxVobsub.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class CDVDDemuxVobsub : public CDVDDemux
} STimestamp;

std::string m_Filename;
std::auto_ptr<CDVDInputStream> m_Input;
std::auto_ptr<CDVDDemuxFFmpeg> m_Demuxer;
std::unique_ptr<CDVDInputStream> m_Input;
std::unique_ptr<CDVDDemuxFFmpeg> m_Demuxer;
std::vector<STimestamp> m_Timestamps;
std::vector<STimestamp>::iterator m_Timestamp;
std::vector<CStream*> m_Streams;
Expand Down
14 changes: 7 additions & 7 deletions xbmc/cores/dvdplayer/DVDDemuxers/DVDFactoryDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
{
// audio/x-xbmc-pcm this is the used codec for AirTunes
// (apples audio only streaming)
auto_ptr<CDVDDemuxBXA> demuxer(new CDVDDemuxBXA());
unique_ptr<CDVDDemuxBXA> demuxer(new CDVDDemuxBXA());
if(demuxer->Open(pInputStream))
return demuxer.release();
else
Expand All @@ -64,7 +64,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
{
CLog::Log(LOGDEBUG, "DVDFactoryDemuxer: Stream is probably CD audio. Creating CDDA demuxer.");

auto_ptr<CDVDDemuxCDDA> demuxer(new CDVDDemuxCDDA());
unique_ptr<CDVDDemuxCDDA> demuxer(new CDVDDemuxCDDA());
if (demuxer->Open(pInputStream))
{
return demuxer.release();
Expand All @@ -80,7 +80,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
/* check so we got the meta information as requested in our http header */
if( header->GetValue("icy-metaint").length() > 0 )
{
auto_ptr<CDVDDemuxShoutcast> demuxer(new CDVDDemuxShoutcast());
unique_ptr<CDVDDemuxShoutcast> demuxer(new CDVDDemuxShoutcast());
if(demuxer->Open(pInputStream))
return demuxer.release();
else
Expand All @@ -91,7 +91,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
#ifdef HAS_FILESYSTEM_HTSP
if (pInputStream->IsStreamType(DVDSTREAM_TYPE_HTSP))
{
auto_ptr<CDVDDemuxHTSP> demuxer(new CDVDDemuxHTSP());
unique_ptr<CDVDDemuxHTSP> demuxer(new CDVDDemuxHTSP());
if(demuxer->Open(pInputStream))
return demuxer.release();
else
Expand All @@ -114,7 +114,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
/* Used for MediaPortal PVR addon (uses PVR otherstream for playback of rtsp streams) */
if (pOtherStream->IsStreamType(DVDSTREAM_TYPE_FFMPEG))
{
auto_ptr<CDVDDemuxFFmpeg> demuxer(new CDVDDemuxFFmpeg());
unique_ptr<CDVDDemuxFFmpeg> demuxer(new CDVDDemuxFFmpeg());
if(demuxer->Open(pOtherStream, streaminfo))
return demuxer.release();
else
Expand All @@ -129,7 +129,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
if (g_PVRClients->GetPlayingClient(client) &&
client->HandlesDemuxing())
{
auto_ptr<CDVDDemuxPVRClient> demuxer(new CDVDDemuxPVRClient());
unique_ptr<CDVDDemuxPVRClient> demuxer(new CDVDDemuxPVRClient());
if(demuxer->Open(pInputStream))
return demuxer.release();
else
Expand All @@ -144,7 +144,7 @@ CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(CDVDInputStream* pInputStream, bool
streaminfo = !useFastswitch;
}

auto_ptr<CDVDDemuxFFmpeg> demuxer(new CDVDDemuxFFmpeg());
unique_ptr<CDVDDemuxFFmpeg> demuxer(new CDVDDemuxFFmpeg());
if(demuxer->Open(pInputStream, streaminfo, fileinfo))
return demuxer.release();
else
Expand Down
4 changes: 2 additions & 2 deletions xbmc/cores/dvdplayer/DVDFileInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

bool CDVDFileInfo::GetFileDuration(const std::string &path, int& duration)
{
std::auto_ptr<CDVDInputStream> input;
std::auto_ptr<CDVDDemux> demux;
std::unique_ptr<CDVDInputStream> input;
std::unique_ptr<CDVDDemux> demux;

input.reset(CDVDFactoryInputStream::CreateInputStream(NULL, path, ""));
if (!input.get())
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/dvdplayer/DVDPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3161,7 +3161,7 @@ bool CDVDPlayer::OpenStream(CCurrentStream& current, int iStream, int source, bo
if(!m_pSubtitleDemuxer || m_pSubtitleDemuxer->GetFileName() != st.filename)
{
CLog::Log(LOGNOTICE, "Opening Subtitle file: %s", st.filename.c_str());
auto_ptr<CDVDDemuxVobsub> demux(new CDVDDemuxVobsub());
unique_ptr<CDVDDemuxVobsub> demux(new CDVDDemuxVobsub());
if(!demux->Open(st.filename, st.filename2))
return false;
m_pSubtitleDemuxer = demux.release();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dbwrappers/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ std::string CDatabase::PrepareSQL(std::string strStmt, ...) const
return strResult;
}

std::string CDatabase::GetSingleValue(const std::string &query, std::auto_ptr<Dataset> &ds)
std::string CDatabase::GetSingleValue(const std::string &query, std::unique_ptr<Dataset> &ds)
{
std::string ret;
try
Expand Down
8 changes: 4 additions & 4 deletions xbmc/dbwrappers/Database.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CDatabase
\param ds the dataset to use for the query.
\return the value from the query, empty on failure.
*/
std::string GetSingleValue(const std::string &query, std::auto_ptr<dbiplus::Dataset> &ds);
std::string GetSingleValue(const std::string &query, std::unique_ptr<dbiplus::Dataset> &ds);

/*!
* @brief Delete values from a table.
Expand Down Expand Up @@ -206,9 +206,9 @@ class CDatabase

bool m_sqlite; ///< \brief whether we use sqlite (defaults to true)

std::auto_ptr<dbiplus::Database> m_pDB;
std::auto_ptr<dbiplus::Dataset> m_pDS;
std::auto_ptr<dbiplus::Dataset> m_pDS2;
std::unique_ptr<dbiplus::Database> m_pDB;
std::unique_ptr<dbiplus::Dataset> m_pDS;
std::unique_ptr<dbiplus::Dataset> m_pDS2;

private:
void InitSettings(DatabaseSettings &dbSettings);
Expand Down
8 changes: 4 additions & 4 deletions xbmc/filesystem/Directory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ bool CDirectory::Create(const CURL& url)
try
{
CURL realURL = URIUtils::SubstitutePath(url);
auto_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
if (pDirectory.get())
if(pDirectory->Create(realURL))
return true;
Expand Down Expand Up @@ -320,7 +320,7 @@ bool CDirectory::Exists(const CURL& url, bool bUseCache /* = true */)
if (bPathInCache)
return false;
}
auto_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
if (pDirectory.get())
return pDirectory->Exists(realURL);
}
Expand All @@ -344,7 +344,7 @@ bool CDirectory::Remove(const CURL& url)
try
{
CURL realURL = URIUtils::SubstitutePath(url);
auto_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL));
if (pDirectory.get())
if(pDirectory->Remove(realURL))
{
Expand All @@ -368,7 +368,7 @@ void CDirectory::FilterFileDirectories(CFileItemList &items, const std::string &
CFileItemPtr pItem=items[i];
if (!pItem->m_bIsFolder && pItem->IsFileFolder(EFILEFOLDER_TYPE_ALWAYS))
{
auto_ptr<IFileDirectory> pDirectory(CFileDirectoryFactory::Create(pItem->GetURL(),pItem.get(),mask));
unique_ptr<IFileDirectory> pDirectory(CFileDirectoryFactory::Create(pItem->GetURL(),pItem.get(),mask));
if (pDirectory.get())
pItem->m_bIsFolder = true;
else
Expand Down
20 changes: 10 additions & 10 deletions xbmc/filesystem/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ bool CFile::Open(const CURL& file, const unsigned int flags)
SAFE_DELETE(m_pFile);
if (pRedirectEx && pRedirectEx->m_pNewFileImp)
{
auto_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
unique_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
m_pFile = pRedirectEx->m_pNewFileImp;
delete pRedirectEx;

Expand Down Expand Up @@ -372,7 +372,7 @@ bool CFile::Exists(const CURL& file, bool bUseCache /* = true */)
return false;
}

auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return false;

Expand All @@ -386,8 +386,8 @@ bool CFile::Exists(const CURL& file, bool bUseCache /* = true */)
CLog::Log(LOGDEBUG,"File::Exists - redirecting implementation for %s", file.GetRedacted().c_str());
if (pRedirectEx && pRedirectEx->m_pNewFileImp)
{
auto_ptr<IFile> pImp(pRedirectEx->m_pNewFileImp);
auto_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
unique_ptr<IFile> pImp(pRedirectEx->m_pNewFileImp);
unique_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
delete pRedirectEx;

if (pImp.get())
Expand Down Expand Up @@ -454,7 +454,7 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer)

try
{
auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return -1;
return pFile->Stat(url, buffer);
Expand All @@ -467,8 +467,8 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer)
CLog::Log(LOGDEBUG,"File::Stat - redirecting implementation for %s", file.GetRedacted().c_str());
if (pRedirectEx && pRedirectEx->m_pNewFileImp)
{
auto_ptr<IFile> pImp(pRedirectEx->m_pNewFileImp);
auto_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
unique_ptr<IFile> pImp(pRedirectEx->m_pNewFileImp);
unique_ptr<CURL> pNewUrl(pRedirectEx->m_pNewUrl);
delete pRedirectEx;

if (pNewUrl.get())
Expand Down Expand Up @@ -792,7 +792,7 @@ bool CFile::Delete(const CURL& file)
{
CURL url(URIUtils::SubstitutePath(file));

auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return false;

Expand Down Expand Up @@ -826,7 +826,7 @@ bool CFile::Rename(const CURL& file, const CURL& newFile)
CURL url(URIUtils::SubstitutePath(file));
CURL urlnew(URIUtils::SubstitutePath(newFile));

auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return false;

Expand Down Expand Up @@ -858,7 +858,7 @@ bool CFile::SetHidden(const CURL& file, bool hidden)
{
CURL url(URIUtils::SubstitutePath(file));

auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
if (!pFile.get())
return false;

Expand Down
14 changes: 7 additions & 7 deletions xbmc/filesystem/MusicDatabaseDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool CMusicDatabaseDirectory::GetDirectory(const CURL& url, CFileItemList &items
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(url);
items.SetPath(path);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));

if (!pNode.get())
return false;
Expand All @@ -71,7 +71,7 @@ bool CMusicDatabaseDirectory::GetDirectory(const CURL& url, CFileItemList &items
NODE_TYPE CMusicDatabaseDirectory::GetDirectoryChildType(const std::string& strPath)
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));

if (!pNode.get())
return NODE_TYPE_NONE;
Expand All @@ -82,7 +82,7 @@ NODE_TYPE CMusicDatabaseDirectory::GetDirectoryChildType(const std::string& strP
NODE_TYPE CMusicDatabaseDirectory::GetDirectoryType(const std::string& strPath)
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));

if (!pNode.get())
return NODE_TYPE_NONE;
Expand All @@ -93,7 +93,7 @@ NODE_TYPE CMusicDatabaseDirectory::GetDirectoryType(const std::string& strPath)
NODE_TYPE CMusicDatabaseDirectory::GetDirectoryParentType(const std::string& strPath)
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));

if (!pNode.get())
return NODE_TYPE_NONE;
Expand Down Expand Up @@ -143,7 +143,7 @@ bool CMusicDatabaseDirectory::GetLabel(const std::string& strDirectory, std::str
strLabel = "";

std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strDirectory);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
if (!pNode.get())
return false;

Expand Down Expand Up @@ -249,7 +249,7 @@ bool CMusicDatabaseDirectory::ContainsSongs(const std::string &path)
bool CMusicDatabaseDirectory::Exists(const CURL& url)
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(url);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));

if (!pNode.get())
return false;
Expand All @@ -263,7 +263,7 @@ bool CMusicDatabaseDirectory::Exists(const CURL& url)
bool CMusicDatabaseDirectory::CanCache(const std::string& strPath)
{
std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strPath);
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path));
if (!pNode.get())
return false;
return pNode->CanCache();
Expand Down
4 changes: 2 additions & 2 deletions xbmc/filesystem/MusicDatabaseDirectory/DirectoryNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ CDirectoryNode* CDirectoryNode::ParseURL(const std::string& strPath)
// returns the database ids of the path,
void CDirectoryNode::GetDatabaseInfo(const std::string& strPath, CQueryParams& params)
{
auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(strPath));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(strPath));

if (!pNode.get())
return;
Expand Down Expand Up @@ -260,7 +260,7 @@ bool CDirectoryNode::GetChilds(CFileItemList& items)
if (CanCache() && items.Load())
return true;

auto_ptr<CDirectoryNode> pNode(CDirectoryNode::CreateNode(GetChildType(), "", this));
unique_ptr<CDirectoryNode> pNode(CDirectoryNode::CreateNode(GetChildType(), "", this));

bool bSuccess=false;
if (pNode.get())
Expand Down
Loading

0 comments on commit 8999ff7

Please sign in to comment.