QRegularExpression: QDebug support for pattern options

Added the proper QDebug operator to debug the
QRegularExpression::PatternOptions flags.

Change-Id: Icd00e93a0c6cc4345db528d494fc176624f7b7a2
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
bb10
Giuseppe D'Angelo 2012-02-07 23:56:40 +00:00 committed by Qt by Nokia
parent c7cb455a47
commit aea65cbaa4
2 changed files with 38 additions and 0 deletions

View File

@ -1976,6 +1976,43 @@ QDebug operator<<(QDebug debug, const QRegularExpression &re)
return debug.space();
}
/*!
\relates QRegularExpression
Writes the pattern options \a patternOptions into the debug object \a debug
for debugging purposes.
\sa {Debugging Techniques}
*/
QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions)
{
QStringList flags;
if (patternOptions == QRegularExpression::NoPatternOption) {
flags << QLatin1String("NoPatternOption");
} else {
if (patternOptions & QRegularExpression::CaseInsensitiveOption)
flags << QLatin1String("CaseInsensitiveOption");
if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
flags << QLatin1String("DotMatchesEverythingOption");
if (patternOptions & QRegularExpression::MultilineOption)
flags << QLatin1String("MultilineOption");
if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
flags << QLatin1String("ExtendedPatternSyntaxOption");
if (patternOptions & QRegularExpression::InvertedGreedinessOption)
flags << QLatin1String("InvertedGreedinessOption");
if (patternOptions & QRegularExpression::DontCaptureOption)
flags << QLatin1String("DontCaptureOption");
if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
flags << QLatin1String("UseUnicodePropertiesOption");
}
debug.nospace() << "QRegularExpression::PatternOptions("
<< qPrintable(flags.join(QLatin1String("|")))
<< ")";
return debug.space();
}
/*!
\relates QRegularExpressionMatch

View File

@ -142,6 +142,7 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &in, QRegularExpression &re);
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QRegularExpression &re);
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions);
#endif
struct QRegularExpressionMatchPrivate;