# include "qurl.h"
# include "qvariant.h"
# include "qabstractitemmodel.h"
+# include "qregularexpression.h"
#endif
#ifndef QT_NO_GEOM_VARIANT
#ifdef QT_NO_REGEXP
template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; };
#endif
+#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP)
+template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
+#endif
} // namespace
/*!
\value QPoint QPoint
\value QUrl QUrl
\value QRegExp QRegExp
+ \value QRegularExpression QRegularExpression
\value QDateTime QDateTime
\value QPointF QPointF
\value QPalette QPalette
break;
#endif
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegularExpression:
+ stream << *static_cast<const NS(QRegularExpression)*>(data);
+ break;
+#endif // QT_NO_REGEXP
case QMetaType::QEasingCurve:
stream << *static_cast<const NS(QEasingCurve)*>(data);
break;
-#endif
+#endif // QT_BOOTSTRAPPED
case QMetaType::QFont:
case QMetaType::QPixmap:
case QMetaType::QBrush:
break;
#endif
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegularExpression:
+ stream >> *static_cast< NS(QRegularExpression)*>(data);
+ break;
+#endif // QT_NO_REGEXP
case QMetaType::QEasingCurve:
stream >> *static_cast< NS(QEasingCurve)*>(data);
break;
-#endif
+#endif // QT_BOOTSTRAPPED
case QMetaType::QFont:
case QMetaType::QPixmap:
case QMetaType::QBrush:
return new NS(QRegExp)(*static_cast<const NS(QRegExp)*>(copy));
#endif
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegularExpression:
+ return new NS(QRegularExpression)(*static_cast<const NS(QRegularExpression)*>(copy));
+#endif // QT_NO_REGEXP
case QMetaType::QEasingCurve:
return new NS(QEasingCurve)(*static_cast<const NS(QEasingCurve)*>(copy));
-#endif
+#endif // QT_BOOTSTRAPPED
case QMetaType::QUuid:
return new NS(QUuid)(*static_cast<const NS(QUuid)*>(copy));
#ifndef QT_BOOTSTRAPPED
return new NS(QRegExp);
#endif
#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGEXP
+ case QMetaType::QRegularExpression:
+ return new NS(QRegularExpression);
+#endif // QT_NO_REGEXP
case QMetaType::QEasingCurve:
return new NS(QEasingCurve);
-#endif
+#endif // QT_BOOTSTRAPPED
case QMetaType::QUuid:
return new NS(QUuid);
#ifndef QT_BOOTSTRAPPED
F(QUuid, 30, QUuid) \
F(QVariant, 41, QVariant) \
F(QModelIndex, 42, QModelIndex) \
+ F(QRegularExpression, 44, QRegularExpression)
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)\
F(QObjectStar, 39, QObject*) \
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Bool,
- LastCoreType = Void,
+ LastCoreType = QRegularExpression,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QIcon,
#include "qdatetime.h"
#include "qeasingcurve.h"
#include "qlist.h"
+#include "qregularexpression.h"
#include "qstring.h"
#include "qstringlist.h"
#include "qurl.h"
#ifdef QT_BOOTSTRAPPED
template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; };
template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
#endif
#ifdef QT_NO_GEOM_VARIANT
template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; };
\value Rect a QRect
\value RectF a QRectF
\value RegExp a QRegExp
+ \value RegularExpression a QRegularExpression
\value Region a QRegion
\value Size a QSize
\value SizeF a QSizeF
Constructs a new variant with the regexp value \a regExp.
*/
+/*!
+ \fn QVariant::QVariant(const QRegularExpression &re)
+
+ \since 5.0
+
+ Constructs a new variant with the regular expression value \a re.
+*/
+
/*! \since 4.2
\fn QVariant::QVariant(Qt::GlobalColor color)
QVariant::QVariant(const QLocale &l) { d.is_null = false; d.type = Locale; v_construct<QLocale>(&d, l); }
#ifndef QT_NO_REGEXP
QVariant::QVariant(const QRegExp ®Exp) { d.is_null = false; d.type = RegExp; v_construct<QRegExp>(&d, regExp); }
-#endif
+#ifndef QT_BOOTSTRAPPED
+QVariant::QVariant(const QRegularExpression &re) { d.is_null = false; d.type = QMetaType::QRegularExpression; v_construct<QRegularExpression>(&d, re); }
+#endif // QT_BOOTSTRAPPED
+#endif // QT_NO_REGEXP
QVariant::QVariant(Qt::GlobalColor color) { create(62, &color); }
/*!
#endif
/*!
+ \fn QRegularExpression QVariant::toRegularExpression() const
+ \since 5.0
+
+ Returns the variant as a QRegularExpression if the variant has type() \l
+ QRegularExpression; otherwise returns an empty QRegularExpression.
+
+ \sa canConvert(), convert()
+*/
+#ifndef QT_BOOTSTRAPPED
+#ifndef QT_NO_REGEXP
+QRegularExpression QVariant::toRegularExpression() const
+{
+ return qVariantToHelper<QRegularExpression>(d, handlerManager);
+}
+#endif
+#endif
+
+/*!
\fn QChar QVariant::toChar() const
Returns the variant as a QChar if the variant has type() \l Char,
class QRectF;
#ifndef QT_NO_REGEXP
class QRegExp;
-#endif
+class QRegularExpression;
+#endif // QT_NO_REGEXP
class QTextFormat;
class QTextLength;
class QUrl;
Point = QMetaType::QPoint,
PointF = QMetaType::QPointF,
RegExp = QMetaType::QRegExp,
+ RegularExpression = QMetaType::QRegularExpression,
Hash = QMetaType::QVariantHash,
EasingCurve = QMetaType::QEasingCurve,
Uuid = QMetaType::QUuid,
QVariant(const QLocale &locale);
#ifndef QT_NO_REGEXP
QVariant(const QRegExp ®Exp);
-#endif
+#ifndef QT_BOOTSRAPPED
+ QVariant(const QRegularExpression &re);
+#endif // QT_BOOTSTRAPPED
+#endif // QT_NO_REGEXP
#ifndef QT_BOOTSTRAPPED
QVariant(const QEasingCurve &easing);
#endif
QLocale toLocale() const;
#ifndef QT_NO_REGEXP
QRegExp toRegExp() const;
-#endif
+#ifndef QT_BOOTSTRAPPED
+ QRegularExpression toRegularExpression() const;
+#endif // QT_BOOTSTRAPPED
+#endif // QT_NO_REGEXP
#ifndef QT_BOOTSTRAPPED
QEasingCurve toEasingCurve() const;
#endif
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QRegularExpression)
-
QT_END_HEADER
#endif // QT_NO_REGEXP
#endif
}
};
+template<> struct TestValueFactory<QMetaType::QRegularExpression> {
+ static QRegularExpression *create()
+ {
+#ifndef QT_NO_REGEXP
+ return new QRegularExpression("abc.*def");
+#else
+ return 0;
+#endif
+ }
+};
template<> struct TestValueFactory<QMetaType::QVariant> {
static QVariant *create() { return new QVariant(QStringList(QStringList() << "Q" << "t")); }
};
void toLocale();
void toRegExp();
+ void toRegularExpression();
void matrix();
rx = variant.toRegExp();
}
+void tst_QVariant::toRegularExpression()
+{
+ QVariant variant;
+ QRegularExpression re = variant.toRegularExpression();
+ QCOMPARE(re, QRegularExpression());
+
+ variant = QRegularExpression("abc.*def");
+ re = variant.toRegularExpression();
+ QCOMPARE(re, QRegularExpression("abc.*def"));
+
+ variant = QVariant::fromValue(QRegularExpression("[ab]\\w+"));
+ re = variant.value<QRegularExpression>();
+ QCOMPARE(re, QRegularExpression("[ab]\\w+"));
+}
+
void tst_QVariant::matrix()
{
QVariant variant;
QTest::newRow( "qchar_null" ) << QVariant(QChar(0)) << true;
QTest::newRow( "regexp" ) << QVariant(QRegExp("foo", Qt::CaseInsensitive)) << false;
QTest::newRow( "regexp_empty" ) << QVariant(QRegExp()) << false;
+ QTest::newRow( "regularexpression" ) << QVariant(QRegularExpression("abc.*def")) << false;
+ QTest::newRow( "regularexpression_empty" ) << QVariant(QRegularExpression()) << false;
// types known to QMetaType, but not part of QVariant::Type
QTest::newRow("QMetaType::Long invalid") << QVariant(QMetaType::Long, (void *) 0) << false;
QTest::newRow("48") << int(QVariant::Vector3D) << QByteArray("QVector3D");
QTest::newRow("49") << int(QVariant::Vector4D) << QByteArray("QVector4D");
QTest::newRow("50") << int(QVariant::Quaternion) << QByteArray("QQuaternion");
+ QTest::newRow("51") << int(QVariant::RegularExpression) << QByteArray("QRegularExpression");
}
void tst_QVariant::typeName()