Replace QRegExp with QRegularExpression
This commit is contained in:
parent
9830f21e4a
commit
cbcc223150
|
@ -35,7 +35,8 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionMatch>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
@ -306,11 +307,12 @@ QString LinuxDemangle(const QString &symbol);
|
||||||
|
|
||||||
QString LinuxDemangle(const QString &symbol) {
|
QString LinuxDemangle(const QString &symbol) {
|
||||||
|
|
||||||
QRegExp regex("\\(([^+]+)");
|
QRegularExpression regex("\\(([^+]+)");
|
||||||
if (!symbol.contains(regex)) {
|
QRegularExpressionMatch match = regex.match(symbol);
|
||||||
|
if (!match.hasMatch()) {
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
QString mangled_function = regex.cap(1);
|
QString mangled_function = match.captured(1);
|
||||||
return CXXDemangle(mangled_function);
|
return CXXDemangle(mangled_function);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QChar>
|
#include <QChar>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
#include <QRegularExpressionMatch>
|
||||||
|
|
||||||
#include "fmpsparser.h"
|
#include "fmpsparser.h"
|
||||||
|
|
||||||
|
@ -89,20 +91,20 @@ bool FMPSParser::Parse(const QString &data) {
|
||||||
|
|
||||||
int FMPSParser::ParseValueRef(const QStringRef& data, QVariant* ret) const {
|
int FMPSParser::ParseValueRef(const QStringRef& data, QVariant* ret) const {
|
||||||
// Try to match a float
|
// Try to match a float
|
||||||
int pos = float_re_.indexIn(*data.string(), data.position());
|
QRegularExpressionMatch re_match = float_re_.match(*data.string(), data.position());
|
||||||
if (pos == data.position()) {
|
if (re_match.captured() == data.position()) {
|
||||||
*ret = float_re_.cap(1).toDouble();
|
*ret = re_match.captured(1).toDouble();
|
||||||
return float_re_.matchedLength();
|
return re_match.capturedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise try to match a string
|
// Otherwise try to match a string
|
||||||
pos = string_re_.indexIn(*data.string(), data.position());
|
re_match = string_re_.match(*data.string(), data.position());
|
||||||
if (pos == data.position()) {
|
if (re_match.captured() == data.position()) {
|
||||||
// Replace escape sequences with their actual characters
|
// Replace escape sequences with their actual characters
|
||||||
QString value = string_re_.cap(1);
|
QString value = re_match.captured(1);
|
||||||
value.replace(escape_re_, "\\1");
|
value.replace(escape_re_, "\\1");
|
||||||
*ret = value;
|
*ret = value;
|
||||||
return string_re_.matchedLength();
|
return re_match.capturedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
|
|
||||||
class FMPSParser {
|
class FMPSParser {
|
||||||
public:
|
public:
|
||||||
FMPSParser();
|
FMPSParser();
|
||||||
|
|
||||||
// A FMPS result is a list of lists of values (where a value is a string or
|
// A FMPS result is a list of lists of values (where a value is a string or
|
||||||
|
@ -54,10 +54,10 @@ public:
|
||||||
int ParseListList(const QString &data, Result *ret) const;
|
int ParseListList(const QString &data, Result *ret) const;
|
||||||
int ParseListListRef(const QStringRef &data, Result *ret) const;
|
int ParseListListRef(const QStringRef &data, Result *ret) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRegExp float_re_;
|
QRegularExpression float_re_;
|
||||||
QRegExp string_re_;
|
QRegularExpression string_re_;
|
||||||
QRegExp escape_re_;
|
QRegularExpression escape_re_;
|
||||||
Result result_;
|
Result result_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue