summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-02-09 14:29:21 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-03-20 08:19:25 +0000
commit5a4787dca01c302dd462a76222dfbf28c8951a8d (patch)
tree897b7caea659526d740e98c06b11c15970d35a7b /src/corelib/tools
parentdd74f5d347d0a5a21527142f85114374e2d90646 (diff)
Modernize the "regularexpression" feature
Use QT_CONFIG(regularexpression), disentangle it from QT_BOOTSTRAPPED, switch it off in the bootstrap build, remove the #ifdefs from qregularexpression.{h|cpp}, and add QT_REQUIRE_CONFIG(regularexpression) to the header. qregularexpression.{h|cpp} are already correctly excluded in tools.pri if !qtConfig(regularexpression). Change-Id: I21de154a6a118b76f99003d3acb72ac1e220d302 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qregularexpression.cpp4
-rw-r--r--src/corelib/tools/qregularexpression.h6
-rw-r--r--src/corelib/tools/qstring.cpp30
-rw-r--r--src/corelib/tools/qstring.h8
-rw-r--r--src/corelib/tools/qstringlist.cpp22
-rw-r--r--src/corelib/tools/qstringlist.h24
6 files changed, 35 insertions, 59 deletions
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 86bc99716d..13eff07c04 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -41,8 +41,6 @@
#include "qregularexpression.h"
-#ifndef QT_NO_REGULAREXPRESSION
-
#include <QtCore/qcoreapplication.h>
#include <QtCore/qhashfunctions.h>
#include <QtCore/qreadwritelock.h>
@@ -2912,5 +2910,3 @@ static const char *pcreCompileErrorCodes[] =
#endif // #if 0
QT_END_NAMESPACE
-
-#endif // QT_NO_REGULAREXPRESSION
diff --git a/src/corelib/tools/qregularexpression.h b/src/corelib/tools/qregularexpression.h
index 050841e70e..398fc9ec9c 100644
--- a/src/corelib/tools/qregularexpression.h
+++ b/src/corelib/tools/qregularexpression.h
@@ -43,13 +43,13 @@
#include <QtCore/qglobal.h>
-#ifndef QT_NO_REGULAREXPRESSION
-
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
+QT_REQUIRE_CONFIG(regularexpression);
+
QT_BEGIN_NAMESPACE
class QStringView;
@@ -277,6 +277,4 @@ Q_DECLARE_SHARED(QRegularExpressionMatchIterator)
QT_END_NAMESPACE
-#endif // QT_NO_REGULAREXPRESSION
-
#endif // QREGULAREXPRESSION_H
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index b56ad34546..f6360f5504 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -40,7 +40,9 @@
#include "qstringlist.h"
#include "qregexp.h"
+#if QT_CONFIG(regularexpression)
#include "qregularexpression.h"
+#endif
#include "qunicodetables_p.h"
#ifndef QT_NO_TEXTCODEC
#include <qtextcodec.h>
@@ -3695,7 +3697,7 @@ int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs
}
-#if !(defined(QT_NO_REGEXP) && defined(QT_NO_REGULAREXPRESSION))
+#if !(defined(QT_NO_REGEXP) && !QT_CONFIG(regularexpression))
struct QStringCapture
{
int pos;
@@ -3862,8 +3864,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
}
#endif
-#ifndef QT_NO_REGULAREXPRESSION
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
/*!
\overload replace()
\since 5.0
@@ -3991,8 +3992,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
return *this;
}
-#endif // QT_BOOTSTRAPPED
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
/*!
Returns the number of (potentially overlapping) occurrences of
@@ -4207,8 +4207,7 @@ int QString::count(const QRegExp& rx) const
}
#endif // QT_NO_REGEXP
-#ifndef QT_NO_REGULAREXPRESSION
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
/*!
\overload indexOf()
\since 5.0
@@ -4386,8 +4385,7 @@ int QString::count(const QRegularExpression &re) const
}
return count;
}
-#endif // QT_BOOTSTRAPPED
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
/*! \fn int QString::count() const
@@ -4509,7 +4507,7 @@ QString QString::section(const QString &sep, int start, int end, SectionFlags fl
return ret;
}
-#if !(defined(QT_NO_REGEXP) && defined(QT_NO_REGULAREXPRESSION))
+#if !(defined(QT_NO_REGEXP) && !QT_CONFIG(regularexpression))
class qt_section_chunk {
public:
qt_section_chunk() {}
@@ -4619,8 +4617,7 @@ QString QString::section(const QRegExp &reg, int start, int end, SectionFlags fl
}
#endif
-#ifndef QT_NO_REGULAREXPRESSION
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
/*!
\overload section()
\since 5.0
@@ -4664,8 +4661,7 @@ QString QString::section(const QRegularExpression &re, int start, int end, Secti
return extractSections(sections, start, end, flags);
}
-#endif // QT_BOOTSTRAPPED
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
/*!
Returns a substring that contains the \a n leftmost characters
@@ -7586,8 +7582,7 @@ QVector<QStringRef> QString::splitRef(const QRegExp &rx, SplitBehavior behavior)
}
#endif
-#ifndef QT_NO_REGULAREXPRESSION
-#ifndef QT_BOOTSTRAPPED
+#if QT_CONFIG(regularexpression)
namespace {
template<class ResultList, typename MidMethod>
static ResultList splitString(const QString &source, MidMethod mid, const QRegularExpression &re,
@@ -7667,8 +7662,7 @@ QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavio
{
return splitString<QVector<QStringRef> >(*this, &QString::midRef, re, behavior);
}
-#endif // QT_BOOTSTRAPPED
-#endif // QT_NO_REGULAREXPRESSION
+#endif // QT_CONFIG(regularexpression)
/*!
\enum QString::NormalizationForm
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index b8f4d49831..f27f7efa2b 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -353,7 +353,7 @@ public:
inline bool contains(QRegExp &rx) const { return indexOf(rx) != -1; }
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
int indexOf(const QRegularExpression &re, int from = 0) const;
int indexOf(const QRegularExpression &re, int from, QRegularExpressionMatch *rmatch) const; // ### Qt 6: merge overloads
int lastIndexOf(const QRegularExpression &re, int from = -1) const;
@@ -377,7 +377,7 @@ public:
#ifndef QT_NO_REGEXP
QString section(const QRegExp &reg, int start, int end = -1, SectionFlags flags = SectionDefault) const;
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QString section(const QRegularExpression &re, int start, int end = -1, SectionFlags flags = SectionDefault) const;
#endif
Q_REQUIRED_RESULT QString left(int n) const;
@@ -502,7 +502,7 @@ public:
inline QString &remove(const QRegExp &rx)
{ return replace(rx, QString()); }
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
QString &replace(const QRegularExpression &re, const QString &after);
inline QString &remove(const QRegularExpression &re)
{ return replace(re, QString()); }
@@ -522,7 +522,7 @@ public:
Q_REQUIRED_RESULT QStringList split(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const;
Q_REQUIRED_RESULT QVector<QStringRef> splitRef(const QRegExp &sep, SplitBehavior behavior = KeepEmptyParts) const;
#endif
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
Q_REQUIRED_RESULT QStringList split(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const;
Q_REQUIRED_RESULT QVector<QStringRef> splitRef(const QRegularExpression &sep, SplitBehavior behavior = KeepEmptyParts) const;
#endif
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp
index 17f6bd8539..d10d9ad9d0 100644
--- a/src/corelib/tools/qstringlist.cpp
+++ b/src/corelib/tools/qstringlist.cpp
@@ -39,7 +39,9 @@
#include <qstringlist.h>
#include <qset.h>
-#include <qregularexpression.h>
+#if QT_CONFIG(regularexpression)
+# include <qregularexpression.h>
+#endif
#include <algorithm>
@@ -361,8 +363,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegExp
}
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
/*!
\fn QStringList QStringList::filter(const QRegularExpression &re) const
\overload
@@ -380,8 +381,7 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula
}
return res;
}
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
/*!
\fn QStringList &QStringList::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
@@ -436,8 +436,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegExp &r
}
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
/*!
\fn QStringList &QStringList::replaceInStrings(const QRegularExpression &re, const QString &after)
\overload
@@ -466,8 +465,7 @@ void QtPrivate::QStringList_replaceInStrings(QStringList *that, const QRegularEx
for (int i = 0; i < that->size(); ++i)
(*that)[i].replace(re, after);
}
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
static int accumulatedSize(const QStringList &list, int seplen)
{
@@ -674,8 +672,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int
}
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
/*!
\fn int QStringList::indexOf(const QRegularExpression &re, int from) const
\overload
@@ -732,8 +729,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx
}
return -1;
}
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
/*!
\fn int QStringList::removeDuplicates()
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index b11856d9be..e58445b8c0 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -84,12 +84,10 @@ public:
inline QStringList &replaceInStrings(const QRegExp &rx, const QString &after);
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
inline QStringList filter(const QRegularExpression &re) const;
inline QStringList &replaceInStrings(const QRegularExpression &re, const QString &after);
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
#ifndef Q_QDOC
private:
@@ -138,12 +136,10 @@ public:
inline int lastIndexOf(QRegExp &rx, int from = -1) const;
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
inline int indexOf(const QRegularExpression &re, int from = 0) const;
inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
using QList<QString>::indexOf;
using QList<QString>::lastIndexOf;
@@ -179,14 +175,12 @@ namespace QtPrivate {
int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, QRegExp &rx, int from);
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, const QRegularExpression &rx, const QString &after);
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QRegularExpression &re);
int Q_CORE_EXPORT QStringList_indexOf(const QStringList *that, const QRegularExpression &re, int from);
int Q_CORE_EXPORT QStringList_lastIndexOf(const QStringList *that, const QRegularExpression &re, int from);
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
}
inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
@@ -275,8 +269,7 @@ inline int QStringList::lastIndexOf(QRegExp &rx, int from) const
}
#endif
-#ifndef QT_BOOTSTRAPPED
-#ifndef QT_NO_REGULAREXPRESSION
+#if QT_CONFIG(regularexpression)
inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
{
QtPrivate::QStringList_replaceInStrings(self(), rx, after);
@@ -297,8 +290,7 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
{
return QtPrivate::QStringList_lastIndexOf(this, rx, from);
}
-#endif // QT_NO_REGULAREXPRESSION
-#endif // QT_BOOTSTRAPPED
+#endif // QT_CONFIG(regularexpression)
#endif // Q_QDOC
QT_END_NAMESPACE