diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-05-22 16:47:19 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-06-01 20:43:21 +0200 |
commit | aac39167b7903eea886d8638ab84296d4e8952f1 (patch) | |
tree | 5a44a583ad44169ea5e3fa5d6b8209d1e73759f7 /src/corelib/text/qstringview.h | |
parent | 4f1ebf666e36020c501e6d3b20d70320b45ab2ec (diff) |
Add QStringView::split() methods
Since QString::split() is not going away in Qt 6, we should aim
to provide API symmetry here, and ease porting existing code from
QString(Ref) to use QStringView.
This is easier than having to port everything to use tokenize() at
the same time. tokenize() will however lead to better performance
and thus should be preferred.
Change-Id: I1eb43300a90167c6e9389ab56f416f2bf7edf506
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/text/qstringview.h')
-rw-r--r-- | src/corelib/text/qstringview.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index 5890515652..4e780628cc 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE class QString; class QStringRef; class QStringView; +class QRegularExpression; namespace QtPrivate { template <typename Char> @@ -339,6 +340,21 @@ public: Q_REQUIRED_RESULT inline int toWCharArray(wchar_t *array) const; // defined in qstring.h + + Q_REQUIRED_RESULT Q_CORE_EXPORT + QList<QStringView> split(QStringView sep, + Qt::SplitBehavior behavior = Qt::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + Q_REQUIRED_RESULT Q_CORE_EXPORT + QList<QStringView> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts, + Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + +#if QT_CONFIG(regularexpression) + Q_REQUIRED_RESULT Q_CORE_EXPORT + QList<QStringView> split(const QRegularExpression &sep, + Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const; +#endif + // // STL compatibility API: // |