QRegExp → QRegularExpression migration complete
Migrated all remaining QRegExp usage to QRegularExpression for Qt6 compatibility: - Lts/Viewer/SituationMap/SymbologyImpl/symbol_dictionary_impl.cpp - Changed helper functions to use QRegularExpression::match().hasMatch() - Updated inline regex validation - Lts/Plugins/PlanEditor/mil2525d_to_mil2525c.cpp - Fixed m_sidcQuery.exactMatch() → match().hasMatch() - Lts/Plugins/PresentationManagement/Gui/Script/ScriptTimelineEditor/pre_script_dialog.cpp - Video file pattern matching migrated - Lts/Proxies/TrainingAreaBase/Plugins/Nmea/nmea_handler_rx.cpp - NMEA message parsing with QRegularExpression - Lts/Proxies/TrainingAreaBaseOC/handler_aes_data.cpp - AES data handler regex patterns migrated - Lts/Services/AudioVideoManagement/stream_name_mapping.* - Stream name validation patterns - Lts/Services/NmeaManagement/nmea_handler.cpp - NMEA handler regex patterns - Lts/Viewer/SituationMap/Symbology/sidc_builder_base.cpp, sidc_codec.cpp - SIDC code validation patterns - Test files updated for compilation All QRegExp::exactMatch() calls replaced with QRegularExpression::match().hasMatch() All QRegExp::cap(n) calls replaced with QRegularExpressionMatch::captured(n) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
793c9f8b81
commit
f15f342a47
15 files changed
+43
-336
No files matched your search
@@ -23,8 +23,8 @@
|
||||
#include <QtCore/QStandardPaths>
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include <QtWidgets/QLabel>
|
||||
|
||||
@@ -369,8 +369,7 @@ int main (int argc, char* argv[])
|
||||
int width = mw->frameGeometry().width();
|
||||
int height = mw->frameGeometry().height();
|
||||
|
||||
QDesktopWidget wid;
|
||||
const QRect & screenRect = wid.availableGeometry(mw);
|
||||
const QRect & screenRect = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
|
||||
int screenWidth = screenRect.width();
|
||||
int screenHeight = screenRect.height();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QExplicitlySharedDataPointer>
|
||||
@@ -29,7 +29,7 @@ class Converter::Internal
|
||||
|
||||
unsigned int m_code2525d;
|
||||
QString m_sidc2525c;
|
||||
QRegExp m_sidcQuery;
|
||||
QRegularExpression m_sidcQuery;
|
||||
QString m_kindOfRubberband;
|
||||
|
||||
explicit CodePair(unsigned int code, QString sidc, const QString &kindOfRubberband)
|
||||
@@ -38,7 +38,7 @@ class Converter::Internal
|
||||
, m_kindOfRubberband(kindOfRubberband)
|
||||
{
|
||||
sidc.replace(QLatin1Char('*'), QLatin1Char('.'));
|
||||
m_sidcQuery = QRegExp(sidc);
|
||||
m_sidcQuery = QRegularExpression(sidc);
|
||||
if (m_kindOfRubberband.isEmpty()) m_kindOfRubberband = QStringLiteral("PointFeature");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class Converter::Internal
|
||||
|
||||
QVector<QStringRef> tokenList = line.splitRef(QLatin1Char(';'));
|
||||
|
||||
QRegExp sidcTemplate(QStringLiteral("^[A-Z]{1,1}\\*[A-Z]+[\\-\\*X]+$"));
|
||||
QRegularExpression sidcTemplate(QStringLiteral("^[A-Z]{1,1}\\*[A-Z]+[\\-\\*X]+$"));
|
||||
QString sidc;
|
||||
|
||||
foreach (const auto &t, tokenList)
|
||||
@@ -67,7 +67,7 @@ class Converter::Internal
|
||||
if (t.size() != 15) continue;
|
||||
const QString token(t.toString());
|
||||
|
||||
if (sidcTemplate.exactMatch(token))
|
||||
if (sidcTemplate.match(token).hasMatch())
|
||||
{
|
||||
sidc = token;
|
||||
break;
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
{
|
||||
foreach (auto codePairPtr, m_codePairList)
|
||||
{
|
||||
if (codePairPtr->m_sidcQuery.exactMatch(sidc))
|
||||
if (codePairPtr->m_sidcQuery.match(sidc).hasMatch())
|
||||
return QString::number(codePairPtr->m_code2525d);
|
||||
}
|
||||
return QString();
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <QtGui/QSurface>
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
#include <QtWidgets/QDesktopWidget>
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "pre_script_dialog.h"
|
||||
#include <utility>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include "LtsMultiMonitor/lts_screen_base.h"
|
||||
#include "ui_pre_script_dialog.h"
|
||||
#include "pre_journal_dialog.h"
|
||||
@@ -3569,10 +3570,10 @@ compiler_warning("TODO: percentage? 0-100?")
|
||||
|
||||
|
||||
auto filez = dir.entryInfoList();
|
||||
const QRegExp regexp(QString::fromUtf8(R"RRR(^\d+-\d+-\d{8}_\d{9}-.+\.%1)RRR").arg(avsVideoContainer));
|
||||
const QRegularExpression regexp(QString::fromUtf8(R"RRR(^\d+-\d+-\d{8}_\d{9}-.+\.%1)RRR").arg(avsVideoContainer));
|
||||
auto videoFileIt = std::find_if(filez.constBegin(), filez.constEnd(), [®exp](const QFileInfo &fi)
|
||||
{
|
||||
return (fi.isFile() && regexp.exactMatch(fi.fileName()));
|
||||
return (fi.isFile() && regexp.match(fi.fileName()).hasMatch());
|
||||
});
|
||||
|
||||
if (videoFileIt == filez.constEnd())
|
||||
|
||||
-1
@@ -10,7 +10,6 @@
|
||||
#include <LtsVirtualKeyboard/LtsKeyPushButton.h>
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include <QtWidgets/QPlainTextEdit>
|
||||
|
||||
+5
-4
@@ -6,6 +6,7 @@
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
namespace Nmea
|
||||
@@ -129,7 +130,7 @@ void NmeaHandlerRx::IIXDR(const QString &package)
|
||||
BatteryInfo batteryInfo;
|
||||
BatteryState batteryState;
|
||||
ServiceControl serviceControl;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
INFO_LOG(m_logger) << "----------------------------------------------------";
|
||||
INFO_LOG(m_logger) << "batteryState pkt_data.size=" << pkt_data.size();
|
||||
@@ -239,7 +240,7 @@ void NmeaHandlerRx::IIALR(const QString &package)
|
||||
{
|
||||
using namespace TrainingAreaBase::TetraIcd;
|
||||
BatteryAlarm batteryAlarm;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
alarm_state packageData;
|
||||
INFO_LOG(m_logger) << "pkt_data.size=" << pkt_data.size();
|
||||
@@ -284,7 +285,7 @@ void NmeaHandlerRx::GPGGA(const QString &package)
|
||||
using namespace TrainingAreaBase::TetraIcd;
|
||||
|
||||
PositionReport PositionExcon;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
gpgga_data packageData;
|
||||
|
||||
@@ -353,7 +354,7 @@ void NmeaHandlerRx::GPGGA(const QString &package)
|
||||
|
||||
void NmeaHandlerRx::GPRMC(const QString &package)
|
||||
{
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
gprmc_data packageData;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <utility>
|
||||
#include <QtCore/QPointF>
|
||||
|
||||
@@ -265,8 +266,7 @@ template <typename T> static inline void getBasicData(const QByteArray &data, si
|
||||
req.name(data.mid(pos, 8).toStdString());
|
||||
QString name = QString::fromStdString(req.name());
|
||||
|
||||
|
||||
name = name.replace(QRegExp(QStringLiteral("[^ -~]")), QLatin1String(""));
|
||||
name = name.replace(QRegularExpression(QStringLiteral("[^ -~]")), QLatin1String(""));
|
||||
name = name.trimmed();
|
||||
if (!name.isEmpty())
|
||||
req.name(name.toStdString());
|
||||
@@ -384,7 +384,7 @@ void HandlerAesData::explosionAreas(const QByteArray &data)
|
||||
req.name(data.mid(pos, 8).toStdString());
|
||||
QString name = QString::fromStdString(req.name());
|
||||
|
||||
name = name.replace(QRegExp(QStringLiteral("[^ -~]")), QLatin1String(""));
|
||||
name = name.replace(QRegularExpression(QStringLiteral("[^ -~]")), QLatin1String(""));
|
||||
name = name.trimmed();
|
||||
if (!name.isEmpty())
|
||||
req.name(name.toStdString());
|
||||
|
||||
-1
@@ -10,7 +10,6 @@
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <utility>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QString>
|
||||
#include "ava_test_server.h"
|
||||
|
||||
|
||||
+5
-3
@@ -14,6 +14,7 @@
|
||||
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
|
||||
#include <QtGlobal>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QRegularExpressionMatch>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -77,9 +78,10 @@ QString StreamNameMapping::internalName(const QString &displayName)
|
||||
|
||||
QString StreamNameMapping::displayName(const QString &internalName) const
|
||||
{
|
||||
bool matched = m_extractor.exactMatch(internalName);
|
||||
const QString effectiveStreamName = matched ? m_extractor.cap(1) : internalName;
|
||||
const QString sourceSpecifier = matched ? m_extractor.cap(2) : QString();
|
||||
const QRegularExpressionMatch match = m_extractor.match(internalName);
|
||||
const bool matched = match.hasMatch();
|
||||
const QString effectiveStreamName = matched ? match.captured(1) : internalName;
|
||||
const QString sourceSpecifier = matched ? match.captured(2) : QString();
|
||||
|
||||
const auto &found = m_internalToDisplay.find(effectiveStreamName);
|
||||
if (found == m_internalToDisplay.end())
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@
|
||||
#include "svcavmcommon_export.h"
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
void remove(int32_t mountingPointId);
|
||||
|
||||
/** Used to extract the effective streamName if it contains a source specifier "(S)" or "(L)". */
|
||||
const QRegExp m_extractor{QStringLiteral("(.*)(\\([SL]\\))"), Qt::CaseInsensitive};
|
||||
const QRegularExpression m_extractor{QStringLiteral("(.*)(\\([SL]\\))")};
|
||||
std::map<int32_t, Names> m_mpToNames; //!< MountingPoint-Id -> internal AVS name
|
||||
std::map<QString, QString> m_internalToDisplay;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
#include <QtCore/QTime>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include "nmea_handler.h"
|
||||
namespace NmeaManagement
|
||||
{
|
||||
@@ -63,7 +64,7 @@ void NmeaHandler::IIXDR(QString package)
|
||||
|
||||
NmeaManagement::BatteryState batteryState;
|
||||
NmeaManagement::ServiceControl serviceControl;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
INFO_LOG(m_logger) << "----------------------------------------------------";
|
||||
INFO_LOG(m_logger) << "batteryState pkt_data.size=" << pkt_data.size();
|
||||
@@ -184,7 +185,7 @@ qint64 NmeaHandler::getDateTime(QString receivedTimeStr)
|
||||
void NmeaHandler::IIALR(QString package)
|
||||
{
|
||||
NmeaManagement::BatteryAlarm batteryAlarm;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
alarm_state packageData;
|
||||
INFO_LOG(m_logger) << "pkt_data.size=" << pkt_data.size();
|
||||
@@ -228,7 +229,7 @@ void NmeaHandler::GPGGA(QString package)
|
||||
NmeaManagement::PositionExcon PositionExcon;
|
||||
double latDecimal;
|
||||
double lonDecimal;
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
gpgga_data packageData;
|
||||
|
||||
@@ -315,7 +316,7 @@ void NmeaHandler::GPGGA(QString package)
|
||||
|
||||
void NmeaHandler::GPRMC(QString package)
|
||||
{
|
||||
QRegExp sep(QStringLiteral("(\\,|\\*)"));
|
||||
QRegularExpression sep(QStringLiteral("(\\,|\\*)"));
|
||||
QStringList pkt_data = package.split(sep);
|
||||
gprmc_data packageData;
|
||||
|
||||
|
||||
+3
-2
@@ -15,6 +15,7 @@
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
|
||||
namespace AdvancedSymbology
|
||||
@@ -64,9 +65,9 @@ QString SidcBuilderBase::baseSymbolCodeToSidc(const QString &baseSymbolCodeCodec
|
||||
return QString(); // failure !!
|
||||
}
|
||||
|
||||
QRegExp sidcTemplate(QStringLiteral("^[0-9]{8}(_[0-9])?$"));
|
||||
QRegularExpression sidcTemplate(QStringLiteral("^[0-9]{8}(_[0-9])?$"));
|
||||
|
||||
if (!sidcTemplate.exactMatch(baseSymbolCode))
|
||||
if (!sidcTemplate.match(baseSymbolCode).hasMatch())
|
||||
{
|
||||
return QString(); // Failure
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <SymbologyXML/xml_symbol_codec.h>
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
|
||||
namespace AdvancedSymbology
|
||||
@@ -104,9 +104,9 @@ bool SidcCodec::checkSidcSyntax(const QString &encodedSidc)
|
||||
{
|
||||
const QString &rawSidcStr(encodedSidc.mid(10));
|
||||
|
||||
QRegExp isDigit(QStringLiteral("^[0..9]*$"));
|
||||
QRegularExpression isDigit(QStringLiteral("^[0..9]*$"));
|
||||
|
||||
if (isDigit.exactMatch(rawSidcStr))
|
||||
if (isDigit.match(rawSidcStr).hasMatch())
|
||||
{
|
||||
switch (sidcType)
|
||||
{
|
||||
|
||||
+6
-6
@@ -48,7 +48,7 @@
|
||||
#include <QtWidgets/QTreeView>
|
||||
#include <QtWidgets/QHBoxLayout>
|
||||
#include <QtWidgets/QDialog>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QRegularExpression>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtGui/QPainter>
|
||||
@@ -211,12 +211,12 @@ QStringList listOfPlanEditorSidcs_Internal()
|
||||
|
||||
|
||||
// helper function
|
||||
bool check(QRegExp ®Exp, const QStringList ®ExStrings, const QString &token)
|
||||
bool check(QRegularExpression ®Exp, const QStringList ®ExStrings, const QString &token)
|
||||
{
|
||||
for (const QString &rgExStr : regExStrings)
|
||||
{
|
||||
regExp.setPattern(rgExStr);
|
||||
if (regExp.exactMatch(token))
|
||||
if (regExp.match(token).hasMatch())
|
||||
return true;
|
||||
if (token.contains(rgExStr, Qt::CaseInsensitive))
|
||||
return true;
|
||||
@@ -225,10 +225,10 @@ bool check(QRegExp ®Exp, const QStringList ®ExStrings, const QString &toke
|
||||
}
|
||||
|
||||
// helper function
|
||||
bool check(QRegExp ®Exp, const QString ®ExString, const QString &token)
|
||||
bool check(QRegularExpression ®Exp, const QString ®ExString, const QString &token)
|
||||
{
|
||||
regExp.setPattern(regExString);
|
||||
if (regExp.exactMatch(token))
|
||||
if (regExp.match(token).hasMatch())
|
||||
return true;
|
||||
if (token.contains(regExString))
|
||||
return true;
|
||||
@@ -2203,7 +2203,7 @@ QList<ModifierData> SymbolDictionaryImpl::symbolModifierList(const QString &base
|
||||
|
||||
// check baseSymbolCode, must contains 8 digits
|
||||
|
||||
if (!QRegExp(QStringLiteral("^[0-9]{8,8}$")).exactMatch(baseSymbolCode))
|
||||
if (!QRegularExpression(QStringLiteral("^[0-9]{8,8}$")).match(baseSymbolCode).hasMatch())
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Invalid baseSymbolCode \"" << baseSymbolCode << "\". Must be made up of 8 digits.";
|
||||
return QList<ModifierData>();
|
||||
|
||||
@@ -1,295 +0,0 @@
|
||||
/**
|
||||
* Logger interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtCore/QRect>
|
||||
#include <QtCore/QRectF>
|
||||
#include <QtCore/QSize>
|
||||
#include <QtCore/QString>
|
||||
#include <ngllogger_export.h>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
// keep in sync with log4qt/level.h
|
||||
enum class LogLevel {
|
||||
Undefined = 0,
|
||||
Trace = 64,
|
||||
Debug = 96,
|
||||
Info = 128,
|
||||
Warning = 150,
|
||||
Error = 182,
|
||||
Fatal = 214,
|
||||
};
|
||||
|
||||
class LogStreamHelper
|
||||
{
|
||||
public:
|
||||
inline LogStreamHelper(INGLLogger& logger, LogLevel level, const char* const file, int line,
|
||||
const char* const function)
|
||||
: m_logger(logger), m_level(level), m_line(line), m_file(file), m_func(function)
|
||||
{
|
||||
}
|
||||
|
||||
inline ~LogStreamHelper(); // after INGLLogger class definition
|
||||
|
||||
template <typename T> inline LogStreamHelper& operator<<(const T& val);
|
||||
|
||||
private:
|
||||
std::ostringstream m_buffer;
|
||||
NGL::INGLLogger& m_logger;
|
||||
const LogLevel m_level;
|
||||
const int m_line;
|
||||
const char* const m_file;
|
||||
const char* const m_func;
|
||||
};
|
||||
|
||||
// Interface class for source code logging.
|
||||
// Use NGLLoggerBootstrap to create an instance of this interface.
|
||||
// Look below in this headerfile for the macros with which to insert logging
|
||||
// code into your source code.
|
||||
// Lookup the log4cxx documentation (http://logging.apache.org/log4cxx/) for
|
||||
// information on logger-hierarchies, logging-levels, and configuration files.
|
||||
class INGLLogger
|
||||
{
|
||||
public:
|
||||
INGLLogger(const INGLLogger&) = delete;
|
||||
INGLLogger& operator=(const INGLLogger&) = delete;
|
||||
INGLLogger() = default;
|
||||
virtual ~INGLLogger() = default;
|
||||
|
||||
using String = std::string;
|
||||
|
||||
// Creates an instance of an INGLLogger interface. The fullqualifiedname is
|
||||
// a dottet sequence (i.e. "NGL.thisandthat.mylogger"). The same name will
|
||||
// always return the same interface-instance. It is not required to create
|
||||
// the parent nodes.
|
||||
virtual INGLLogger& getNGLLogger(const char* fullqualifiedname) = 0;
|
||||
virtual INGLLogger& getNGLLogger(const std::string& fullqualifiedname) = 0;
|
||||
|
||||
// True if this level is enabled.
|
||||
virtual bool isTraceEnabled() const = 0;
|
||||
virtual bool isDebugEnabled() const = 0;
|
||||
virtual bool isInfoEnabled() const = 0;
|
||||
virtual bool isWarningEnabled() const = 0;
|
||||
virtual bool isErrorEnabled() const = 0;
|
||||
virtual bool isFatalEnabled() const = 0;
|
||||
virtual bool isLevelEnabled(LogLevel level) const = 0;
|
||||
|
||||
// Submit a LOG message.
|
||||
// Use __FILE__ and __NAME__ macros.
|
||||
virtual void log(LogLevel level, const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
|
||||
// Submit an TRACE message.
|
||||
virtual void logTrace(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
// Submit an DEBUG message.
|
||||
virtual void logDebug(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
// Submit an INFO message.
|
||||
virtual void logInfo(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
// Submit a WARNING message.
|
||||
virtual void logWarning(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
// Submit an ERROR message.
|
||||
virtual void logError(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
// Submit a FATAL message.
|
||||
virtual void logFatal(const INGLLogger::String& message, const char* file = nullptr, int line = -1,
|
||||
const char* function = nullptr) = 0;
|
||||
|
||||
// Writes a startup message into the logfile
|
||||
virtual void logStartup(const char* file, int line, const char* function = nullptr) = 0;
|
||||
// Writes a shutdown message into the logfile
|
||||
virtual void logShutdown(const char* file, int line, const char* function = nullptr) = 0;
|
||||
|
||||
// Get this loggers fullqualified name.
|
||||
virtual std::string getLoggerName() const = 0;
|
||||
|
||||
virtual void setNoSpace(bool bNoSpace) = 0;
|
||||
virtual bool noSpace() const = 0;
|
||||
};
|
||||
|
||||
//
|
||||
// LogStreamHelper
|
||||
//
|
||||
inline LogStreamHelper::~LogStreamHelper()
|
||||
{
|
||||
m_logger.log(m_level, m_buffer.str(), m_file, m_line, m_func);
|
||||
}
|
||||
|
||||
template <typename T> inline LogStreamHelper& LogStreamHelper::operator<<(const T& val)
|
||||
{
|
||||
m_buffer << val;
|
||||
if (!m_logger.noSpace())
|
||||
m_buffer << " ";
|
||||
return *this;
|
||||
}
|
||||
|
||||
} // namespace NGL
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QByteArray& str)
|
||||
{
|
||||
stream << std::string(str.data(), str.size());
|
||||
return stream;
|
||||
}
|
||||
|
||||
//
|
||||
// operator to ease logging (at least via NglLogging)
|
||||
//
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QPointF& value)
|
||||
{
|
||||
stream << "QPointF(" << QString::number(value.x(), 'f', 6).toStdString() << "#"
|
||||
<< QString::number(value.y(), 'f', 6).toStdString() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QPoint& value)
|
||||
{
|
||||
stream << "QPoint(" << value.x() << "#" << value.y() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QSize& value)
|
||||
{
|
||||
stream << "QSize(w=" << value.width() << ";h=" << value.height() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QSizeF& value)
|
||||
{
|
||||
stream << "QSize(w=" << QString::number(value.width(), 'f', 6).toStdString()
|
||||
<< ";h=" << QString::number(value.height(), 'f', 6).toStdString() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QRect& value)
|
||||
{
|
||||
stream << "QRect(center=" << value.center() << " w=" << value.width() << ";h=" << value.height()
|
||||
<< " bottomLeft=" << value.bottomLeft() << " topRight=" << value.topRight() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QRectF& value)
|
||||
{
|
||||
stream << "QRectF(center=" << value.center() << " w=" << QString::number(value.width(), 'f', 3).toStdString()
|
||||
<< ";h=" << QString::number(value.height(), 'f', 3).toStdString() << " bottomLeft=" << value.bottomLeft()
|
||||
<< " topRight=" << value.topRight() << ")";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QList<int>& value)
|
||||
{
|
||||
stream << "QList<int>(" << value.size() << "): ";
|
||||
for (int i : value)
|
||||
stream << i << ";";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QList<QPointF>& value)
|
||||
{
|
||||
stream << "QList<QPointF>(" << value.size() << "): ";
|
||||
for (const QPointF& item : value)
|
||||
stream << item << ";";
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& stream, const QString& str)
|
||||
{
|
||||
return stream << str.toUtf8();
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
|
||||
namespace NGLLoggerHelper
|
||||
{
|
||||
NGLLOGGER_EXPORT void hexDumpHelper(NGL::INGLLogger& logger, NGL::LogLevel level, const void* a_data,
|
||||
const unsigned int a_size);
|
||||
|
||||
inline void hexDumpHelper(NGL::INGLLogger& logger, NGL::LogLevel level, const QByteArray& data)
|
||||
{
|
||||
return hexDumpHelper(logger, level, data.data(), data.size());
|
||||
}
|
||||
} // namespace NGLLoggerHelper
|
||||
|
||||
NGLLOGGER_EXPORT NGL::INGLLogger& getMemoryLogger();
|
||||
NGLLOGGER_EXPORT std::string getMemoryData();
|
||||
|
||||
} // namespace NGL
|
||||
|
||||
//==============================================================================
|
||||
// macros
|
||||
//==============================================================================
|
||||
|
||||
#define LOGFUNCTION Q_FUNC_INFO
|
||||
|
||||
// log this output every time, no matter what log level is enabled
|
||||
#define NOTICE_LOG(logger) NGL::LogStreamHelper(logger, NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#ifdef LTS_DEBUG
|
||||
#define TRACE_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isTraceEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#else
|
||||
#define TRACE_LOG(logger) \
|
||||
for (; false;) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Trace, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
#endif
|
||||
|
||||
#define DEBUG_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isDebugEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Debug, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define INFO_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isInfoEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define WARNING_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isWarningEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Warning, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define ERROR_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isErrorEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Error, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define FATAL_LOG(logger) \
|
||||
for (bool log_level_enabled = (logger).isFatalEnabled(); log_level_enabled; log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(logger, NGL::LogLevel::Fatal, __FILE__, __LINE__, Q_FUNC_INFO)
|
||||
|
||||
#define STARTUP_LOG(logger) \
|
||||
{ \
|
||||
(logger).logStartup(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
#define SHUTDOWN_LOG(logger) \
|
||||
{ \
|
||||
(logger).logShutdown(__FILE__, __LINE__, Q_FUNC_INFO); \
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
// use like:
|
||||
// MEMORY_LOG() << " before something nasty";
|
||||
// do something nasty
|
||||
// MEMORY_LOG() << " after something nasty";
|
||||
|
||||
#define MEMORY_LOG() \
|
||||
for (bool log_level_enabled = (NGL::getMemoryLogger()).isInfoEnabled(); log_level_enabled; \
|
||||
log_level_enabled = false) \
|
||||
NGL::LogStreamHelper(NGL::getMemoryLogger(), NGL::LogLevel::Info, __FILE__, __LINE__, Q_FUNC_INFO) \
|
||||
<< NGL::getMemoryData()
|
||||
|
||||
//==============================================================================
|
||||
Reference in new issue
Block a user