Skip to content

Commit

Permalink
Don't include all of the standard namespace. (libmythbase)
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 a5fa9ae commit 6d7a5dd
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 283 deletions.
1 change: 0 additions & 1 deletion mythtv/libs/libmythbase/dbcheckcommon.cpp
Expand Up @@ -6,7 +6,6 @@

#include <cstdio>
#include <iostream>
using namespace std;

#include <QString>
#include <QSqlError>
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythbase/filesysteminfo.cpp
Expand Up @@ -16,8 +16,6 @@
#include <sys/mount.h> // for struct statfs
#endif

using namespace std;

#include <QList>
#include <QString>
#include <QStringList>
Expand Down Expand Up @@ -190,7 +188,7 @@ void FileSystemInfo::Consolidate(QList<FileSystemInfo> &disks,
if (it2->getFSysID() != -1) // disk has already been matched
continue;

int bSize = max(32, max(it1->getBlockSize(), it2->getBlockSize())
int bSize = std::max(32, std::max(it1->getBlockSize(), it2->getBlockSize())
/ 1024);
int64_t diffSize = it1->getTotalSpace() - it2->getTotalSpace();
int64_t diffUsed = it1->getUsedSpace() - it2->getUsedSpace();
Expand Down
6 changes: 2 additions & 4 deletions mythtv/libs/libmythbase/iso639.cpp
Expand Up @@ -7,13 +7,11 @@

#include <QStringList>

using namespace std;

QMap<int, QString> iso639_key_to_english_name;
static QMap<int, int> s_iso639_key2_to_key3;
static QMap<int, int> s_iso639_key3_to_canonical_key3;
static QStringList s_languages;
static vector<int> s_language_keys;
static std::vector<int> s_language_keys;

/* Note: this file takes a long time to compile. **/

Expand Down Expand Up @@ -55,7 +53,7 @@ QStringList iso639_get_language_list(void)
return s_languages;
}

vector<int> iso639_get_language_key_list(void)
std::vector<int> iso639_get_language_key_list(void)
{
if (s_language_keys.empty())
{
Expand Down
25 changes: 12 additions & 13 deletions mythtv/libs/libmythbase/logging.cpp
Expand Up @@ -12,8 +12,6 @@
#include <QVariantMap>
#include <iostream>

using namespace std;

#include "mythlogging.h"
#include "logging.h"
#include "loggingserver.h"
Expand Down Expand Up @@ -941,7 +939,7 @@ void verboseHelp(void)
{
QString m_verbose = userDefaultValueStr.simplified().replace(' ', ',');

cerr << "Verbose debug levels.\n"
std::cerr << "Verbose debug levels.\n"
"Accepts any combination (separated by comma) of:\n\n";

for (VerboseMap::Iterator vit = verboseMap.begin();
Expand All @@ -951,11 +949,11 @@ void verboseHelp(void)
QString name = QString(" %1").arg(item->name, -15, ' ');
if (item->helpText.isEmpty())
continue;
cerr << name.toLocal8Bit().constData() << " - " <<
item->helpText.toLocal8Bit().constData() << endl;
std::cerr << name.toLocal8Bit().constData() << " - "
<< item->helpText.toLocal8Bit().constData() << std::endl;
}

cerr << endl <<
std::cerr << std::endl <<
"The default for this program appears to be: '-v " <<
m_verbose.toLocal8Bit().constData() << "'\n\n"
"Most options are additive except for 'none' and 'all'.\n"
Expand All @@ -967,13 +965,14 @@ void verboseHelp(void)
"prefixing them with 'no', so you may use '-v all,nodatabase'\n"
"to view all but database debug messages.\n\n";

cerr << "The 'global' loglevel is specified with --loglevel, but can be\n"
std::cerr
<< "The 'global' loglevel is specified with --loglevel, but can be\n"
<< "overridden on a component by component basis by appending "
<< "':level'\n"
<< "to the component.\n"
<< " For example: -v gui:debug,channel:notice,record\n\n";

cerr << "Some debug levels may not apply to this program.\n" << endl;
std::cerr << "Some debug levels may not apply to this program.\n" << std::endl;
}

/// \brief Parse the --verbose commandline argument and set the verbose level
Expand All @@ -993,7 +992,7 @@ int verboseArgParse(const QString& arg)

if (arg.startsWith('-'))
{
cerr << "Invalid or missing argument to -v/--verbose option\n";
std::cerr << "Invalid or missing argument to -v/--verbose option\n";
return GENERIC_EXIT_INVALID_CMDLINE;
}

Expand Down Expand Up @@ -1023,11 +1022,11 @@ int verboseArgParse(const QString& arg)
}
if (option == "important")
{
cerr << "The \"important\" log mask is no longer valid.\n";
std::cerr << "The \"important\" log mask is no longer valid.\n";
}
else if (option == "extra")
{
cerr << "The \"extra\" log mask is no longer valid. Please try "
std::cerr << "The \"extra\" log mask is no longer valid. Please try "
"--loglevel debug instead.\n";
}
else if (option == "default")
Expand Down Expand Up @@ -1088,8 +1087,8 @@ int verboseArgParse(const QString& arg)
}
else
{
cerr << "Unknown argument for -v/--verbose: " <<
option.toLocal8Bit().constData() << endl;;
std::cerr << "Unknown argument for -v/--verbose: " <<
option.toLocal8Bit().constData() << std::endl;;
return GENERIC_EXIT_INVALID_CMDLINE;
}
}
Expand Down
2 changes: 0 additions & 2 deletions mythtv/libs/libmythbase/loggingserver.cpp
Expand Up @@ -13,8 +13,6 @@
#include <QSocketNotifier>
#include <iostream>

using namespace std;

#include "mythlogging.h"
#include "logging.h"
#include "loggingserver.h"
Expand Down
9 changes: 4 additions & 5 deletions mythtv/libs/libmythbase/mthread.cpp
Expand Up @@ -20,7 +20,6 @@
*/

#include <iostream>
using namespace std;

// Qt headers
#include <QStringList>
Expand Down Expand Up @@ -159,13 +158,13 @@ void MThread::Cleanup(void)
return;

// logging has been stopped so we need to use iostream...
cerr<<"Error: Not all threads were shut down properly: "<<endl;
std::cerr<<"Error: Not all threads were shut down properly: "<<std::endl;
for (auto *thread : qAsConst(badGuys))
{
cerr<<"Thread "<<qPrintable(thread->objectName())
<<" is still running"<<endl;
std::cerr<<"Thread "<<qPrintable(thread->objectName())
<<" is still running"<<std::endl;
}
cerr<<endl;
std::cerr<<std::endl;

static const int kTimeout = 5000;
MythTimer t;
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythbase/mthreadpool.cpp
Expand Up @@ -74,7 +74,6 @@

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

// Qt headers
#include <QCoreApplication>
Expand Down Expand Up @@ -218,7 +217,7 @@ class MThreadPoolPrivate

int GetRealMaxThread(void) const
{
return max(m_maxThreadCount,1) + m_reserveThread;
return std::max(m_maxThreadCount,1) + m_reserveThread;
}

mutable QMutex m_lock;
Expand Down

0 comments on commit 6d7a5dd

Please sign in to comment.