Skip to content

Commit

Permalink
Don't include all of the standard namespace. (libmythtv/channelscan)
Browse files Browse the repository at this point in the history
Including all of the standard namespace is considered bad practice. It
defeats the purpose of namespaces, and pollutes the global name table.
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent fd24102 commit 4055915
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 80 deletions.
92 changes: 45 additions & 47 deletions mythtv/libs/libmythtv/channelscan/channelimporter.cpp
Expand Up @@ -15,8 +15,6 @@
#include <QTextStream>
#include <QElapsedTimer>

using namespace std;

// MythTV headers
#include "channelimporter.h"
#include "mythdialogbox.h"
Expand Down Expand Up @@ -65,7 +63,7 @@ void ChannelImporter::Process(const ScanDTVTransportList &_transports,
}
else
{
cout << (ChannelUtil::GetChannelCount() ?
std::cout << (ChannelUtil::GetChannelCount() ?
"No new channels to process" :
"No channels to process..");
}
Expand Down Expand Up @@ -230,7 +228,7 @@ QString ChannelImporter::toString(ChannelType type)
uint ChannelImporter::DeleteChannels(
ScanDTVTransportList &transports)
{
vector<uint> off_air_list;
std::vector<uint> off_air_list;
QMap<uint,bool> deleted;
ScanDTVTransportList off_air_transports;

Expand Down Expand Up @@ -258,9 +256,9 @@ uint ChannelImporter::DeleteChannels(
return 0;

// List of off-air channels (in database but not in the scan)
cout << endl << "Off-air channels (" << SimpleCountChannels(off_air_transports) << "):" << endl;
std::cout << std::endl << "Off-air channels (" << SimpleCountChannels(off_air_transports) << "):" << std::endl;
ChannelImporterBasicStats infoA = CollectStats(off_air_transports);
cout << FormatChannels(off_air_transports, &infoA).toLatin1().constData() << endl;
std::cout << FormatChannels(off_air_transports, &infoA).toLatin1().constData() << std::endl;

// Ask user whether to delete all or some of these stale channels
// if some is selected ask about each individually
Expand Down Expand Up @@ -909,7 +907,7 @@ void ChannelImporter::MergeSameFrequency(ScanDTVTransportList &transports)

uint freq_mult = (is_dvbs) ? 1 : 1000;

vector<bool> ignore;
std::vector<bool> ignore;
ignore.resize(transports.size());
for (size_t i = 0; i < transports.size(); ++i)
{
Expand Down Expand Up @@ -965,7 +963,7 @@ void ChannelImporter::RemoveDuplicates(ScanDTVTransportList &transports, ScanDTV
QString("Number of transports:%1").arg(transports.size()));

ScanDTVTransportList no_dups;
vector<bool> ignore;
std::vector<bool> ignore;
ignore.resize(transports.size());
for (size_t i = 0; i < transports.size(); ++i)
{
Expand Down Expand Up @@ -1368,7 +1366,7 @@ ChannelImporterUniquenessStats ChannelImporter::CollectUniquenessStats(
(chan.m_atscMinorChannel)] == 1) ? 1 : 0;
stats.m_uniqueAtscMin +=
(info.m_atscMinCnt[(chan.m_atscMinorChannel)] == 1) ? 1 : 0;
stats.m_maxAtscMajCnt = max(
stats.m_maxAtscMajCnt = std::max(
stats.m_maxAtscMajCnt,
info.m_atscMajCnt[chan.m_atscMajorChannel]);
}
Expand Down Expand Up @@ -1790,21 +1788,21 @@ ChannelImporter::QueryUserDelete(const QString &msg)
}
else if (m_isInteractive)
{
cout << msg.toLatin1().constData()
<< endl
std::cout << msg.toLatin1().constData()
<< std::endl
<< tr("Do you want to:").toLatin1().constData()
<< endl
<< std::endl
<< tr("1. Delete All").toLatin1().constData()
<< endl
<< std::endl
<< tr("2. Set all invisible").toLatin1().constData()
<< endl
<< std::endl
// cout << "3. Handle manually" << endl;
<< tr("4. Ignore All").toLatin1().constData()
<< endl;
<< std::endl;
while (true)
{
string ret;
cin >> ret;
std::string ret;
std::cin >> ret;
bool ok = false;
uint val = QString(ret.c_str()).toUInt(&ok);
if (ok && (val == 1 || val == 2 || val == 4))
Expand All @@ -1817,8 +1815,8 @@ ChannelImporter::QueryUserDelete(const QString &msg)
}

//cout << "Please enter either 1, 2, 3 or 4:" << endl;
cout << tr("Please enter either 1, 2 or 4:")
.toLatin1().constData() << endl;//
std::cout << tr("Please enter either 1, 2 or 4:")
.toLatin1().constData() << std::endl;
}
}

Expand Down Expand Up @@ -1862,20 +1860,20 @@ ChannelImporter::QueryUserInsert(const QString &msg)
}
else if (m_isInteractive)
{
cout << msg.toLatin1().constData()
<< endl
std::cout << msg.toLatin1().constData()
<< std::endl
<< tr("Do you want to:").toLatin1().constData()
<< endl
<< std::endl
<< tr("1. Insert All").toLatin1().constData()
<< endl
<< std::endl
<< tr("2. Insert Manually").toLatin1().constData()
<< endl
<< std::endl
<< tr("3. Ignore All").toLatin1().constData()
<< endl;
<< std::endl;
while (true)
{
string ret;
cin >> ret;
std::string ret;
std::cin >> ret;
bool ok = false;
uint val = QString(ret.c_str()).toUInt(&ok);
if (ok && (1 <= val) && (val <= 3))
Expand All @@ -1886,8 +1884,8 @@ ChannelImporter::QueryUserInsert(const QString &msg)
break;
}

cout << tr("Please enter either 1, 2, or 3:")
.toLatin1().constData() << endl;
std::cout << tr("Please enter either 1, 2, or 3:")
.toLatin1().constData() << std::endl;
}
}

