summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp14
-rw-r--r--src/corelib/io/qdir.cpp4
-rw-r--r--src/corelib/io/qfileselector.cpp2
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp2
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp2
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qprocess.h2
-rw-r--r--src/corelib/io/qsettings_winrt.cpp2
-rw-r--r--src/corelib/io/qstandardpaths.cpp3
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp4
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp2
-rw-r--r--src/corelib/serialization/qjsondocument.cpp14
-rw-r--r--src/corelib/text/qbytearray.cpp2
-rw-r--r--src/corelib/text/qstring.cpp186
-rw-r--r--src/corelib/text/qstring.h103
-rw-r--r--src/corelib/text/qstringlist.h17
-rw-r--r--src/corelib/time/qdatetime.cpp6
-rw-r--r--src/corelib/tools/qvector.h18
20 files changed, 262 insertions, 127 deletions
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index f797890e5d..271b6d7afc 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -762,7 +762,7 @@ void Widget::splitFunction()
//! [60]
str = "This time, a normal English sentence.";
- list = str.split(QRegExp("\\W+"), QString::SkipEmptyParts);
+ list = str.split(QRegExp("\\W+"), Qt::SkipEmptyParts);
// list: [ "This", "time", "a", "normal", "English", "sentence" ]
//! [60]
@@ -783,7 +783,7 @@ void Widget::splitFunction()
//! [91]
str = "This time, a normal English sentence.";
- list = str.split(QRegularExpression("\\W+"), QString::SkipEmptyParts);
+ list = str.split(QRegularExpression("\\W+"), Qt::SkipEmptyParts);
// list: [ "This", "time", "a", "normal", "English", "sentence" ]
//! [91]
@@ -797,24 +797,24 @@ void Widget::splitFunction()
void Widget::splitCaseSensitiveFunction()
{
//! [62]
- QString str = "a,,b,c";
+ QString str = QStringLiteral("a,,b,c");
- QStringList list1 = str.split(',');
+ QStringList list1 = str.split(QLatin1Char(','));
// list1: [ "a", "", "b", "c" ]
- QStringList list2 = str.split(',', QString::SkipEmptyParts);
+ QStringList list2 = str.split(QLatin1Char(','), Qt::SkipEmptyParts);
// list2: [ "a", "b", "c" ]
//! [62]
//! [62-empty]
QString str = "abc";
- auto parts = str.split("");
+ auto parts = str.split(QString());
// parts: {"", "a", "b", "c", ""}
//! [62-empty]
//! [62-slashes]
QString str = "/a/b/c/";
- auto parts = str.split('/');
+ auto parts = str.split(QLatin1Char('/'));
// parts: {"", "a", "b", "c", ""}
//! [62-slashes]
}
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 526702d151..5ce3fbcca8 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -867,8 +867,8 @@ QString QDir::relativeFilePath(const QString &fileName) const
#endif
QString result;
- QVector<QStringRef> dirElts = dir.splitRef(QLatin1Char('/'), QString::SkipEmptyParts);
- QVector<QStringRef> fileElts = file.splitRef(QLatin1Char('/'), QString::SkipEmptyParts);
+ QVector<QStringRef> dirElts = dir.splitRef(QLatin1Char('/'), Qt::SkipEmptyParts);
+ QVector<QStringRef> fileElts = file.splitRef(QLatin1Char('/'), Qt::SkipEmptyParts);
int i = 0;
while (i < dirElts.size() && i < fileElts.size() &&
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index 7adaafea18..0c42a98b37 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -324,7 +324,7 @@ void QFileSelectorPrivate::updateSelectors()
QLatin1Char pathSep(',');
QStringList envSelectors = QString::fromLatin1(qgetenv("QT_FILE_SELECTORS"))
- .split(pathSep, QString::SkipEmptyParts);
+ .split(pathSep, Qt::SkipEmptyParts);
if (envSelectors.count())
sharedData->staticSelectors << envSelectors;
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 36d43e9cb7..6ad123f3b6 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -394,7 +394,7 @@ static QString readLink(const QFileSystemEntry &link)
static bool uncShareExists(const QString &server)
{
// This code assumes the UNC path is always like \\?\UNC\server...
- const QVector<QStringRef> parts = server.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = server.splitRef(QLatin1Char('\\'), Qt::SkipEmptyParts);
if (parts.count() >= 3) {
QStringList shares;
if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index 6741282881..a2a4271ba9 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -101,7 +101,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags);
if (findFileHandle == INVALID_HANDLE_VALUE) {
if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) {
- const QVector<QStringRef> parts = nativePath.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = nativePath.splitRef(QLatin1Char('\\'), Qt::SkipEmptyParts);
if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer(
QLatin1String("\\\\") + parts.at(2), &uncShares)) {
if (uncShares.isEmpty())
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index acc60915e7..73e192fa3e 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2239,7 +2239,7 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
Tokens with spaces can be surrounded by double quotes; three
consecutive double quotes represent the quote character itself.
*/
-QStringList QProcess::splitCommand(const QString &command)
+QStringList QProcess::splitCommand(QStringView command)
{
QStringList args;
QString tmp;
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 0ef02b196d..fe11aa2ec6 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -282,7 +282,7 @@ public:
static QString nullDevice();
- static QStringList splitCommand(const QString &command);
+ static QStringList splitCommand(QStringView command);
public Q_SLOTS:
void terminate();
diff --git a/src/corelib/io/qsettings_winrt.cpp b/src/corelib/io/qsettings_winrt.cpp
index e91d4d64a2..a208262ab4 100644
--- a/src/corelib/io/qsettings_winrt.cpp
+++ b/src/corelib/io/qsettings_winrt.cpp
@@ -646,7 +646,7 @@ IApplicationDataContainer *QWinRTSettingsPrivate::getContainer(IApplicationDataC
IApplicationDataContainer *current = parent;
if (group.isEmpty())
return current;
- const QStringList groupPath = group.split(QLatin1Char('/'), QString::SkipEmptyParts);
+ const QStringList groupPath = group.split(QLatin1Char('/'), Qt::SkipEmptyParts);
for (const QString &subGroup : groupPath) {
ComPtr<IApplicationDataContainer> sub = subContainer(current, subGroup);
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 9d773e6f52..d95c9015cc 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -512,7 +512,8 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
}
// Remove trailing slashes, which occur on Windows.
- const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(QDir::listSeparator(), QString::SkipEmptyParts);
+ const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(
+ QDir::listSeparator(), Qt::SkipEmptyParts);
searchPaths.reserve(rawPaths.size());
for (const QString &rawPath : rawPaths) {
QString cleanPath = QDir::cleanPath(rawPath);
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 5f4955c53f..ec37ce7d76 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -283,7 +283,7 @@ static QStringList xdgDataDirs()
dirs.append(QString::fromLatin1("/usr/local/share"));
dirs.append(QString::fromLatin1("/usr/share"));
} else {
- const auto parts = xdgDataDirsEnv.splitRef(QLatin1Char(':'), QString::SkipEmptyParts);
+ const auto parts = xdgDataDirsEnv.splitRef(QLatin1Char(':'), Qt::SkipEmptyParts);
// Normalize paths, skip relative paths
for (const QStringRef &dir : parts) {
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index dc46695f80..09d2e194ba 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2693,7 +2693,7 @@ QStringList QCoreApplication::libraryPathsLocked()
auto setPathsFromEnv = [&](QString libPathEnv) {
if (!libPathEnv.isEmpty()) {
- QStringList paths = libPathEnv.split(QDir::listSeparator(), QString::SkipEmptyParts);
+ QStringList paths = libPathEnv.split(QDir::listSeparator(), Qt::SkipEmptyParts);
for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
QString canonicalPath = QDir(*it).canonicalPath();
if (!canonicalPath.isEmpty()
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index da4d98955d..c81f958e74 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -718,7 +718,7 @@ QMetaType &QMetaType::operator=(const QMetaType &other)
\relates QMetaType
\overload
- Returns \c true if the QMetaType \a a represents a difference type
+ Returns \c true if the QMetaType \a a represents a different type
than the QMetaType \a b, otherwise returns \c false.
*/
@@ -1750,7 +1750,7 @@ static QtPrivate::QMetaTypeInterface *interfaceForType(int typeId)
Constructs a QMetaType object that contains all information about type \a typeId.
- \note: The default parameter was added in Qt 5.15
+ \note The default parameter was added in Qt 5.15.
*/
QMetaType::QMetaType(int typeId) : QMetaType(interfaceForType(typeId)) {}
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index 1f8cef790c..1a88476596 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -109,7 +109,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
if (!onlySystemDirectory) {
const QString PATH(QLatin1String(qgetenv("PATH").constData()));
- searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts);
+ searchOrder << PATH.split(QLatin1Char(';'), Qt::SkipEmptyParts);
}
QString fileName = QString::fromWCharArray(libraryName);
fileName.append(QLatin1String(".dll"));
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index 0be0fc020d..338b752f13 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -239,6 +239,8 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other)
#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15)
/*!
+ \deprecated
+
Creates a QJsonDocument that uses the first \a size bytes from
\a data. It assumes \a data contains a binary encoded JSON document.
The created document does not take ownership of \a data. The data is
@@ -253,7 +255,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other)
Returns a QJsonDocument representing the data.
- \deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
+ \note Deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
compatibility. It is undocumented and restrictive in the maximum size of JSON
documents that can be encoded. Qt JSON types can be converted to Qt CBOR types,
which can in turn be serialized into the CBOR binary format and vice versa. The
@@ -285,13 +287,15 @@ QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidat
}
/*!
+ \deprecated
+
Returns the raw binary representation of the data
\a size will contain the size of the returned data.
This method is useful to e.g. stream the JSON document
in its binary form to a file.
- \deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
+ \note Deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
compatibility. It is undocumented and restrictive in the maximum size of JSON
documents that can be encoded. Qt JSON types can be converted to Qt CBOR types,
which can in turn be serialized into the CBOR binary format and vice versa. The
@@ -325,13 +329,14 @@ const char *QJsonDocument::rawData(int *size) const
}
/*!
+ \deprecated
Creates a QJsonDocument from \a data.
\a validation decides whether the data is checked for validity before being used.
By default the data is validated. If the \a data is not valid, the method returns
a null document.
- \deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
+ \note Deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
compatibility. It is undocumented and restrictive in the maximum size of JSON
documents that can be encoded. Qt JSON types can be converted to Qt CBOR types,
which can in turn be serialized into the CBOR binary format and vice versa. The
@@ -364,6 +369,7 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati
}
/*!
+ \deprecated
Returns a binary representation of the document.
The binary representation is also the native format used internally in Qt,
@@ -373,7 +379,7 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati
or computers. fromBinaryData() can be used to convert it back into a
JSON document.
- \deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
+ \note Deprecated in Qt 5.15. The binary JSON encoding is only retained for backwards
compatibility. It is undocumented and restrictive in the maximum size of JSON
documents that can be encoded. Qt JSON types can be converted to Qt CBOR types,
which can in turn be serialized into the CBOR binary format and vice versa. The
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index ac5f2afb57..52bde98b62 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -4969,7 +4969,7 @@ QByteArray QByteArray::toPercentEncoding(const QByteArray &exclude, const QByteA
\snippet code/src_corelib_tools_qbytearray.cpp 44ter
- In alternative, it is possible to access the conversion status
+ Alternatively, it is possible to access the conversion status
and the decoded data directly:
\snippet code/src_corelib_tools_qbytearray.cpp 44quater
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 8cdf41ffbf..da2c44bef6 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2018 Intel Corporation.
** Copyright (C) 2019 Mail.ru Group.
** Contact: https://www.qt.io/licensing/
@@ -1757,6 +1757,9 @@ const QString::Null QString::null = { };
/*!
\enum QString::SplitBehavior
+ \obsolete
+ Use Qt::SplitBehavior instead.
+
This enum specifies how the split() function should behave with
respect to empty strings.
@@ -4612,7 +4615,7 @@ int QString::count(const QRegularExpression &re) const
QString QString::section(const QString &sep, int start, int end, SectionFlags flags) const
{
- const QVector<QStringRef> sections = splitRef(sep, KeepEmptyParts,
+ const QVector<QStringRef> sections = splitRef(sep, Qt::KeepEmptyParts,
(flags & SectionCaseInsensitiveSeps) ? Qt::CaseInsensitive : Qt::CaseSensitive);
const int sectionsSize = sections.size();
if (!(flags & SectionSkipEmpty)) {
@@ -7603,23 +7606,30 @@ QString QString::number(double n, char f, int prec)
namespace {
template<class ResultList, class StringSource>
static ResultList splitString(const StringSource &source, const QChar *sep,
- QString::SplitBehavior behavior, Qt::CaseSensitivity cs, const int separatorSize)
+ Qt::SplitBehavior behavior, Qt::CaseSensitivity cs, const int separatorSize)
{
ResultList list;
typename StringSource::size_type start = 0;
typename StringSource::size_type end;
typename StringSource::size_type extra = 0;
while ((end = QtPrivate::findString(QStringView(source.constData(), source.size()), start + extra, QStringView(sep, separatorSize), cs)) != -1) {
- if (start != end || behavior == QString::KeepEmptyParts)
+ if (start != end || behavior == Qt::KeepEmptyParts)
list.append(source.mid(start, end - start));
start = end + separatorSize;
extra = (separatorSize == 0 ? 1 : 0);
}
- if (start != source.size() || behavior == QString::KeepEmptyParts)
+ if (start != source.size() || behavior == Qt::KeepEmptyParts)
list.append(source.mid(start, -1));
return list;
}
+#if QT_DEPRECATED_SINCE(5, 15)
+Qt::SplitBehavior mapSplitBehavior(QString::SplitBehavior sb)
+{
+ return sb & QString::SkipEmptyParts ? Qt::SkipEmptyParts : Qt::KeepEmptyParts;
+}
+#endif
+
} // namespace
/*!
@@ -7649,12 +7659,25 @@ static ResultList splitString(const StringSource &source, const QChar *sep,
\snippet qstring/main.cpp 62-slashes
\sa QStringList::join(), section()
+
+ \since 5.14
*/
-QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+QStringList QString::split(const QString &sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
return splitString<QStringList>(*this, sep.constData(), behavior, cs, sep.size());
}
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \obsolete
+*/
+QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return split(sep, mapSplitBehavior(behavior), cs);
+}
+#endif
+
/*!
Splits the string into substring references wherever \a sep occurs, and
returns the list of those strings.
@@ -7665,29 +7688,68 @@ QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseS
\note All references are valid as long this string is alive. Destroying this
string will cause all references to be dangling pointers.
- \since 5.4
+ \since 5.14
\sa QStringRef split()
*/
+QVector<QStringRef> QString::splitRef(const QString &sep, Qt::SplitBehavior behavior,
+ Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef>>(QStringRef(this), sep.constData(), behavior,
+ cs, sep.size());
+}
+
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \obsolete
+ \since 5.4
+*/
QVector<QStringRef> QString::splitRef(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
- return splitString<QVector<QStringRef> >(QStringRef(this), sep.constData(), behavior, cs, sep.size());
+ return splitRef(sep, mapSplitBehavior(behavior), cs);
}
+#endif
+
/*!
\overload
+ \since 5.14
*/
-QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+QStringList QString::split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
return splitString<QStringList>(*this, &sep, behavior, cs, 1);
}
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \obsolete
+*/
+QStringList QString::split(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return split(sep, mapSplitBehavior(behavior), cs);
+}
+#endif
+
+/*!
+ \overload
+ \since 5.14
+*/
+QVector<QStringRef> QString::splitRef(QChar sep, Qt::SplitBehavior behavior,
+ Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef> >(QStringRef(this), &sep, behavior, cs, 1);
+}
+
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
\since 5.4
*/
QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
- return splitString<QVector<QStringRef> >(QStringRef(this), &sep, behavior, cs, 1);
+ return splitRef(sep, mapSplitBehavior(behavior), cs);
}
+#endif
/*!
Splits the string into substrings references wherever \a sep occurs, and
@@ -7699,26 +7761,50 @@ QVector<QStringRef> QString::splitRef(QChar sep, SplitBehavior behavior, Qt::Cas
\note All references are valid as long this string is alive. Destroying this
string will cause all references to be dangling pointers.
+ \since 5.14
+*/
+QVector<QStringRef> QStringRef::split(const QString &sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef> >(*this, sep.constData(), behavior, cs, sep.size());
+}
+
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
\since 5.4
+ \obsolete
*/
QVector<QStringRef> QStringRef::split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
- return splitString<QVector<QStringRef> >(*this, sep.constData(), behavior, cs, sep.size());
+ return split(sep, mapSplitBehavior(behavior), cs);
}
+#endif
/*!
\overload
+ \since 5.14
+*/
+QVector<QStringRef> QStringRef::split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
+{
+ return splitString<QVector<QStringRef> >(*this, &sep, behavior, cs, 1);
+}
+
+#if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
\since 5.4
+ \obsolete
*/
QVector<QStringRef> QStringRef::split(QChar sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const
{
- return splitString<QVector<QStringRef> >(*this, &sep, behavior, cs, 1);
+ return split(sep, mapSplitBehavior(behavior), cs);
}
+#endif
#ifndef QT_NO_REGEXP
namespace {
template<class ResultList, typename MidMethod>
-static ResultList splitString(const QString &source, MidMethod mid, const QRegExp &rx, QString::SplitBehavior behavior)
+static ResultList splitString(const QString &source, MidMethod mid, const QRegExp &rx, Qt::SplitBehavior behavior)
{
QRegExp rx2(rx);
ResultList list;
@@ -7727,12 +7813,12 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegEx
int end;
while ((end = rx2.indexIn(source, start + extra)) != -1) {
int matchedLen = rx2.matchedLength();
- if (start != end || behavior == QString::KeepEmptyParts)
+ if (start != end || behavior == Qt::KeepEmptyParts)
list.append((source.*mid)(start, end - start));
start = end + matchedLen;
extra = (matchedLen == 0) ? 1 : 0;
}
- if (start != source.size() || behavior == QString::KeepEmptyParts)
+ if (start != source.size() || behavior == Qt::KeepEmptyParts)
list.append((source.*mid)(start, -1));
return list;
}
@@ -7740,6 +7826,7 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegEx
/*!
\overload
+ \since 5.14
Splits the string into substrings wherever the regular expression
\a rx matches, and returns the list of those strings. If \a rx
@@ -7764,14 +7851,25 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegEx
\sa QStringList::join(), section()
*/
-QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
+QStringList QString::split(const QRegExp &rx, Qt::SplitBehavior behavior) const
{
return splitString<QStringList>(*this, &QString::mid, rx, behavior);
}
+# if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
- \since 5.4
+ \obsolete
+*/
+QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
+{
+ return split(rx, mapSplitBehavior(behavior));
+}
+# endif
+
+/*!
+ \overload
+ \since 5.14
Splits the string into substring references wherever the regular expression
\a rx matches, and returns the list of those strings. If \a rx
@@ -7783,17 +7881,29 @@ QStringList QString::split(const QRegExp &rx, SplitBehavior behavior) const
\sa QStringRef split()
*/
-QVector<QStringRef> QString::splitRef(const QRegExp &rx, SplitBehavior behavior) const
+QVector<QStringRef> QString::splitRef(const QRegExp &rx, Qt::SplitBehavior behavior) const
{
return splitString<QVector<QStringRef> >(*this, &QString::midRef, rx, behavior);
}
-#endif
+
+# if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \since 5.4
+ \obsolete
+*/
+QVector<QStringRef> QString::splitRef(const QRegExp &rx, SplitBehavior behavior) const
+{
+ return splitRef(rx, mapSplitBehavior(behavior));
+}
+# endif
+#endif // QT_NO_REGEXP
#if QT_CONFIG(regularexpression)
namespace {
template<class ResultList, typename MidMethod>
static ResultList splitString(const QString &source, MidMethod mid, const QRegularExpression &re,
- QString::SplitBehavior behavior)
+ Qt::SplitBehavior behavior)
{
ResultList list;
if (!re.isValid()) {
@@ -7807,12 +7917,12 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegul
while (iterator.hasNext()) {
QRegularExpressionMatch match = iterator.next();
end = match.capturedStart();
- if (start != end || behavior == QString::KeepEmptyParts)
+ if (start != end || behavior == Qt::KeepEmptyParts)
list.append((source.*mid)(start, end - start));
start = match.capturedEnd();
}
- if (start != source.size() || behavior == QString::KeepEmptyParts)
+ if (start != source.size() || behavior == Qt::KeepEmptyParts)
list.append((source.*mid)(start, -1));
return list;
@@ -7821,7 +7931,7 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegul
/*!
\overload
- \since 5.0
+ \since 5.14
Splits the string into substrings wherever the regular expression
\a re matches, and returns the list of those strings. If \a re
@@ -7846,14 +7956,26 @@ static ResultList splitString(const QString &source, MidMethod mid, const QRegul
\sa QStringList::join(), section()
*/
-QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior) const
+QStringList QString::split(const QRegularExpression &re, Qt::SplitBehavior behavior) const
{
return splitString<QStringList>(*this, &QString::mid, re, behavior);
}
+# if QT_DEPRECATED_SINCE(5, 15)
/*!
\overload
- \since 5.4
+ \since 5.0
+ \obsolete
+*/
+QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior) const
+{
+ return split(re, mapSplitBehavior(behavior));
+}
+# endif
+
+/*!
+ \overload
+ \since 5.14
Splits the string into substring references wherever the regular expression
\a re matches, and returns the list of those strings. If \a re
@@ -7865,10 +7987,22 @@ QStringList QString::split(const QRegularExpression &re, SplitBehavior behavior)
\sa split() QStringRef
*/
-QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavior behavior) const
+QVector<QStringRef> QString::splitRef(const QRegularExpression &re, Qt::SplitBehavior behavior) const
{
return splitString<QVector<QStringRef> >(*this, &QString::midRef, re, behavior);
}
+
+# if QT_DEPRECATED_SINCE(5, 15)
+/*!
+ \overload
+ \since 5.4
+ \obsolete
+*/
+QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavior behavior) const
+{
+ return splitRef(re, mapSplitBehavior(behavior));
+}
+# endif
#endif // QT_CONFIG(regularexpression)
/*!
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index f08c7b0d00..f4d6fc24a5 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -580,45 +580,68 @@ public:
{ return replace(re, QString()); }
#endif
- enum SplitBehavior { KeepEmptyParts, SkipEmptyParts };
+#if QT_DEPRECATED_SINCE(5, 15)
+ enum SplitBehavior // ### Qt 6: replace with Qt:: version
+ {
+ KeepEmptyParts Q_DECL_ENUMERATOR_DEPRECATED,
+ SkipEmptyParts Q_DECL_ENUMERATOR_DEPRECATED
+ };
- Q_REQUIRED_RESULT QStringList split(const QString &sep, SplitBehavior behavior = KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT QVector<QStringRef> splitRef(const QString &sep, SplitBehavior behavior = KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT QStringList split(QChar sep, SplitBehavior behavior = KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT QVector<QStringRef> splitRef(QChar sep, SplitBehavior behavior = KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QStringList split(const QString &sep, SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> splitRef(const QString &sep, SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QStringList split(QChar sep, SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> splitRef(QChar sep, SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#ifndef QT_NO_REGEXP
- 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;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QStringList split(const QRegExp &sep, SplitBehavior behavior) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> splitRef(const QRegExp &sep, SplitBehavior behavior) const;
#endif
#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;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QStringList split(const QRegularExpression &sep, SplitBehavior behavior) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> splitRef(const QRegularExpression &sep, SplitBehavior behavior) const;
#endif
+#endif // 5.15 deprecations
-private:
- static Q_DECL_CONSTEXPR SplitBehavior _sb(Qt::SplitBehavior sb) Q_DECL_NOTHROW
- { return sb & Qt::SkipEmptyParts ? SkipEmptyParts : KeepEmptyParts; }
public:
-
- Q_REQUIRED_RESULT inline QStringList split(const QString &sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT inline QVector<QStringRef> splitRef(const QString &sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT inline QStringList split(QChar sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT inline QVector<QStringRef> splitRef(QChar sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QStringList split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> splitRef(const QString &sep,
+ Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QStringList split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> splitRef(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#ifndef QT_NO_REGEXP
- Q_REQUIRED_RESULT inline QStringList split(const QRegExp &sep, Qt::SplitBehavior behavior) const;
- Q_REQUIRED_RESULT inline QVector<QStringRef> splitRef(const QRegExp &sep, Qt::SplitBehavior behavior) const;
+ Q_REQUIRED_RESULT
+ QStringList split(const QRegExp &sep,
+ Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> splitRef(const QRegExp &sep,
+ Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
#endif
#ifndef QT_NO_REGULAREXPRESSION
- Q_REQUIRED_RESULT inline QStringList split(const QRegularExpression &sep, Qt::SplitBehavior behavior) const;
- Q_REQUIRED_RESULT inline QVector<QStringRef> splitRef(const QRegularExpression &sep, Qt::SplitBehavior behavior) const;
+ Q_REQUIRED_RESULT
+ QStringList split(const QRegularExpression &sep,
+ Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> splitRef(const QRegularExpression &sep,
+ Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
#endif
@@ -1485,15 +1508,21 @@ public:
int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT QVector<QStringRef> split(const QString &sep, QString::SplitBehavior behavior = QString::KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT QVector<QStringRef> split(QChar sep, QString::SplitBehavior behavior = QString::KeepEmptyParts,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+#if QT_DEPRECATED_SINCE(5, 15)
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> split(const QString &sep, QString::SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT QT_DEPRECATED_VERSION_X_5_15("Use Qt::SplitBehavior variant instead")
+ QVector<QStringRef> split(QChar sep, QString::SplitBehavior behavior,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+#endif // 5.15 deprecations
- Q_REQUIRED_RESULT inline QVector<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- Q_REQUIRED_RESULT inline QVector<QStringRef> split(QChar sep, Qt::SplitBehavior behavior,
- Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> split(const QString &sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ Q_REQUIRED_RESULT
+ QVector<QStringRef> split(QChar sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
Q_REQUIRED_RESULT QStringRef left(int n) const;
Q_REQUIRED_RESULT QStringRef right(int n) const;
diff --git a/src/corelib/text/qstringlist.h b/src/corelib/text/qstringlist.h
index 6e0940c488..c03e34b9ba 100644
--- a/src/corelib/text/qstringlist.h
+++ b/src/corelib/text/qstringlist.h
@@ -384,23 +384,6 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
#endif // QT_CONFIG(regularexpression)
#endif // Q_QDOC
-//
-// QString inline functions:
-//
-
-QStringList QString::split(const QString &sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return split(sep, _sb(behavior), cs); }
-QStringList QString::split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return split(sep, _sb(behavior), cs); }
-#ifndef QT_NO_REGEXP
-QStringList QString::split(const QRegExp &sep, Qt::SplitBehavior behavior) const
-{ return split(sep, _sb(behavior)); }
-#endif
-#if QT_CONFIG(regularexpression)
-QStringList QString::split(const QRegularExpression &sep, Qt::SplitBehavior behavior) const
-{ return split(sep, _sb(behavior)); }
-#endif
-
QT_END_NAMESPACE
#endif // QSTRINGLIST_H
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 14e36b59ca..e9fe34110a 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -173,7 +173,7 @@ static ParsedRfcDateTime rfcDateImpl(const QString &s)
// or "ddd MMM dd[ hh:mm:ss] yyyy [±hhmm]" - permissive RFC 850, 1036 (read only)
ParsedRfcDateTime result;
- auto words = s.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
+ auto words = s.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
if (words.size() < 3 || words.size() > 6)
return result;
const QChar colon(QLatin1Char(':'));
@@ -1784,7 +1784,7 @@ QT_WARNING_POP
return rfcDateImpl(string).date;
default:
case Qt::TextDate: {
- QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
+ QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
if (parts.count() != 4)
return QDate();
@@ -5417,7 +5417,7 @@ QT_WARNING_POP
return QDateTime(date, time, spec, offset);
}
case Qt::TextDate: {
- QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), QString::SkipEmptyParts);
+ QVector<QStringRef> parts = string.splitRef(QLatin1Char(' '), Qt::SkipEmptyParts);
if ((parts.count() < 5) || (parts.count() > 6))
return QDateTime();
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 026f99fd09..2d54cb1468 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -784,24 +784,6 @@ extern template class Q_CORE_EXPORT QVector<QPoint>;
QVector<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
-QVector<QStringRef> QString::splitRef(const QString &sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return splitRef(sep, _sb(behavior), cs); }
-QVector<QStringRef> QString::splitRef(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return splitRef(sep, _sb(behavior), cs); }
-#ifndef QT_NO_REGEXP
-QVector<QStringRef> QString::splitRef(const QRegExp &sep, Qt::SplitBehavior behavior) const
-{ return splitRef(sep, _sb(behavior)); }
-#endif
-#if QT_CONFIG(regularexpression)
-QVector<QStringRef> QString::splitRef(const QRegularExpression &sep, Qt::SplitBehavior behavior) const
-{ return splitRef(sep, _sb(behavior)); }
-#endif
-QVector<QStringRef> QStringRef::split(const QString &sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return split(sep, QString::_sb(behavior), cs); }
-QVector<QStringRef> QStringRef::split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const
-{ return split(sep, QString::_sb(behavior), cs); }
-
-
QT_END_NAMESPACE
#include <QtCore/qbytearraylist.h>