QRegularExpression: QDebug support for pattern options
authorGiuseppe D'Angelo <dangelog@gmail.com>
Tue, 7 Feb 2012 23:56:40 +0000 (23:56 +0000)
committerQt by Nokia <qt-info@nokia.com>
Tue, 6 Mar 2012 20:54:11 +0000 (21:54 +0100)
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>
src/corelib/tools/qregularexpression.cpp
src/corelib/tools/qregularexpression.h

index 488a454..7fbbfaa 100644 (file)
@@ -1977,6 +1977,43 @@ QDebug operator<<(QDebug debug, const QRegularExpression &re)
 }
 
 /*!
+    \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
 
     Writes the match object \a match into the debug object \a debug for
index c9bcb1e..13c7de7 100644 (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;