Expand Down Expand Up @@ -1930,20 +1928,20 @@ ChannelImporter::QueryUserUpdate(const QString &msg)
}
else if (m_isInteractive)
{
cout << msg.toLatin1().constData()
<< endl
std::cout << msg.toLatin1().constData()
<< std::endl
<< tr("Do you want to:").toLatin1().constData()
<< endl
<< std::endl
<< tr("1. Update All").toLatin1().constData()
<< endl
<< std::endl
<< tr("2. Update Manually").toLatin1().constData()
<< endl
<< std::endl
<< tr("3. Ignore All").toLatin1().constData()
<< endl;
<< std::endl;
while (true)
{
string ret;
cin >> ret;
std::string ret;
std::cin >> ret;
bool ok = false;
uint val = QString(ret.c_str()).toUInt(&ok);
if (ok && (1 <= val) && (val <= 3))
Expand All @@ -1954,8 +1952,8 @@ ChannelImporter::QueryUserUpdate(const QString &msg)
break;
}

cout << tr("Please enter either 1, 2, or 3:")
.toLatin1().constData() << endl;
std::cout << tr("Please enter either 1, 2, or 3:")
.toLatin1().constData() << std::endl;
}
}

Expand Down Expand Up @@ -2140,7 +2138,7 @@ OkCancelType ChannelImporter::QueryUserResolve(
}
else if (m_isInteractive)
{
cout << msg.toLatin1().constData() << endl;
std::cout << msg.toLatin1().constData() << std::endl;

QString cancelStr = QCoreApplication::translate("(Common)",
"Cancel").toLower();
Expand All @@ -2152,9 +2150,9 @@ OkCancelType ChannelImporter::QueryUserResolve(

while (true)
{
cout << msg2.toLatin1().constData() << endl;
string sret;
cin >> sret;
std::cout << msg2.toLatin1().constData() << std::endl;
std::string sret;
std::cin >> sret;
QString val = QString(sret.c_str());
if (val.toLower() == cancelStr)
{
Expand Down Expand Up @@ -2218,7 +2216,7 @@ OkCancelType ChannelImporter::QueryUserInsert(
}
else if (m_isInteractive)
{
cout << msg.toLatin1().constData() << endl;
std::cout << msg.toLatin1().constData() << std::endl;

QString cancelStr = QCoreApplication::translate("(Common)", "Cancel").toLower();
QString cancelAllStr = QCoreApplication::translate("(Common)", "Cancel All").toLower();
Expand All @@ -2230,9 +2228,9 @@ OkCancelType ChannelImporter::QueryUserInsert(

while (true)
{
cout << msg2.toLatin1().constData() << endl;
string sret;
cin >> sret;
std::cout << msg2.toLatin1().constData() << std::endl;
std::string sret;
std::cin >> sret;
QString val = QString(sret.c_str());
if (val.toLower() == cancelStr)
{
Expand Down
6 changes: 2 additions & 4 deletions mythtv/libs/libmythtv/channelscan/channelscan_sm.cpp
Expand Up @@ -34,8 +34,6 @@
#include <algorithm>
#include <utility>

using namespace std;

// Qt includes
#include <QMutexLocker>
#include <QObject>
Expand Down Expand Up @@ -327,7 +325,7 @@ bool ChannelScanSM::ScanExistingTransports(uint sourceid, bool follow_nit)
m_scanTransports.clear();
m_nextIt = m_scanTransports.end();

vector<uint> multiplexes = SourceUtil::GetMplexIDs(sourceid);
std::vector<uint> multiplexes = SourceUtil::GetMplexIDs(sourceid);

if (multiplexes.empty())
{
Expand Down Expand Up @@ -718,7 +716,7 @@ DTVTunerType ChannelScanSM::GuessDTVTunerType(DTVTunerType type) const
if (!chan)
return type;

vector<DTVTunerType> tts = chan->GetTunerTypes();
std::vector<DTVTunerType> tts = chan->GetTunerTypes();

for (auto & tt : tts)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelscan/channelscan_sm.h
Expand Up @@ -60,7 +60,7 @@ class SignalMonitor;
class DTVSignalMonitor;
class DVBSignalMonitor;

using pmt_vec_t = vector<const ProgramMapTable*>;
using pmt_vec_t = std::vector<const ProgramMapTable*>;
using pmt_map_t = QMap<uint, pmt_vec_t>;
class ScannedChannelInfo;
using ChannelListItem = QPair<transport_scan_items_it_t, ScannedChannelInfo*>;
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/channelscan/channelscanner.cpp
Expand Up @@ -28,7 +28,6 @@
*/

#include <algorithm>
using namespace std;

#include "analogsignalmonitor.h"
#include "iptvchannelfetcher.h"
Expand Down Expand Up @@ -446,12 +445,12 @@ void ChannelScanner::PreScanCommon(
}

// ensure a minimal signal timeout of 1 second
signal_timeout = max(signal_timeout, 1000U);
signal_timeout = std::max(signal_timeout, 1000U);

// Make sure that channel_timeout is at least 7 seconds to catch
// at least one SDT section. kDVBTableTimeout in ChannelScanSM
// ensures that we catch the NIT then.
channel_timeout = max(channel_timeout, static_cast<int>(need_nit) * 7 * 1000U);
channel_timeout = std::max(channel_timeout, static_cast<int>(need_nit) * 7 * 1000U);
}

#ifdef USING_DVB
Expand Down
16 changes: 7 additions & 9 deletions mythtv/libs/libmythtv/channelscan/channelscanner_cli.cpp
Expand Up @@ -27,8 +27,6 @@
#include <QCoreApplication>
#include <iostream>

using namespace std;

// MythTv headers
#include "channelscanner_cli.h"
#include "channelscan_sm.h"
Expand All @@ -42,12 +40,12 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)
(scanEvent->type() == ScannerEvent::ScanShutdown) ||
(scanEvent->type() == ScannerEvent::ScanErrored))
{
cout<<endl;
std::cout<<std::endl;

if (scanEvent->type() == ScannerEvent::ScanShutdown)
cerr<<"HandleEvent(void) -- scan shutdown"<<endl;
std::cerr<<"HandleEvent(void) -- scan shutdown"<<std::endl;
else
cerr<<"HandleEvent(void) -- scan complete"<<endl;
std::cerr<<"HandleEvent(void) -- scan complete"<<std::endl;

ScanDTVTransportList transports;
if (m_sigmonScanner)
Expand Down Expand Up @@ -115,16 +113,16 @@ void ChannelScannerCLI::HandleEvent(const ScannerEvent *scanEvent)
{
if (msg.length() > 80)
msg = msg.left(77) + "...";
cout<<"\r"<<msg.toLatin1().constData()<<"\r";
cout<<flush;
std::cout<<"\r"<<msg.toLatin1().constData()<<"\r";
std::cout<<std::flush;
}
}

void ChannelScannerCLI::InformUser(const QString &error)
{
if (VERBOSE_LEVEL_NONE)
{
cerr<<"ERROR: "<<error.toLatin1().constData()<<endl;
std::cerr<<"ERROR: "<<error.toLatin1().constData()<<std::endl;
}
else
{
Expand All @@ -148,5 +146,5 @@ void ChannelScannerCLI::MonitorProgress(
bool /*lock*/, bool /*strength*/, bool /*snr*/, bool /*rotor*/)
{
if (VERBOSE_LEVEL_NONE)
cout<<"\r0%"<<flush;
std::cout<<"\r0%"<<std::flush;
}
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/channelscan/channelscanner_gui.cpp
Expand Up @@ -32,7 +32,6 @@

// Std C++
#include <algorithm>
using namespace std;

// MythTV headers
#include "mythdialogbox.h"
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/channelscan/externrecscanner.cpp
Expand Up @@ -109,8 +109,8 @@ void ExternRecChannelScanner::run(void)
return;
}

vector<uint> existing = ChannelUtil::GetChanIDs(m_sourceId);
vector<uint>::iterator Iold;
std::vector<uint> existing = ChannelUtil::GetChanIDs(m_sourceId);
std::vector<uint>::iterator Iold;

// Step 3/4 : Process
if (m_scanMonitor)
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythtv/channelscan/paneatsc.h
Expand Up @@ -6,7 +6,6 @@
#define PANE_ATSC_H

#include <algorithm>
using namespace std;

// MythTV headers
#include "channelscanmiscsettings.h"
Expand Down Expand Up @@ -105,7 +104,7 @@ class PaneATSC : public GroupSetting
b = a;
}

int diff = max(b + 1 - a, 0);
int diff = std::max(b + 1 - a, 0);
m_transportCount->setValue(QString::number(diff));
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/channelscan/paneexistingscanimport.h
Expand Up @@ -57,7 +57,7 @@ class PaneExistingScanImport : public GroupSetting
if (!m_sourceid)
return;

vector<ScanInfo> scans = LoadScanList(m_sourceid);
std::vector<ScanInfo> scans = LoadScanList(m_sourceid);
for (auto it = scans.rbegin(); it != scans.rend(); ++it)
{
ScanInfo &scan = *it;
Expand Down

0 comments on commit 4055915

Please sign in to comment.