本文整理汇总了C++中QRegularExpressionMatch::capturedRef方法的典型用法代码示例。如果您正苦于以下问题:C++ QRegularExpressionMatch::capturedRef方法的具体用法?C++ QRegularExpressionMatch::capturedRef怎么用?C++ QRegularExpressionMatch::capturedRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRegularExpressionMatch
的用法示例。
在下文中一共展示了QRegularExpressionMatch::capturedRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterAndAddToTextEdit
void AndroidDevice::filterAndAddToTextEdit(const QString& line)
{
static const QRegularExpression re(
"(?<date>[\\d-]+) *(?<time>[\\d:\\.]+) *(?<pid>\\d+) *(?<tid>\\d+) *(?<verbosity>[A-Z]) *(?<tag>.+):",
QRegularExpression::InvertedGreedinessOption | QRegularExpression::DotMatchesEverythingOption
);
bool filtersMatch = true;
const QRegularExpressionMatch match = re.match(line);
if (match.hasMatch())
{
const QStringRef date = match.capturedRef("date");
const QStringRef time = match.capturedRef("time");
const QStringRef pid = match.capturedRef("pid");
const QStringRef tid = match.capturedRef("tid");
const QStringRef verbosity = match.capturedRef("verbosity");
const QStringRef tag = match.capturedRef("tag").trimmed();
const QStringRef text = line.midRef(match.capturedEnd("tag") + 1);
const auto verbosityLevel = static_cast<VerbosityEnum>(Utils::verbosityCharacterToInt(verbosity.at(0).toLatin1()));
checkFilters(filtersMatch, m_filtersValid, verbosityLevel, pid, tid, tag, text);
if (filtersMatch)
{
const auto verbosityColorType = static_cast<ColorTheme::ColorType>(verbosityLevel);
m_deviceWidget->addText(verbosityColorType, verbosity);
m_deviceWidget->addText(ColorTheme::DateTime, date);
m_deviceWidget->addText(ColorTheme::DateTime, time);
m_deviceWidget->addText(ColorTheme::Pid, pid);
m_deviceWidget->addText(ColorTheme::Tid, tid);
m_deviceWidget->addText(ColorTheme::Tag, tag);
m_deviceWidget->addText(verbosityColorType, text);
m_deviceWidget->flushText();
}
}
else
{
qDebug() << "failed to parse" << line;
checkFilters(filtersMatch, m_filtersValid);
if (filtersMatch)
{
m_deviceWidget->addText(ColorTheme::VerbosityVerbose, QStringRef(&line));
m_deviceWidget->flushText();
}
}
m_deviceWidget->highlightFilterLineEdit(!m_filtersValid);
}
示例2: handleLink
void handleLink(const QString &href) final
{
const QRegularExpressionMatch match = filePattern.match(href);
if (!match.hasMatch())
return;
const QString fileName = match.captured(3);
const int lineNumber = match.capturedRef(4).toInt();
Core::EditorManager::openEditorAt(fileName, lineNumber);
}
示例3: insertRegularExpression
static QString insertRegularExpression (QRegularExpressionMatch &match) {
bool atEnd = match.capturedRef (2).isEmpty ();
QString result = QStringLiteral("(?<");
result.append (match.capturedRef (1));
result.append (QStringLiteral(">"));
if (atEnd) {
result.append (QStringLiteral(".+)"));
} else {
result.append (QStringLiteral("[^"));
result.append (match.capturedRef (2));
result.append (QStringLiteral("]+)"));
result.append (match.capturedRef (2));
}
return result;
}
示例4: appendMessage
void appendMessage(const QString &text, OutputFormat format) final
{
const bool isTrace = (format == StdErrFormat
|| format == StdErrFormatSameLine)
&& (text.startsWith("Traceback (most recent call last):")
|| text.startsWith("\nTraceback (most recent call last):"));
if (!isTrace) {
OutputFormatter::appendMessage(text, format);
return;
}
const QTextCharFormat frm = charFormat(format);
const Core::Id id(PythonErrorTaskCategory);
QVector<Task> tasks;
const QStringList lines = text.split('\n');
unsigned taskId = unsigned(lines.size());
for (const QString &line : lines) {
const QRegularExpressionMatch match = filePattern.match(line);
if (match.hasMatch()) {
QTextCursor tc = plainTextEdit()->textCursor();
tc.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
tc.insertText('\n' + match.captured(1));
tc.insertText(match.captured(2), linkFormat(frm, match.captured(2)));
const auto fileName = FileName::fromString(match.captured(3));
const int lineNumber = match.capturedRef(4).toInt();
Task task(Task::Warning,
QString(), fileName, lineNumber, id);
task.taskId = --taskId;
tasks.append(task);
} else {
if (!tasks.isEmpty()) {
Task &task = tasks.back();
if (!task.description.isEmpty())
task.description += ' ';
task.description += line.trimmed();
}
OutputFormatter::appendMessage('\n' + line, format);
}
}
if (!tasks.isEmpty()) {
tasks.back().type = Task::Error;
for (auto rit = tasks.crbegin(), rend = tasks.crend(); rit != rend; ++rit)
TaskHub::addTask(*rit);
}
}
示例5: progressInLine
IFilterStrategy::Progress MakeJobCompilerFilterStrategy::progressInLine(const QString& line)
{
// example string: [ 97%] Built target clang-parser
static const QRegularExpression re("^\\[([\\d ][\\d ]\\d)%\\] (.*)");
QRegularExpressionMatch match = re.match(line);
if (match.hasMatch()) {
bool ok;
const int percent = match.capturedRef(1).toInt(&ok);
if (ok) {
// this is output from make, likely
const QString action = match.captured(2);
return {action, percent};
}
}
return {};
}