Skip to content

Commit

Permalink
gcc-6 fixes
Browse files Browse the repository at this point in the history
- New file autoptr.h to switch between "std::unique_ptr" and
  "std::auto_ptr" depending on the GCC version, by new macro AUTO_PTR.
- Removed some "using namespace std" and add some "#define __STL_CONFIG_H"
  before including header files. This will not define "swap" in vdr/tools.h.
- Remove also "using namespace std::tr1".
  • Loading branch information
jasmin-j committed May 20, 2017
1 parent 3aea661 commit eba2ad6
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 40 deletions.
14 changes: 14 additions & 0 deletions autoptr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef VDR_LIVE_AUTOPTR_H
#define VDR_LIVE_AUTOPTR_H

#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)

#if GCC_VERSION > 50000
# define AUTO_PTR std::unique_ptr
#else
# define AUTO_PTR std::auto_ptr
#endif

#endif // VDR_LIVE_AUTOPTR_H
7 changes: 4 additions & 3 deletions epgsearch/services.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The project's page is at http://winni.vdr-developer.org/epgsearch
#include <memory>
#include <set>
#include <vdr/osdbase.h>
#include "../autoptr.h"

// Data structure for service "Epgsearch-search-v1.0"
struct Epgsearch_search_v1_0
Expand Down Expand Up @@ -157,7 +158,7 @@ class cServiceHandler
struct Epgsearch_services_v1_0
{
// in/out
std::auto_ptr<cServiceHandler> handler;
AUTO_PTR<cServiceHandler> handler;
};

// Data structures for service "Epgsearch-services-v1.1"
Expand All @@ -173,7 +174,7 @@ class cServiceHandler_v1_1 : public cServiceHandler
struct Epgsearch_services_v1_1
{
// in/out
std::auto_ptr<cServiceHandler_v1_1> handler;
AUTO_PTR<cServiceHandler_v1_1> handler;
};

// Data structures for service "Epgsearch-services-v1.2"
Expand All @@ -189,7 +190,7 @@ class cServiceHandler_v1_2 : public cServiceHandler_v1_1
struct Epgsearch_services_v1_2
{
// in/out
std::auto_ptr<cServiceHandler_v1_2> handler;
AUTO_PTR<cServiceHandler_v1_2> handler;
};

#endif
3 changes: 2 additions & 1 deletion grab.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "stdext.h"
#include "tasks.h"
#include "autoptr.h"

namespace vdrlive {

Expand All @@ -28,7 +29,7 @@ class GrabImageManager

void PutImage( char* image, int size );

std::auto_ptr< GrabImageTask > m_task;
AUTO_PTR< GrabImageTask > m_task;
GrabImagePtr m_image;
int m_size;
};
Expand Down
5 changes: 3 additions & 2 deletions live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* See the README file for copyright information and how to reach the author.
*/

// To get rid of the swap definition in vdr/tools.h
#define __STL_CONFIG_H

#include <vdr/config.h>
#include <vdr/plugin.h>
#include "i18n.h"
Expand All @@ -18,8 +21,6 @@

namespace vdrlive {

using namespace std;

const char *Plugin::VERSION = LIVEVERSION;
const char *Plugin::DESCRIPTION = LIVESUMMARY;

Expand Down
3 changes: 2 additions & 1 deletion live.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <vdr/config.h>
#include <vdr/plugin.h>
#include "thread.h"
#include "autoptr.h"

namespace vdrlive {

Expand Down Expand Up @@ -33,7 +34,7 @@ class Plugin : public cPlugin {
static std::string m_configDirectory;
static std::string m_resourceDirectory;

std::auto_ptr< ServerThread > m_thread;
AUTO_PTR< ServerThread > m_thread;
};

} // namespace vdrlive
Expand Down
7 changes: 6 additions & 1 deletion pages/edit_timer.ecpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<%pre>

// To get rid of the swap definition in vdr/tools.h
#define __STL_CONFIG_H

#include <memory>
#include <vdr/channels.h>
#include <vdr/config.h>
Expand All @@ -14,6 +18,7 @@
#include "livefeatures.h"
#include "epgsearch.h"
#include "users.h"
#include "autoptr.h"

using namespace std;
using namespace vdrlive;
Expand Down Expand Up @@ -106,7 +111,7 @@ cTimer* timer;
if (message.empty())
edit_timerreferer = request.getHeader("Referer:", "timers.html");

auto_ptr< cTimer > eventTimer;
AUTO_PTR< cTimer > eventTimer;
if ( timer == 0 && !epgid.empty()) {
EpgEvents::DecodeDomId(epgid, channelid, eventid);
if ( channelid.Valid() && eventid != 0 ) {
Expand Down
57 changes: 29 additions & 28 deletions recman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
#define INDEXFILESUFFIX "/index.vdr"
#define LENGTHFILESUFFIX "/length.vdr"

using namespace std::tr1;
using namespace std;
using std::string;
using std::vector;
using std::pair;

namespace vdrlive {

/**
* Implementation of class RecordingsManager:
*/
weak_ptr< RecordingsManager > RecordingsManager::m_recMan;
shared_ptr< RecordingsTree > RecordingsManager::m_recTree;
shared_ptr< RecordingsList > RecordingsManager::m_recList;
shared_ptr< DirectoryList > RecordingsManager::m_recDirs;
std::tr1::weak_ptr< RecordingsManager > RecordingsManager::m_recMan;
std::tr1::shared_ptr< RecordingsTree > RecordingsManager::m_recTree;
std::tr1::shared_ptr< RecordingsList > RecordingsManager::m_recList;
std::tr1::shared_ptr< DirectoryList > RecordingsManager::m_recDirs;
time_t RecordingsManager::m_recordingsState = 0;
string RecordingsManager::m_UpdateFileName;

Expand All @@ -35,7 +36,7 @@ namespace vdrlive {
// use any longer, it will be freed automaticaly, which leads to a
// release of the VDR recordings lock. Upon requesting access to
// the RecordingsManager via LiveRecordingsManger function, first
// the weak ptr is locked (obtaining a shared_ptr from an possible
// the weak ptr is locked (obtaining a std::tr1::shared_ptr from an possible
// existing instance) and if not successfull a new instance is
// created, which again locks the VDR Recordings.
//
Expand All @@ -58,7 +59,7 @@ namespace vdrlive {
{
RecordingsManagerPtr recMan = EnsureValidData();
if (! recMan) {
return RecordingsTreePtr(recMan, shared_ptr< RecordingsTree >());
return RecordingsTreePtr(recMan, std::tr1::shared_ptr< RecordingsTree >());
}
return RecordingsTreePtr(recMan, m_recTree);
}
Expand All @@ -67,25 +68,25 @@ namespace vdrlive {
{
RecordingsManagerPtr recMan = EnsureValidData();
if (! recMan) {
return RecordingsListPtr(recMan, shared_ptr< RecordingsList >());
return RecordingsListPtr(recMan, std::tr1::shared_ptr< RecordingsList >());
}
return RecordingsListPtr(recMan, shared_ptr< RecordingsList >(new RecordingsList(m_recList, ascending)));
return RecordingsListPtr(recMan, std::tr1::shared_ptr< RecordingsList >(new RecordingsList(m_recList, ascending)));
}

RecordingsListPtr RecordingsManager::GetRecordingsList(time_t begin, time_t end, bool ascending) const
{
RecordingsManagerPtr recMan = EnsureValidData();
if (! recMan) {
return RecordingsListPtr(recMan, shared_ptr< RecordingsList >());
return RecordingsListPtr(recMan, std::tr1::shared_ptr< RecordingsList >());
}
return RecordingsListPtr(recMan, shared_ptr< RecordingsList >(new RecordingsList(m_recList, ascending)));
return RecordingsListPtr(recMan, std::tr1::shared_ptr< RecordingsList >(new RecordingsList(m_recList, ascending)));
}

DirectoryListPtr RecordingsManager::GetDirectoryList() const
{
RecordingsManagerPtr recMan = EnsureValidData();
if (!recMan) {
return DirectoryListPtr(recMan, shared_ptr< DirectoryList >());
return DirectoryListPtr(recMan, std::tr1::shared_ptr< DirectoryList >());
}
return DirectoryListPtr(recMan, m_recDirs);
}
Expand Down Expand Up @@ -211,7 +212,7 @@ namespace vdrlive {

if (archiveType==1) {
string dvdFile = filename + "/dvd.vdr";
ifstream dvd(dvdFile.c_str());
std::ifstream dvd(dvdFile.c_str());

if (dvd) {
string archiveDisc;
Expand All @@ -225,7 +226,7 @@ namespace vdrlive {
}
} else if(archiveType==2) {
string hddFile = filename + "/hdd.vdr";
ifstream hdd(hddFile.c_str());
std::ifstream hdd(hddFile.c_str());

if (hdd) {
string archiveDisc;
Expand Down Expand Up @@ -274,7 +275,7 @@ namespace vdrlive {
RecordingsManagerPtr RecordingsManager::EnsureValidData()
{
// Get singleton instance of RecordingsManager. 'this' is not
// an instance of shared_ptr of the singleton
// an instance of std::tr1::shared_ptr of the singleton
// RecordingsManager, so we obtain it in the overall
// recommended way.
RecordingsManagerPtr recMan = LiveRecordingsManager();
Expand All @@ -298,21 +299,21 @@ namespace vdrlive {
m_recDirs.reset();
}
if (stateChanged || !m_recTree) {
m_recTree = shared_ptr< RecordingsTree >(new RecordingsTree(recMan));
m_recTree = std::tr1::shared_ptr< RecordingsTree >(new RecordingsTree(recMan));
}
if (!m_recTree) {
esyslog("[LIVE]: creation of recordings tree failed!");
return RecordingsManagerPtr();
}
if (stateChanged || !m_recList) {
m_recList = shared_ptr< RecordingsList >(new RecordingsList(RecordingsTreePtr(recMan, m_recTree)));
m_recList = std::tr1::shared_ptr< RecordingsList >(new RecordingsList(RecordingsTreePtr(recMan, m_recTree)));
}
if (!m_recList) {
esyslog("[LIVE]: creation of recordings list failed!");
return RecordingsManagerPtr();
}
if (stateChanged || !m_recDirs) {
m_recDirs = shared_ptr< DirectoryList >(new DirectoryList(recMan));
m_recDirs = std::tr1::shared_ptr< DirectoryList >(new DirectoryList(recMan));
}
if (!m_recDirs) {
esyslog("[LIVE]: creation of directory list failed!");
Expand Down Expand Up @@ -546,13 +547,13 @@ namespace vdrlive {
* Implementation of class RecordingsTreePtr:
*/
RecordingsTreePtr::RecordingsTreePtr() :
shared_ptr<RecordingsTree>(),
std::tr1::shared_ptr<RecordingsTree>(),
m_recManPtr()
{
}

RecordingsTreePtr::RecordingsTreePtr(RecordingsManagerPtr recManPtr, std::tr1::shared_ptr< RecordingsTree > recTree) :
shared_ptr<RecordingsTree>(recTree),
std::tr1::shared_ptr<RecordingsTree>(recTree),
m_recManPtr(recManPtr)
{
}
Expand All @@ -572,7 +573,7 @@ namespace vdrlive {
return;
}

stack< RecordingsItemPtr > treeStack;
std::stack< RecordingsItemPtr > treeStack;
treeStack.push(recTree->Root());

while (!treeStack.empty()) {
Expand All @@ -590,7 +591,7 @@ namespace vdrlive {
}
}

RecordingsList::RecordingsList(shared_ptr< RecordingsList > recList, bool ascending) :
RecordingsList::RecordingsList(std::tr1::shared_ptr< RecordingsList > recList, bool ascending) :
m_pRecVec(new RecVecType(recList->size()))
{
if (!m_pRecVec) {
Expand All @@ -604,7 +605,7 @@ namespace vdrlive {
}
}

RecordingsList::RecordingsList(shared_ptr< RecordingsList > recList, time_t begin, time_t end, bool ascending) :
RecordingsList::RecordingsList(std::tr1::shared_ptr< RecordingsList > recList, time_t begin, time_t end, bool ascending) :
m_pRecVec(new RecVecType())
{
if (end > begin) {
Expand Down Expand Up @@ -646,8 +647,8 @@ namespace vdrlive {
/**
* Implementation of class RecordingsList:
*/
RecordingsListPtr::RecordingsListPtr(RecordingsManagerPtr recManPtr, shared_ptr< RecordingsList > recList) :
shared_ptr< RecordingsList >(recList),
RecordingsListPtr::RecordingsListPtr(RecordingsManagerPtr recManPtr, std::tr1::shared_ptr< RecordingsList > recList) :
std::tr1::shared_ptr< RecordingsList >(recList),
m_recManPtr(recManPtr)
{
}
Expand Down Expand Up @@ -716,8 +717,8 @@ namespace vdrlive {
/**
* Implementation of class DirectoryListPtr:
*/
DirectoryListPtr::DirectoryListPtr(RecordingsManagerPtr recManPtr, shared_ptr< DirectoryList > recDirs) :
shared_ptr< DirectoryList >(recDirs),
DirectoryListPtr::DirectoryListPtr(RecordingsManagerPtr recManPtr, std::tr1::shared_ptr< DirectoryList > recDirs) :
std::tr1::shared_ptr< DirectoryList >(recDirs),
m_recManPtr(recManPtr)
{
}
Expand Down
4 changes: 2 additions & 2 deletions tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace vdrlive {

using namespace std;
using namespace std::tr1;
using std::for_each;
using std::tr1::bind;
using namespace std::tr1::placeholders;

const char* NowReplaying()
Expand Down
4 changes: 3 additions & 1 deletion thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <memory>
#include <vdr/thread.h>
#include "autoptr.h"


namespace tnt { class Tntnet; }

Expand All @@ -19,7 +21,7 @@ class ServerThread : public cThread {
virtual void Action();

private:
std::auto_ptr< tnt::Tntnet > m_server;
AUTO_PTR< tnt::Tntnet > m_server;
};

} // namespace vdrlive
Expand Down
3 changes: 2 additions & 1 deletion timers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "timers.h"
#include "tools.h"
#include "i18n.h"
#include "autoptr.h"

static bool operator<( cTimer const& left, cTimer const& right )
{
Expand Down Expand Up @@ -272,7 +273,7 @@ namespace vdrlive {

void TimerManager::DoInsertTimer( TimerPair& timerData )
{
auto_ptr< cTimer > newTimer( new cTimer );
AUTO_PTR< cTimer > newTimer( new cTimer );
if ( !newTimer->Parse( timerData.second.c_str() ) ) {
StoreError( timerData, tr("Error in timer settings") );
return;
Expand Down

0 comments on commit eba2ad6

Please sign in to comment.