summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index e8eb04b598..fdde0955dd 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -6669,6 +6669,28 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS
}
/*!
+ Splits the string into substring references wherever \a sep occurs, and
+ returns the list of those strings. If \a sep does not match
+ anywhere in the string, splitRef() returns a single-element vector
+ containing this string reference.
+
+ \a cs specifies whether \a sep should be matched case
+ sensitively or case insensitively.
+
+ If \a behavior is QString::SkipEmptyParts, empty entries don't
+ appear in the result. By default, empty entries are kept.
+
+ \note All references are valid as long this string is alive. Destroying this
+ string will cause all references be dangling pointers.
+
+ \since 5.4
+ \sa QStringRef split()
+*/
+QVector<QStringRef> QString::splitRef(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef> >(*this, &QString::midRef, sep, behavior, cs, sep.size());
+}
+/*!
\overload
*/
QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
@@ -6676,6 +6698,15 @@ QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivit
return splitString<QStringList>(*this, &QString::mid, sep, behavior, cs, 1);
}
+/*!
+ \overload
+ \since 5.4
+*/
+QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef> >(*this, &QString::midRef, sep, behavior, cs, 1);
+}
+
#ifndef QT_NO_REGEXP
namespace {
template<class ResultList, typename MidMethod>
@@ -6729,6 +6760,25 @@ QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
{
return splitString<QStringList>(*this, &QString::mid, rx, behavior);
}
+
+/*!
+ \overload
+ \since 5.4
+
+ Splits the string into substring references wherever the regular expression
+ \a rx matches, and returns the list of those strings. If \a rx
+ does not match anywhere in the string, splitRef() returns a
+ single-element vector containing this string reference.
+
+ \note All references are valid as long this string is alive. Destroying this
+ string will cause all references be dangling pointers.
+
+ \sa QStringRef split()
+*/
+QVector<QStringRef> QString::splitRef(const QRegExp &rx, SplitBehavior behavior) const
+{
+ return splitString<QVector<QStringRef> >(*this, &QString::midRef, rx, behavior);
+}
#endif
#ifndef QT_NO_REGULAREXPRESSION
@@ -6793,6 +6843,25 @@ QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior)
{
return splitString<QStringList>(*this, &QString::mid, re, behavior);
}
+
+/*!
+ \overload
+ \since 5.4
+
+ Splits the string into substring references wherever the regular expression
+ \a re matches, and returns the list of those strings. If \a re
+ does not match anywhere in the string, splitRef() returns a
+ single-element vector containing this string reference.
+
+ \note All references are valid as long this string is alive. Destroying this
+ string will cause all references be dangling pointers.
+
+ \sa split() QStringRef
+*/
+QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavior behavior) const
+{
+ return splitString<QVector<QStringRef> >(*this, &QString::midRef, re, behavior);
+}
#endif // QT_BOOTSTRAPPED
#endif // QT_NO_REGULAREXPRESSION