summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-04-20 11:19:14 +0200
committerLiang Qi <liang.qi@qt.io>2017-04-20 12:31:27 +0200
commit7950b6b283549c98f1e0f981c84b68071a13b616 (patch)
treecf7281872045ebd57c68e10064ff0f400084aa13 /src/corelib
parent58d2927861d3e57cac4f6db599e209d2bfb17a2c (diff)
parent0794d61c822585530243f638687b8a75f0a15d0c (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/corelib/tools/qbytearray.h src/corelib/tools/qdatetime.h src/corelib/tools/qstring.h src/corelib/tools/qversionnumber.h src/plugins/platforms/android/qandroidplatformintegration.cpp tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp Change-Id: Iefd92a435e687a76cd593099e40d9a9620a1454d
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qcompilerdetection.h18
-rw-r--r--src/corelib/global/qfloat16.h17
-rw-r--r--src/corelib/global/qglobal.cpp24
-rw-r--r--src/corelib/global/qglobal.h18
-rw-r--r--src/corelib/global/qsysinfo.h1
-rw-r--r--src/corelib/io/qdatastream.cpp20
-rw-r--r--src/corelib/io/qdatastream.h2
-rw-r--r--src/corelib/io/qdebug.h2
-rw-r--r--src/corelib/io/qfileselector.cpp10
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp21
-rw-r--r--src/corelib/io/qloggingregistry.cpp83
-rw-r--r--src/corelib/io/qloggingregistry_p.h7
-rw-r--r--src/corelib/io/qprocess_unix.cpp4
-rw-r--r--src/corelib/io/qurl.h4
-rw-r--r--src/corelib/kernel/qjni.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp2
-rw-r--r--src/corelib/kernel/qvariant.cpp21
-rw-r--r--src/corelib/thread/qthreadpool.h2
-rw-r--r--src/corelib/tools/qarraydata.h14
-rw-r--r--src/corelib/tools/qarraydatapointer.h2
-rw-r--r--src/corelib/tools/qbytearray.h60
-rw-r--r--src/corelib/tools/qdatetime.cpp3
-rw-r--r--src/corelib/tools/qdatetime.h20
-rw-r--r--src/corelib/tools/qline.h18
-rw-r--r--src/corelib/tools/qlocale.cpp4
-rw-r--r--src/corelib/tools/qmap.h6
-rw-r--r--src/corelib/tools/qpoint.h6
-rw-r--r--src/corelib/tools/qrect.h46
-rw-r--r--src/corelib/tools/qregularexpression.cpp35
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h5
-rw-r--r--src/corelib/tools/qsimd_p.h5
-rw-r--r--src/corelib/tools/qsize.h26
-rw-r--r--src/corelib/tools/qstring.h230
-rw-r--r--src/corelib/tools/qstringbuilder.cpp28
-rw-r--r--src/corelib/tools/qtimezoneprivate_p.h4
-rw-r--r--src/corelib/tools/qversionnumber.h32
36 files changed, 438 insertions, 364 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index fcfe020509..5fc7ac9c7e 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -172,7 +172,11 @@
/* Clang also masquerades as GCC */
# if defined(__apple_build_version__)
# /* http://en.wikipedia.org/wiki/Xcode#Toolchain_Versions */
-# if __apple_build_version__ >= 7000053
+# if __apple_build_version__ >= 8020041
+# define Q_CC_CLANG 309
+# elif __apple_build_version__ >= 8000038
+# define Q_CC_CLANG 308
+# elif __apple_build_version__ >= 7000053
# define Q_CC_CLANG 306
# elif __apple_build_version__ >= 6000051
# define Q_CC_CLANG 305
@@ -628,10 +632,7 @@
# define Q_COMPILER_ALIGNAS
# define Q_COMPILER_ALIGNOF
# define Q_COMPILER_INHERITING_CONSTRUCTORS
-# ifndef Q_OS_OSX
-// C++11 thread_local is broken on OS X (Clang doesn't support it either)
-# define Q_COMPILER_THREAD_LOCAL
-# endif
+# define Q_COMPILER_THREAD_LOCAL
# define Q_COMPILER_UDL
# endif
# ifdef _MSC_VER
@@ -993,6 +994,10 @@
# endif /* __cplusplus */
#endif /* Q_CC_MSVC */
+#ifdef Q_COMPILER_UNICODE_STRINGS
+# define Q_STDLIB_UNICODE_STRINGS
+#endif
+
#ifdef __cplusplus
# include <utility>
# if defined(Q_OS_QNX)
@@ -1015,8 +1020,9 @@
# undef Q_COMPILER_INITIALIZER_LISTS
# undef Q_COMPILER_RVALUE_REFS
# undef Q_COMPILER_REF_QUALIFIERS
-# undef Q_COMPILER_UNICODE_STRINGS
# undef Q_COMPILER_NOEXCEPT
+// Disable C++11 library features:
+# undef Q_STDLIB_UNICODE_STRINGS
# endif // !_HAS_CPP0X
# if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T
# undef Q_COMPILER_NULLPTR
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h
index 05b88e0e92..b0272c51c3 100644
--- a/src/corelib/global/qfloat16.h
+++ b/src/corelib/global/qfloat16.h
@@ -81,18 +81,18 @@ private:
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE);
-Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
-Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
-Q_CORE_EXPORT Q_REQUIRED_RESULT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
+Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsInf(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
+Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsNaN(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
+Q_REQUIRED_RESULT Q_CORE_EXPORT bool qIsFinite(qfloat16 f) Q_DECL_NOTHROW; // complements qnumeric.h
// The remainder of these utility functions complement qglobal.h
-inline Q_REQUIRED_RESULT int qRound(qfloat16 d) Q_DECL_NOTHROW
+Q_REQUIRED_RESULT inline int qRound(qfloat16 d) Q_DECL_NOTHROW
{ return qRound(static_cast<float>(d)); }
-inline Q_REQUIRED_RESULT qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW
+Q_REQUIRED_RESULT inline qint64 qRound64(qfloat16 d) Q_DECL_NOTHROW
{ return qRound64(static_cast<float>(d)); }
-inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW
+Q_REQUIRED_RESULT inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOTHROW
{
float f1 = static_cast<float>(p1);
float f2 = static_cast<float>(p2);
@@ -105,7 +105,7 @@ inline Q_REQUIRED_RESULT bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) Q_DECL_NOT
return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2)));
}
-inline Q_REQUIRED_RESULT bool qIsNull(qfloat16 f) Q_DECL_NOTHROW
+Q_REQUIRED_RESULT inline bool qIsNull(qfloat16 f) Q_DECL_NOTHROW
{
return (f.b16 & static_cast<quint16>(0x7fff)) == 0;
}
@@ -115,6 +115,7 @@ inline int qIntCast(qfloat16 f) Q_DECL_NOTHROW
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wc99-extensions")
+QT_WARNING_DISABLE_GCC("-Wold-style-cast")
inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW
{
#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__))
@@ -246,7 +247,7 @@ QT_WARNING_POP
/*!
\internal
*/
-inline Q_REQUIRED_RESULT bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW
+Q_REQUIRED_RESULT inline bool qFuzzyIsNull(qfloat16 f) Q_DECL_NOTHROW
{
return qAbs(static_cast<float>(f)) <= 0.001f;
}
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index e7bfbb2903..6de03d73b3 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2643,12 +2643,14 @@ QString QSysInfo::kernelVersion()
to determine the distribution name and returns that. If determining the
distribution name failed, it returns "unknown".
- \b{Darwin, \macos, iOS, tvOS, and watchOS note}: this function returns
- "macos" for \macos systems, "ios" for iOS systems, "tvos" for tvOS systems,
- "watchos" for watchOS systems, and "darwin" in case the system could not
- be determined.
+ \b{\macos note}: this function returns "osx" for all \macos systems,
+ regardless of Apple naming convention. The returned string will be updated
+ for Qt 6. Note that this function erroneously returned "macos" for \macos
+ 10.12 in Qt versions 5.6.2, 5.7.1, and 5.8.0.
- \b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12.
+ \b{Darwin, iOS, tvOS, and watchOS note}: this function returns "ios" for
+ iOS systems, "tvos" for tvOS systems, "watchos" for watchOS systems, and
+ "darwin" in case the system could not be determined.
\b{FreeBSD note}: this function returns "debian" for Debian/kFreeBSD and
"unknown" otherwise.
@@ -2681,10 +2683,12 @@ QString QSysInfo::productType()
#elif defined(Q_OS_WATCHOS)
return QStringLiteral("watchos");
#elif defined(Q_OS_MACOS)
- const auto version = QOperatingSystemVersion::current();
- if (version.majorVersion() == 10 && version.minorVersion() < 12)
- return QStringLiteral("osx");
+ // ### Qt6: remove fallback
+# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return QStringLiteral("macos");
+# else
+ return QStringLiteral("osx");
+# endif
#elif defined(Q_OS_DARWIN)
return QStringLiteral("darwin");
@@ -3198,12 +3202,16 @@ static QBasicMutex environmentMutex;
Returns the value of the environment variable with name \a
varName. To get the variable string, use QByteArray::constData().
+ To convert the data to a QString use QString::fromLocal8Bit().
\note qgetenv() was introduced because getenv() from the standard
C library was deprecated in VC2005 (and later versions). qgetenv()
uses the new replacement function in VC, and calls the standard C
library's implementation on all other platforms.
+ \warning Don't use qgetenv on Windows if the content may contain
+ non-US-ASCII characters, like file paths.
+
\sa qputenv(), qEnvironmentVariableIsSet(), qEnvironmentVariableIsEmpty()
*/
QByteArray qgetenv(const char *varName)
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 49577caba2..e04d9fdefa 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -783,26 +783,22 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("Unimplemented code.")
#endif
-Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
+Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
+Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
-Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
+Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
-Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
+Q_REQUIRED_RESULT Q_DECL_CONSTEXPR static inline Q_DECL_UNUSED bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
}
@@ -812,8 +808,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
-static inline bool qIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-static inline bool qIsNull(double d)
+Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(double d)
{
union U {
double d;
@@ -829,8 +824,7 @@ static inline bool qIsNull(double d)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
-static inline bool qIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED;
-static inline bool qIsNull(float f)
+Q_REQUIRED_RESULT static inline Q_DECL_UNUSED bool qIsNull(float f)
{
union U {
float f;
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index ff0a784ace..f443ab4b93 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -213,6 +213,7 @@ public:
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
QT_WARNING_DISABLE_CLANG("-Wdeprecated-declarations")
+QT_WARNING_DISABLE_INTEL(1478)
QT_WARNING_DISABLE_INTEL(1786)
QT_WARNING_DISABLE_MSVC(4996)
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 58e2500057..9044ad74b1 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -772,6 +772,17 @@ int QDataStream::readBlock(char *data, int len)
}
/*!
+ \fn QDataStream &QDataStream::operator>>(std::nullptr &ptr)
+ \since 5.9
+ \overload
+
+ Simulates reading a \c{std::nullptr_t} from the stream into \a ptr and
+ returns a reference to the stream. This function does not actually read
+ anything from the stream, as \c{std::nullptr_t} values are stored as 0
+ bytes.
+*/
+
+/*!
\fn QDataStream &QDataStream::operator>>(quint8 &i)
\overload
@@ -1085,6 +1096,15 @@ int QDataStream::readRawData(char *s, int len)
QDataStream write functions
*****************************************************************************/
+/*!
+ \fn QDataStream &QDataStream::operator<<(std::nullptr ptr)
+ \since 5.9
+ \overload
+
+ Simulates writing a \c{std::nullptr_t}, \a ptr, to the stream and returns a
+ reference to the stream. This function does not actually write anything to
+ the stream, as \c{std::nullptr_t} values are stored as 0 bytes.
+*/
/*!
\fn QDataStream &QDataStream::operator<<(quint8 i)
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 993a20fcd3..0a429d091a 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -153,6 +153,7 @@ public:
QDataStream &operator>>(quint32 &i);
QDataStream &operator>>(qint64 &i);
QDataStream &operator>>(quint64 &i);
+ QDataStream &operator>>(std::nullptr_t &ptr) { ptr = nullptr; return *this; }
QDataStream &operator>>(bool &i);
QDataStream &operator>>(qfloat16 &f);
@@ -168,6 +169,7 @@ public:
QDataStream &operator<<(quint32 i);
QDataStream &operator<<(qint64 i);
QDataStream &operator<<(quint64 i);
+ QDataStream &operator<<(std::nullptr_t) { return *this; }
QDataStream &operator<<(bool i);
QDataStream &operator<<(qfloat16 f);
QDataStream &operator<<(float f);
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index d5f32a6efd..ee8ef679a9 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -139,7 +139,7 @@ public:
inline QDebug &operator<<(signed short t) { stream->ts << t; return maybeSpace(); }
inline QDebug &operator<<(unsigned short t) { stream->ts << t; return maybeSpace(); }
#ifdef Q_COMPILER_UNICODE_STRINGS
- inline QDebug &operator<<(char16_t t) { return *this << QChar(t); }
+ inline QDebug &operator<<(char16_t t) { return *this << QChar(ushort(t)); }
inline QDebug &operator<<(char32_t t) { putUcs4(t); return maybeSpace(); }
#endif
inline QDebug &operator<<(signed int t) { stream->ts << t; return maybeSpace(); }
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index cb4f5c4b07..9db67f2f9b 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -363,6 +363,7 @@ void QFileSelectorPrivate::updateSelectors()
QStringList QFileSelectorPrivate::platformSelectors()
{
// similar, but not identical to QSysInfo::osType
+ // ### Qt6: remove macOS fallbacks to "mac" and the future compatibility
QStringList ret;
#if defined(Q_OS_WIN)
ret << QStringLiteral("windows");
@@ -380,12 +381,11 @@ QStringList QFileSelectorPrivate::platformSelectors()
# endif
# endif
QString productName = QSysInfo::productType();
-# ifdef Q_OS_MACOS
- if (productName != QLatin1String("osx"))
- ret << QStringLiteral("osx"); // compatibility
-# endif
if (productName != QLatin1String("unknown"))
- ret << productName; // "opensuse", "fedora", "macos", "ios", "android"
+ ret << productName; // "opensuse", "fedora", "osx", "ios", "android"
+# if defined(Q_OS_MACOS)
+ ret << QStringLiteral("macos"); // future compatibility
+# endif
#endif
return ret;
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index b8dca93f61..929db259ec 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2017 Intel Corporation.
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
** Contact: https://www.qt.io/licensing/
@@ -607,25 +608,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
if (!createParents)
return false;
- // we need the cleaned path in order to create the parents
- // and we save errno just in case encodeName needs to load codecs
- int savedErrno = errno;
- bool pathChanged;
- {
- QString cleanName = QDir::cleanPath(dirName);
-
- // Check if the cleaned name is the same or not. If we were given a
- // path with resolvable "../" sections, cleanPath will remove them, but
- // this may change the target dir if one of those segments was a
- // symlink. This operation depends on cleanPath's optimization of
- // returning the original string if it didn't modify anything.
- pathChanged = !dirName.isSharedWith(cleanName);
- if (pathChanged)
- nativeName = QFile::encodeName(cleanName);
- }
-
- errno = savedErrno;
- return createDirectoryWithParents(nativeName, pathChanged);
+ return createDirectoryWithParents(nativeName, false);
}
//static
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index ff865dc9a1..47fb1fb6b8 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -186,9 +186,10 @@ void QLoggingRule::parse(const QStringRef &pattern)
*/
void QLoggingSettingsParser::setContent(const QString &content)
{
- QString content_ = content;
- QTextStream stream(&content_, QIODevice::ReadOnly);
- setContent(stream);
+ _rules.clear();
+ const auto lines = content.splitRef(QLatin1Char('\n'));
+ for (const auto &line : lines)
+ parseNextLine(line);
}
/*!
@@ -198,42 +199,50 @@ void QLoggingSettingsParser::setContent(const QString &content)
void QLoggingSettingsParser::setContent(QTextStream &stream)
{
_rules.clear();
- while (!stream.atEnd()) {
- QString line = stream.readLine();
-
- // Remove all whitespace from line
- line = line.simplified();
- line.remove(QLatin1Char(' '));
+ QString line;
+ while (stream.readLineInto(&line))
+ parseNextLine(QStringRef(&line));
+}
- // comment
- if (line.startsWith(QLatin1Char(';')))
- continue;
+/*!
+ \internal
+ Parses one line of the configuation file
+*/
- if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
- // new section
- _section = line.mid(1, line.size() - 2);
- continue;
- }
+void QLoggingSettingsParser::parseNextLine(QStringRef line)
+{
+ // Remove whitespace at start and end of line:
+ line = line.trimmed();
+
+ // comment
+ if (line.startsWith(QLatin1Char(';')))
+ return;
+
+ if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
+ // new section
+ auto sectionName = line.mid(1, line.size() - 2).trimmed();
+ m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
+ return;
+ }
- if (_section.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0) {
- int equalPos = line.indexOf(QLatin1Char('='));
- if (equalPos != -1) {
- if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
- const QStringRef pattern = line.leftRef(equalPos);
- const QStringRef valueStr = line.midRef(equalPos + 1);
- int value = -1;
- if (valueStr == QLatin1String("true"))
- value = 1;
- else if (valueStr == QLatin1String("false"))
- value = 0;
- QLoggingRule rule(pattern, (value == 1));
- if (rule.flags != 0 && (value != -1))
- _rules.append(rule);
- else
- warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
- } else {
+ if (m_inRulesSection) {
+ int equalPos = line.indexOf(QLatin1Char('='));
+ if (equalPos != -1) {
+ if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
+ const auto pattern = line.left(equalPos).trimmed();
+ const auto valueStr = line.mid(equalPos + 1).trimmed();
+ int value = -1;
+ if (valueStr == QLatin1String("true"))
+ value = 1;
+ else if (valueStr == QLatin1String("false"))
+ value = 0;
+ QLoggingRule rule(pattern, (value == 1));
+ if (rule.flags != 0 && (value != -1))
+ _rules.append(rule);
+ else
warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
- }
+ } else {
+ warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData());
}
}
}
@@ -286,7 +295,7 @@ void QLoggingRegistry::init()
if (!rulesSrc.isEmpty()) {
QTextStream stream(rulesSrc);
QLoggingSettingsParser parser;
- parser.setSection(QStringLiteral("Rules"));
+ parser.setImplicitRulesSection(true);
parser.setContent(stream);
er += parser.rules();
}
@@ -350,7 +359,7 @@ void QLoggingRegistry::unregisterCategory(QLoggingCategory *cat)
void QLoggingRegistry::setApiRules(const QString &content)
{
QLoggingSettingsParser parser;
- parser.setSection(QStringLiteral("Rules"));
+ parser.setImplicitRulesSection(true);
parser.setContent(content);
if (qtLoggingDebug())
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index 23740c4955..69fc6ea4ec 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -93,7 +93,7 @@ Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE);
class Q_AUTOTEST_EXPORT QLoggingSettingsParser
{
public:
- void setSection(const QString &section) { _section = section; }
+ void setImplicitRulesSection(bool inRulesSection) { m_inRulesSection = inRulesSection; }
void setContent(const QString &content);
void setContent(QTextStream &stream);
@@ -101,7 +101,10 @@ public:
QVector<QLoggingRule> rules() const { return _rules; }
private:
- QString _section;
+ void parseNextLine(QStringRef line);
+
+private:
+ bool m_inRulesSection = false;
QVector<QLoggingRule> _rules;
};
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index e72773d7a4..251f68c9b4 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -122,6 +122,10 @@ QT_BEGIN_NAMESPACE
#if !defined(Q_OS_DARWIN)
+QT_BEGIN_INCLUDE_NAMESPACE
+extern char **environ;
+QT_END_INCLUDE_NAMESPACE
+
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index c16825a033..0bb8707ff9 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -196,7 +196,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
- QUrl adjusted(FormattingOptions options) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QUrl adjusted(FormattingOptions options) const;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@@ -255,7 +255,7 @@ public:
QString fragment(ComponentFormattingOptions options = PrettyDecoded) const;
void setFragment(const QString &fragment, ParsingMode mode = TolerantMode);
- QUrl resolved(const QUrl &relative) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QUrl resolved(const QUrl &relative) const;
bool isRelative() const;
bool isParentOf(const QUrl &url) const;
diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp
index 41d55c8fde..60154328c2 100644
--- a/src/corelib/kernel/qjni.cpp
+++ b/src/corelib/kernel/qjni.cpp
@@ -64,9 +64,7 @@ static QString qt_convertJString(jstring string)
static inline bool exceptionCheckAndClear(JNIEnv *env)
{
if (Q_UNLIKELY(env->ExceptionCheck())) {
-#ifdef QT_DEBUG
env->ExceptionDescribe();
-#endif // QT_DEBUG
env->ExceptionClear();
return true;
}
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index fc8d7dcfea..b75f2ad9dc 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -1350,6 +1350,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QJsonDocument:
return false;
case QMetaType::Nullptr:
+ stream << *static_cast<const std::nullptr_t *>(data);
return true;
case QMetaType::Long:
stream << qlonglong(*static_cast<const long *>(data));
@@ -1573,6 +1574,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QJsonDocument:
return false;
case QMetaType::Nullptr:
+ stream >> *static_cast<std::nullptr_t *>(data);
return true;
case QMetaType::Long: {
qlonglong l;
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index c908e7cdbc..e636c6fe52 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -649,6 +649,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QVariant::Bool:
*ba = QByteArray(d->data.b ? "true" : "false");
break;
+ case QVariant::Uuid:
+ *ba = v_cast<QUuid>(d)->toByteArray();
+ break;
default:
#ifndef QT_NO_QOBJECT
{
@@ -916,6 +919,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QVariant::String:
*static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
break;
+ case QVariant::ByteArray:
+ *static_cast<QUuid *>(result) = QUuid(*v_cast<QByteArray>(d));
+ break;
default:
return false;
}
@@ -2526,8 +2532,9 @@ QRegularExpression QVariant::toRegularExpression() const
/*!
\since 5.0
- Returns the variant as a QUuid if the variant has userType() \l
- QUuid; otherwise returns a default constructed QUuid.
+ Returns the variant as a QUuid if the variant has type()
+ \l QMetaType::QUuid, \l QMetaType::QByteArray or \l QMetaType::QString;
+ otherwise returns a default-constructed QUuid.
\sa canConvert(), convert()
*/
@@ -2874,7 +2881,8 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String,
/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool
- | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong,
+ | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
+ | 1 << QVariant::Uuid,
/*QBitArray*/ 0,
@@ -2910,7 +2918,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QEasingCurve*/ 0,
-/*QUuid*/ 1 << QVariant::String
+/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray,
};
static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix);
@@ -2965,7 +2973,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject)
\l QMetaType::UInt, \l QMetaType::ULongLong
\row \li \l QMetaType::QByteArray \li \l QMetaType::Double,
\l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString,
- \l QMetaType::UInt, \l QMetaType::ULongLong
+ \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid
\row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int,
\l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong
\row \li \l QMetaType::QColor \li \l QMetaType::QString
@@ -2995,7 +3003,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject)
\l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double,
\l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence,
\l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime,
- \l QMetaType::UInt, \l QMetaType::ULongLong
+ \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid
\row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList,
\l QMetaType::QString (if the list contains exactly one item)
\row \li \l QMetaType::QTime \li \l QMetaType::QString
@@ -3005,6 +3013,7 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject)
\row \li \l QMetaType::ULongLong \li \l QMetaType::Bool,
\l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int,
\l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt
+ \row \li \l QMetaType::QUuid \li \l QMetaType::QByteArray, \l QMetaType::QString
\endtable
A QVariant containing a pointer to a type derived from QObject will also return true for this
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index 74a8c28fc8..09b7f96f48 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -88,7 +88,7 @@ public:
QT_DEPRECATED_X("use tryTake(), but note the different deletion rules")
void cancel(QRunnable *runnable);
#endif
- bool tryTake(QRunnable *runnable) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT bool tryTake(QRunnable *runnable);
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h
index bc20932cca..88f0cfb0ea 100644
--- a/src/corelib/tools/qarraydata.h
+++ b/src/corelib/tools/qarraydata.h
@@ -112,12 +112,10 @@ struct Q_CORE_EXPORT QArrayData
return result;
}
- static QArrayData *allocate(size_t objectSize, size_t alignment,
- size_t capacity, AllocationOptions options = Default)
- Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize,
- size_t newCapacity, AllocationOptions newOptions = Default)
- Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QArrayData *allocate(size_t objectSize, size_t alignment,
+ size_t capacity, AllocationOptions options = Default) Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT static QArrayData *reallocateUnaligned(QArrayData *data, size_t objectSize,
+ size_t newCapacity, AllocationOptions newOptions = Default) Q_DECL_NOTHROW;
static void deallocate(QArrayData *data, size_t objectSize,
size_t alignment) Q_DECL_NOTHROW;
@@ -217,8 +215,8 @@ struct QTypedArrayData
class AlignmentDummy { QArrayData header; T data; };
- static QTypedArrayData *allocate(size_t capacity,
- AllocationOptions options = Default) Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT static QTypedArrayData *allocate(size_t capacity,
+ AllocationOptions options = Default)
{
Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData));
return static_cast<QTypedArrayData *>(QArrayData::allocate(sizeof(T),
diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h
index b97dde5a61..51cfa6e849 100644
--- a/src/corelib/tools/qarraydatapointer.h
+++ b/src/corelib/tools/qarraydatapointer.h
@@ -174,7 +174,7 @@ public:
}
private:
- Data *clone(QArrayData::AllocationOptions options) const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Data *clone(QArrayData::AllocationOptions options) const
{
Data *x = Data::allocate(d->detachCapacity(d->size), options);
Q_CHECK_PTR(x);
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 4763afafe1..453f28f39f 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -231,10 +231,10 @@ public:
int count(const char *a) const;
int count(const QByteArray &a) const;
- QByteArray left(int len) const Q_REQUIRED_RESULT;
- QByteArray right(int len) const Q_REQUIRED_RESULT;
- QByteArray mid(int index, int len = -1) const Q_REQUIRED_RESULT;
- QByteArray chopped(int len) const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray left(int len) const;
+ Q_REQUIRED_RESULT QByteArray right(int len) const;
+ Q_REQUIRED_RESULT QByteArray mid(int index, int len = -1) const;
+ Q_REQUIRED_RESULT QByteArray chopped(int len) const
{ Q_ASSERT(len >= 0); Q_ASSERT(len <= size()); return left(size() - len); }
bool startsWith(const QByteArray &a) const;
@@ -249,41 +249,41 @@ public:
void chop(int n);
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT_pushed
# endif
- Q_ALWAYS_INLINE QByteArray toLower() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() const &
{ return toLower_helper(*this); }
- Q_ALWAYS_INLINE QByteArray toLower() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toLower() &&
{ return toLower_helper(*this); }
- Q_ALWAYS_INLINE QByteArray toUpper() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() const &
{ return toUpper_helper(*this); }
- Q_ALWAYS_INLINE QByteArray toUpper() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray toUpper() &&
{ return toUpper_helper(*this); }
- Q_ALWAYS_INLINE QByteArray trimmed() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() const &
{ return trimmed_helper(*this); }
- Q_ALWAYS_INLINE QByteArray trimmed() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray trimmed() &&
{ return trimmed_helper(*this); }
- Q_ALWAYS_INLINE QByteArray simplified() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() const &
{ return simplified_helper(*this); }
- Q_ALWAYS_INLINE QByteArray simplified() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QByteArray simplified() &&
{ return simplified_helper(*this); }
# ifdef Q_REQUIRED_RESULT_pushed
# pragma pop_macro("Q_REQUIRED_RESULT")
# endif
#else
- QByteArray toLower() const Q_REQUIRED_RESULT;
- QByteArray toUpper() const Q_REQUIRED_RESULT;
- QByteArray trimmed() const Q_REQUIRED_RESULT;
- QByteArray simplified() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QByteArray toLower() const;
+ Q_REQUIRED_RESULT QByteArray toUpper() const;
+ Q_REQUIRED_RESULT QByteArray trimmed() const;
+ Q_REQUIRED_RESULT QByteArray simplified() const;
#endif
- QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT;
- QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QByteArray leftJustified(int width, char fill = ' ', bool truncate = false) const;
+ Q_REQUIRED_RESULT QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const;
QByteArray &prepend(char c);
inline QByteArray &prepend(int count, char c);
@@ -318,7 +318,7 @@ public:
QList<QByteArray> split(char sep) const;
- QByteArray repeated(int times) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QByteArray repeated(int times) const;
#ifndef QT_NO_CAST_TO_ASCII
QT_ASCII_CAST_WARN QByteArray &append(const QString &s);
@@ -368,16 +368,16 @@ public:
QByteArray &setNum(double, char f = 'g', int prec = 6);
QByteArray &setRawData(const char *a, uint n); // ### Qt 6: use an int
- static QByteArray number(int, int base = 10) Q_REQUIRED_RESULT;
- static QByteArray number(uint, int base = 10) Q_REQUIRED_RESULT;
- static QByteArray number(qlonglong, int base = 10) Q_REQUIRED_RESULT;
- static QByteArray number(qulonglong, int base = 10) Q_REQUIRED_RESULT;
- static QByteArray number(double, char f = 'g', int prec = 6) Q_REQUIRED_RESULT;
- static QByteArray fromRawData(const char *, int size) Q_REQUIRED_RESULT;
- static QByteArray fromBase64(const QByteArray &base64, Base64Options options) Q_REQUIRED_RESULT;
- static QByteArray fromBase64(const QByteArray &base64) Q_REQUIRED_RESULT; // ### Qt6 merge with previous
- static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT;
- static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QByteArray number(int, int base = 10);
+ Q_REQUIRED_RESULT static QByteArray number(uint, int base = 10);
+ Q_REQUIRED_RESULT static QByteArray number(qlonglong, int base = 10);
+ Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10);
+ Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6);
+ Q_REQUIRED_RESULT static QByteArray fromRawData(const char *, int size);
+ Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options);
+ Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous
+ Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded);
+ Q_REQUIRED_RESULT static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%');
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QByteArray fromCFData(CFDataRef data);
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index ba1dacff8f..7ab7c0e2df 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -2317,10 +2317,11 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
tm local;
bool valid = false;
-#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// localtime() is required to work as if tzset() was called before it.
// localtime_r() does not have this requirement, so make an explicit call.
+ // The explicit call should also request the timezone info be re-parsed.
qt_tzset();
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// Use the reentrant version of localtime() where available
// as is thread-safe and doesn't use a shared static data area
tm *res = 0;
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index e3552f5c82..815fa12b23 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -106,9 +106,9 @@ QT_DEPRECATED inline bool setYMD(int y, int m, int d)
#endif // < Qt 6
void getDate(int *year, int *month, int *day) const;
- QDate addDays(qint64 days) const Q_REQUIRED_RESULT;
- QDate addMonths(int months) const Q_REQUIRED_RESULT;
- QDate addYears(int years) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QDate addDays(qint64 days) const;
+ Q_REQUIRED_RESULT QDate addMonths(int months) const;
+ Q_REQUIRED_RESULT QDate addYears(int years) const;
qint64 daysTo(const QDate &) const;
Q_DECL_CONSTEXPR bool operator==(const QDate &other) const { return jd == other.jd; }
@@ -172,9 +172,9 @@ public:
#endif
bool setHMS(int h, int m, int s, int ms = 0);
- QTime addSecs(int secs) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QTime addSecs(int secs) const;
int secsTo(const QTime &) const;
- QTime addMSecs(int ms) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QTime addMSecs(int ms) const;
int msecsTo(const QTime &) const;
Q_DECL_CONSTEXPR bool operator==(const QTime &other) const { return mds == other.mds; }
@@ -306,11 +306,11 @@ public:
#endif
QString toString(QStringView format) const;
#endif
- QDateTime addDays(qint64 days) const Q_REQUIRED_RESULT;
- QDateTime addMonths(int months) const Q_REQUIRED_RESULT;
- QDateTime addYears(int years) const Q_REQUIRED_RESULT;
- QDateTime addSecs(qint64 secs) const Q_REQUIRED_RESULT;
- QDateTime addMSecs(qint64 msecs) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QDateTime addDays(qint64 days) const;
+ Q_REQUIRED_RESULT QDateTime addMonths(int months) const;
+ Q_REQUIRED_RESULT QDateTime addYears(int years) const;
+ Q_REQUIRED_RESULT QDateTime addSecs(qint64 secs) const;
+ Q_REQUIRED_RESULT QDateTime addMSecs(qint64 msecs) const;
QDateTime toTimeSpec(Qt::TimeSpec spec) const;
inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); }
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h
index 5b5ca3b4c8..6361c1af9f 100644
--- a/src/corelib/tools/qline.h
+++ b/src/corelib/tools/qline.h
@@ -73,10 +73,10 @@ public:
inline void translate(const QPoint &p);
inline void translate(int dx, int dy);
- Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const;
- Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPoint center() const;
inline void setP1(const QPoint &p1);
inline void setP2(const QPoint &p2);
@@ -221,7 +221,7 @@ public:
Q_DECL_CONSTEXPR inline QLineF(qreal x1, qreal y1, qreal x2, qreal y2);
Q_DECL_CONSTEXPR inline QLineF(const QLine &line) : pt1(line.p1()), pt2(line.p2()) { }
- static QLineF fromPolar(qreal length, qreal angle) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QLineF fromPolar(qreal length, qreal angle);
Q_DECL_CONSTEXPR bool isNull() const;
@@ -245,8 +245,8 @@ public:
qreal angleTo(const QLineF &l) const;
- QLineF unitVector() const Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QLineF normalVector() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QLineF unitVector() const;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF normalVector() const;
// ### Qt 6: rename intersects() or intersection() and rename IntersectType IntersectionType
IntersectType intersect(const QLineF &l, QPointF *intersectionPoint) const;
@@ -257,10 +257,10 @@ public:
inline void translate(const QPointF &p);
inline void translate(qreal dx, qreal dy);
- Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const;
- Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QPointF center() const;
inline void setP1(const QPointF &p1);
inline void setP2(const QPointF &p2);
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index bad1481575..d5a024177d 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -38,13 +38,13 @@
**
****************************************************************************/
+#include "qglobal.h"
+
#if !defined(QWS) && defined(Q_OS_MAC)
# include "private/qcore_mac_p.h"
# include <CoreFoundation/CoreFoundation.h>
#endif
-#include "qglobal.h"
-
#include "qplatformdefs.h"
#include "qdatastream.h"
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 3ee6ab8c58..a3b11eddcf 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -209,8 +209,10 @@ struct QMapData : public QMapDataBase
Node *root() const { return static_cast<Node *>(header.left); }
- const Node *end() const { return static_cast<const Node *>(&header); }
- Node *end() { return static_cast<Node *>(&header); }
+ // using reinterpret_cast because QMapDataBase::header is not
+ // actually a QMapNode.
+ const Node *end() const { return reinterpret_cast<const Node *>(&header); }
+ Node *end() { return reinterpret_cast<Node *>(&header); }
const Node *begin() const { if (root()) return static_cast<const Node*>(mostLeftNode); return end(); }
Node *begin() { if (root()) return static_cast<Node*>(mostLeftNode); return end(); }
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 7b1004897a..0f3e0c3517 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -94,7 +94,7 @@ public:
friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal);
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW;
#endif
private:
@@ -256,8 +256,8 @@ public:
Q_DECL_CONSTEXPR QPoint toPoint() const;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT CGPoint toCGPoint() const Q_DECL_NOTHROW;
#endif
private:
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index 4030cccbd5..19ff87b420 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -70,7 +70,7 @@ public:
Q_DECL_CONSTEXPR inline int top() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline int right() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline int bottom() const Q_DECL_NOTHROW;
- QRect normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QRect normalized() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline int x() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline int y() const Q_DECL_NOTHROW;
@@ -104,9 +104,9 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void translate(int dx, int dy) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPoint &p) Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(int dx, int dy) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect translated(const QPoint &p) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect transposed() const Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void moveTo(int x, int t) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPoint &p) Q_DECL_NOTHROW;
@@ -118,7 +118,7 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void getCoords(int *x1, int *y1, int *x2, int *y2) const;
Q_DECL_RELAXED_CONSTEXPR inline void adjust(int x1, int y1, int x2, int y2) Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect adjusted(int x1, int y1, int x2, int y2) const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline QSize size() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline int width() const Q_DECL_NOTHROW;
@@ -136,8 +136,8 @@ public:
bool contains(const QPoint &p, bool proper=false) const Q_DECL_NOTHROW;
inline bool contains(int x, int y) const Q_DECL_NOTHROW;
inline bool contains(int x, int y, bool proper) const Q_DECL_NOTHROW;
- inline QRect united(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT inline QRect united(const QRect &other) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT inline QRect intersected(const QRect &other) const Q_DECL_NOTHROW;
bool intersects(const QRect &r) const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const Q_DECL_NOTHROW;
@@ -146,15 +146,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline QRect &operator-=(const QMargins &margins) Q_DECL_NOTHROW;
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); }
- QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); }
+ Q_REQUIRED_RESULT QT_DEPRECATED QRect unite(const QRect &r) const Q_DECL_NOTHROW { return united(r); }
+ Q_REQUIRED_RESULT QT_DEPRECATED QRect intersect(const QRect &r) const Q_DECL_NOTHROW { return intersected(r); }
#endif
friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW;
friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW;
#endif
private:
@@ -520,7 +520,7 @@ public:
Q_DECL_CONSTEXPR inline bool isNull() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOTHROW;
- QRectF normalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QRectF normalized() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline qreal left() const Q_DECL_NOTHROW { return xp; }
Q_DECL_CONSTEXPR inline qreal top() const Q_DECL_NOTHROW { return yp; }
@@ -560,10 +560,10 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void translate(qreal dx, qreal dy) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void translate(const QPointF &p) Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(qreal dx, qreal dy) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF translated(const QPointF &p) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF transposed() const Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void moveTo(qreal x, qreal y) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void moveTo(const QPointF &p) Q_DECL_NOTHROW;
@@ -575,7 +575,7 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const;
Q_DECL_RELAXED_CONSTEXPR inline void adjust(qreal x1, qreal y1, qreal x2, qreal y2) Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline QSizeF size() const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline qreal width() const Q_DECL_NOTHROW;
@@ -592,8 +592,8 @@ public:
bool contains(const QRectF &r) const Q_DECL_NOTHROW;
bool contains(const QPointF &p) const Q_DECL_NOTHROW;
inline bool contains(qreal x, qreal y) const Q_DECL_NOTHROW;
- inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT inline QRectF united(const QRectF &other) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT inline QRectF intersected(const QRectF &other) const Q_DECL_NOTHROW;
bool intersects(const QRectF &r) const Q_DECL_NOTHROW;
Q_DECL_CONSTEXPR inline QRectF marginsAdded(const QMarginsF &margins) const Q_DECL_NOTHROW;
@@ -602,19 +602,19 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline QRectF &operator-=(const QMarginsF &margins) Q_DECL_NOTHROW;
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return united(r); }
- QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW Q_REQUIRED_RESULT { return intersected(r); }
+ Q_REQUIRED_RESULT QT_DEPRECATED QRectF unite(const QRectF &r) const Q_DECL_NOTHROW { return united(r); }
+ Q_REQUIRED_RESULT QT_DEPRECATED QRectF intersect(const QRectF &r) const Q_DECL_NOTHROW { return intersected(r); }
#endif
friend Q_DECL_CONSTEXPR inline bool operator==(const QRectF &, const QRectF &) Q_DECL_NOTHROW;
friend Q_DECL_CONSTEXPR inline bool operator!=(const QRectF &, const QRectF &) Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT QRect toAlignedRect() const Q_DECL_NOTHROW;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT CGRect toCGRect() const Q_DECL_NOTHROW;
#endif
private:
diff --git a/src/corelib/tools/qregularexpression.cpp b/src/corelib/tools/qregularexpression.cpp
index 8ad907f72b..86bc99716d 100644
--- a/src/corelib/tools/qregularexpression.cpp
+++ b/src/corelib/tools/qregularexpression.cpp
@@ -445,19 +445,25 @@ QT_BEGIN_NAMESPACE
Other differences are outlined below.
- \section2 Exact matching
+ \section2 Porting from QRegExp::exactMatch()
QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched
a regular expression against a subject string, and it implemented partial
- matching. In fact, if an exact match was not found, one could still find
- out how much of the subject string was matched by the regular expression
- by calling QRegExp::matchedLength(). If the returned length was equal
- to the subject string's length, then one could desume that a partial match
- was found.
+ matching.
- QRegularExpression supports partial matching explicitly by means of the
- appropriate MatchType. If instead you simply want to be sure that the
- subject string matches the regular expression exactly, you can wrap the
+ \section3 Porting from QRegExp's Exact Matching
+
+ Exact matching indicates whether the regular expression matches the entire
+ subject string. For example, the classes yield on the subject string \c{"abc123"}:
+
+ \table
+ \header \li \li QRegExp::exactMatch() \li QRegularExpressionMatch::hasMatch()
+ \row \li \c{"\\d+"} \li \b false \li \b true
+ \row \li \c{"[a-z]+\\d+"} \li \b true \li \b true
+ \endtable
+
+ Exact matching is not reflected in QRegularExpression. If you want to be
+ sure that the subject string matches the regular expression exactly, you can wrap the
pattern between a couple of anchoring expressions. Simply
putting the pattern between the \c{^} and the \c{$} anchors is enough
in most cases:
@@ -479,6 +485,17 @@ QT_BEGIN_NAMESPACE
Note the usage of the non-capturing group in order to preserve the meaning
of the branch operator inside the pattern.
+ \section3 Porting from QRegExp's Partial Matching
+
+ When using QRegExp::exactMatch(), if an exact match was not found, one
+ could still find out how much of the subject string was matched by the
+ regular expression by calling QRegExp::matchedLength(). If the returned length
+ was equal to the subject string's length, then one could conclude that a partial
+ match was found.
+
+ QRegularExpression supports partial matching explicitly by means of the
+ appropriate MatchType.
+
\section2 Global matching
Due to limitations of the QRegExp API it was impossible to implement global
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 0d42c8a212..15573c5588 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -260,6 +260,7 @@ namespace QtSharedPointer {
internalSafetyCheckRemove(self);
deleter(self);
}
+ static void noDeleter(ExternalRefCountData *) { }
static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy)
{
@@ -433,11 +434,13 @@ public:
# else
typename Private::DestroyerFn destroy = &Private::deleter;
# endif
+ typename Private::DestroyerFn noDestroy = &Private::noDeleter;
QSharedPointer result(Qt::Uninitialized);
- result.d = Private::create(&result.value, destroy);
+ result.d = Private::create(&result.value, noDestroy);
// now initialize the data
new (result.data()) T(std::forward<Args>(arguments)...);
+ result.d->destroyer = destroy;
result.d->setQObjectShared(result.value, true);
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
internalSafetyCheckAdd(result.d, result.value);
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 59a8dd9d0c..725b6b6765 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -166,10 +166,11 @@
# define __MIPS_DSPR2__
# endif
#elif (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \
- || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \
+ || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && Q_CC_GNU >= 409) \
+ || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 308)) \
&& !defined(QT_BOOTSTRAPPED)
# define QT_COMPILER_SUPPORTS_SIMD_ALWAYS
-# define QT_COMPILER_SUPPORTS_HERE(x) QT_COMPILER_SUPPORTS(x)
+# define QT_COMPILER_SUPPORTS_HERE(x) ((__ ## x ## __) || QT_COMPILER_SUPPORTS(x))
# if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
/* GCC requires attributes for a function */
# define QT_FUNCTION_TARGET(x) __attribute__((__target__(QT_FUNCTION_TARGET_STRING_ ## x)))
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index cd5f8adbf5..bb29dca7c4 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -64,15 +64,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(int w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(int h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize transposed() const Q_DECL_NOTHROW;
inline void scale(int w, int h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSize &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QSize scaled(int w, int h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT QSize scaled(const QSize &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize expandedTo(const QSize &) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSize boundedTo(const QSize &) const Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline int &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline int &rheight() Q_DECL_NOTHROW;
@@ -91,7 +91,7 @@ public:
friend inline const QSize operator/(const QSize &, qreal);
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW;
#endif
private:
@@ -228,15 +228,15 @@ public:
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal w) Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal h) Q_DECL_NOTHROW;
void transpose() Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF transposed() const Q_DECL_NOTHROW;
inline void scale(qreal w, qreal h, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
inline void scale(const QSizeF &s, Qt::AspectRatioMode mode) Q_DECL_NOTHROW;
- QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QSizeF scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT QSizeF scaled(const QSizeF &s, Qt::AspectRatioMode mode) const Q_DECL_NOTHROW;
- Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF expandedTo(const QSizeF &) const Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT Q_DECL_CONSTEXPR inline QSizeF boundedTo(const QSizeF &) const Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rwidth() Q_DECL_NOTHROW;
Q_DECL_RELAXED_CONSTEXPR inline qreal &rheight() Q_DECL_NOTHROW;
@@ -257,8 +257,8 @@ public:
Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW;
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
- static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
- CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW;
+ Q_REQUIRED_RESULT CGSize toCGSize() const Q_DECL_NOTHROW;
#endif
private:
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index f9761ac11a..5130ee99f4 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -312,58 +312,58 @@ public:
const QChar operator[](uint i) const;
QCharRef operator[](uint i);
- inline QChar front() const Q_REQUIRED_RESULT { return at(0); }
- inline QCharRef front() Q_REQUIRED_RESULT;
- inline QChar back() const Q_REQUIRED_RESULT { return at(size() - 1); }
- inline QCharRef back() Q_REQUIRED_RESULT;
-
- QString arg(qlonglong a, int fieldwidth=0, int base=10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(qulonglong a, int fieldwidth=0, int base=10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(long a, int fieldwidth=0, int base=10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(ulong a, int fieldwidth=0, int base=10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(int a, int fieldWidth = 0, int base = 10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(uint a, int fieldWidth = 0, int base = 10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(short a, int fieldWidth = 0, int base = 10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(ushort a, int fieldWidth = 0, int base = 10,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(char a, int fieldWidth = 0,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(QChar a, int fieldWidth = 0,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT inline QChar front() const { return at(0); }
+ Q_REQUIRED_RESULT inline QCharRef front();
+ Q_REQUIRED_RESULT inline QChar back() const { return at(size() - 1); }
+ Q_REQUIRED_RESULT inline QCharRef back();
+
+ Q_REQUIRED_RESULT QString arg(qlonglong a, int fieldwidth=0, int base=10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(qulonglong a, int fieldwidth=0, int base=10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(long a, int fieldwidth=0, int base=10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(ulong a, int fieldwidth=0, int base=10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(int a, int fieldWidth = 0, int base = 10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(uint a, int fieldWidth = 0, int base = 10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(short a, int fieldWidth = 0, int base = 10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(ushort a, int fieldWidth = 0, int base = 10,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(double a, int fieldWidth = 0, char fmt = 'g', int prec = -1,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(char a, int fieldWidth = 0,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(QChar a, int fieldWidth = 0,
+ QChar fillChar = QLatin1Char(' ')) const;
#if QT_STRINGVIEW_LEVEL < 2
- QString arg(const QString &a, int fieldWidth = 0,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString arg(const QString &a, int fieldWidth = 0,
+ QChar fillChar = QLatin1Char(' ')) const;
#endif
- QString arg(QStringView a, int fieldWidth = 0,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(QLatin1String a, int fieldWidth = 0,
- QChar fillChar = QLatin1Char(' ')) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
- const QString &a4) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
- const QString &a4, const QString &a5) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
- const QString &a4, const QString &a5, const QString &a6) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
+ Q_REQUIRED_RESULT QString arg(QStringView a, int fieldWidth = 0,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(QLatin1String a, int fieldWidth = 0,
+ QChar fillChar = QLatin1Char(' ')) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
+ const QString &a4) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
+ const QString &a4, const QString &a5) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
+ const QString &a4, const QString &a5, const QString &a6) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
const QString &a4, const QString &a5, const QString &a6,
- const QString &a7) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
+ const QString &a7) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
const QString &a4, const QString &a5, const QString &a6,
- const QString &a7, const QString &a8) const Q_REQUIRED_RESULT;
- QString arg(const QString &a1, const QString &a2, const QString &a3,
+ const QString &a7, const QString &a8) const;
+ Q_REQUIRED_RESULT QString arg(const QString &a1, const QString &a2, const QString &a3,
const QString &a4, const QString &a5, const QString &a6,
- const QString &a7, const QString &a8, const QString &a9) const Q_REQUIRED_RESULT;
+ const QString &a7, const QString &a8, const QString &a9) const;
QString &vsprintf(const char *format, va_list ap) Q_ATTRIBUTE_FORMAT_PRINTF(2, 0);
QString &sprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
@@ -425,16 +425,16 @@ public:
#ifndef QT_NO_REGULAREXPRESSION
QString section(const QRegularExpression &re, int start, int end = -1, SectionFlags flags = SectionDefault) const;
#endif
- QString left(int n) const Q_REQUIRED_RESULT;
- QString right(int n) const Q_REQUIRED_RESULT;
- QString mid(int position, int n = -1) const Q_REQUIRED_RESULT;
- QString chopped(int n) const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QString left(int n) const;
+ Q_REQUIRED_RESULT QString right(int n) const;
+ Q_REQUIRED_RESULT QString mid(int position, int n = -1) const;
+ Q_REQUIRED_RESULT QString chopped(int n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return left(size() - n); }
- QStringRef leftRef(int n) const Q_REQUIRED_RESULT;
- QStringRef rightRef(int n) const Q_REQUIRED_RESULT;
- QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QStringRef leftRef(int n) const;
+ Q_REQUIRED_RESULT QStringRef rightRef(int n) const;
+ Q_REQUIRED_RESULT QStringRef midRef(int position, int n = -1) const;
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -445,48 +445,48 @@ public:
bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT;
- QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString leftJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
+ Q_REQUIRED_RESULT QString rightJustified(int width, QChar fill = QLatin1Char(' '), bool trunc = false) const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
-# if defined(Q_CC_GNU)
+# if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
// required due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61941
# pragma push_macro("Q_REQUIRED_RESULT")
# undef Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT_pushed
# endif
- Q_ALWAYS_INLINE QString toLower() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() const &
{ return toLower_helper(*this); }
- Q_ALWAYS_INLINE QString toLower() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toLower() &&
{ return toLower_helper(*this); }
- Q_ALWAYS_INLINE QString toUpper() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() const &
{ return toUpper_helper(*this); }
- Q_ALWAYS_INLINE QString toUpper() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toUpper() &&
{ return toUpper_helper(*this); }
- Q_ALWAYS_INLINE QString toCaseFolded() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() const &
{ return toCaseFolded_helper(*this); }
- Q_ALWAYS_INLINE QString toCaseFolded() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString toCaseFolded() &&
{ return toCaseFolded_helper(*this); }
- Q_ALWAYS_INLINE QString trimmed() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() const &
{ return trimmed_helper(*this); }
- Q_ALWAYS_INLINE QString trimmed() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString trimmed() &&
{ return trimmed_helper(*this); }
- Q_ALWAYS_INLINE QString simplified() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() const &
{ return simplified_helper(*this); }
- Q_ALWAYS_INLINE QString simplified() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT Q_ALWAYS_INLINE QString simplified() &&
{ return simplified_helper(*this); }
# ifdef Q_REQUIRED_RESULT_pushed
# pragma pop_macro("Q_REQUIRED_RESULT")
# endif
#else
- QString toLower() const Q_REQUIRED_RESULT;
- QString toUpper() const Q_REQUIRED_RESULT;
- QString toCaseFolded() const Q_REQUIRED_RESULT;
- QString trimmed() const Q_REQUIRED_RESULT;
- QString simplified() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString toLower() const;
+ Q_REQUIRED_RESULT QString toUpper() const;
+ Q_REQUIRED_RESULT QString toCaseFolded() const;
+ Q_REQUIRED_RESULT QString trimmed() const;
+ Q_REQUIRED_RESULT QString simplified() const;
#endif
- QString toHtmlEscaped() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString toHtmlEscaped() const;
QString &insert(int i, QChar c);
QString &insert(int i, const QChar *uc, int len);
@@ -545,21 +545,21 @@ public:
enum SplitBehavior { KeepEmptyParts, SkipEmptyParts };
- 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;
+ 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;
#ifndef QT_NO_REGEXP
- 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;
+ 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
- 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;
+ 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
enum NormalizationForm {
NormalizationForm_D,
@@ -567,31 +567,31 @@ public:
NormalizationForm_KD,
NormalizationForm_KC
};
- QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString normalized(NormalizationForm mode, QChar::UnicodeVersion version = QChar::Unicode_Unassigned) const;
- QString repeated(int times) const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QString repeated(int times) const;
const ushort *utf16() const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QSTRING_COMPAT_CPP) && !defined(Q_CLANG_QDOC)
- QByteArray toLatin1() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toLatin1() const &
{ return toLatin1_helper(*this); }
- QByteArray toLatin1() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toLatin1() &&
{ return toLatin1_helper_inplace(*this); }
- QByteArray toUtf8() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toUtf8() const &
{ return toUtf8_helper(*this); }
- QByteArray toUtf8() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toUtf8() &&
{ return toUtf8_helper(*this); }
- QByteArray toLocal8Bit() const & Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toLocal8Bit() const &
{ return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
- QByteArray toLocal8Bit() && Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toLocal8Bit() &&
{ return toLocal8Bit_helper(isNull() ? nullptr : constData(), size()); }
#else
- QByteArray toLatin1() const Q_REQUIRED_RESULT;
- QByteArray toUtf8() const Q_REQUIRED_RESULT;
- QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QByteArray toLatin1() const;
+ Q_REQUIRED_RESULT QByteArray toUtf8() const;
+ Q_REQUIRED_RESULT QByteArray toLocal8Bit() const;
#endif
- QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QVector<uint> toUcs4() const;
// note - this are all inline so we can benefit from strlen() compile time optimizations
static inline QString fromLatin1(const char *str, int size = -1)
@@ -629,12 +629,12 @@ public:
{ return fromLatin1(str, size); }
QT_DEPRECATED static inline QString fromAscii(const QByteArray &str)
{ return fromLatin1(str); }
- QByteArray toAscii() const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QByteArray toAscii() const
{ return toLatin1(); }
#endif
inline int toWCharArray(wchar_t *array) const;
- static inline QString fromWCharArray(const wchar_t *string, int size = -1) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT static inline QString fromWCharArray(const wchar_t *string, int size = -1);
QString &setRawData(const QChar *unicode, int size);
QString &setUnicode(const QChar *unicode, int size);
@@ -823,7 +823,7 @@ public:
static inline QString fromStdWString(const std::wstring &s);
inline std::wstring toStdWString() const;
-#if defined(Q_COMPILER_UNICODE_STRINGS) || defined(Q_QDOC)
+#if defined(Q_STDLIB_UNICODE_STRINGS) || defined(Q_QDOC)
static inline QString fromStdU16String(const std::u16string &s);
inline std::u16string toStdU16String() const;
static inline QString fromStdU32String(const std::u32string &s);
@@ -1409,7 +1409,7 @@ inline std::wstring QString::toStdWString() const
inline QString QString::fromStdWString(const std::wstring &s)
{ return fromWCharArray(s.data(), int(s.size())); }
-#if defined(Q_COMPILER_UNICODE_STRINGS)
+#if defined(Q_STDLIB_UNICODE_STRINGS)
inline QString QString::fromStdU16String(const std::u16string &s)
{ return fromUtf16(s.data(), int(s.size())); }
@@ -1495,15 +1495,15 @@ public:
int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- 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 Q_REQUIRED_RESULT;
+ 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;
- QStringRef left(int n) const Q_REQUIRED_RESULT;
- QStringRef right(int n) const Q_REQUIRED_RESULT;
- QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT;
- QStringRef chopped(int n) const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QStringRef left(int n) const;
+ Q_REQUIRED_RESULT QStringRef right(int n) const;
+ Q_REQUIRED_RESULT QStringRef mid(int pos, int n = -1) const;
+ Q_REQUIRED_RESULT QStringRef chopped(int n) const
{ Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return left(size() - n); }
void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); }
@@ -1550,13 +1550,13 @@ public:
inline const_reverse_iterator crend() const { return rend(); }
#if QT_DEPRECATED_SINCE(5, 0)
- QT_DEPRECATED QByteArray toAscii() const Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT QT_DEPRECATED QByteArray toAscii() const
{ return toLatin1(); }
#endif
- QByteArray toLatin1() const Q_REQUIRED_RESULT;
- QByteArray toUtf8() const Q_REQUIRED_RESULT;
- QByteArray toLocal8Bit() const Q_REQUIRED_RESULT;
- QVector<uint> toUcs4() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QByteArray toLatin1() const;
+ Q_REQUIRED_RESULT QByteArray toUtf8() const;
+ Q_REQUIRED_RESULT QByteArray toLocal8Bit() const;
+ Q_REQUIRED_RESULT QVector<uint> toUcs4() const;
inline void clear() { m_string = Q_NULLPTR; m_position = m_size = 0; }
QString toString() const;
@@ -1600,7 +1600,7 @@ public:
static int localeAwareCompare(const QStringRef &s1, const QString &s2);
static int localeAwareCompare(const QStringRef &s1, const QStringRef &s2);
- QStringRef trimmed() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT QStringRef trimmed() const;
short toShort(bool *ok = Q_NULLPTR, int base = 10) const;
ushort toUShort(bool *ok = Q_NULLPTR, int base = 10) const;
int toInt(bool *ok = Q_NULLPTR, int base = 10) const;
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index de12de19cb..70152a9202 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
\reentrant
\since 4.6
- \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks.
+ \brief The QStringBuilder class is a template class that provides a facility to build up QStrings and QByteArrays from smaller chunks.
\ingroup tools
\ingroup shared
@@ -58,22 +58,34 @@ QT_BEGIN_NAMESPACE
To build a QString by multiple concatenations, QString::operator+()
- is typically used. This causes \e{n - 1} reallocations when building
- a string from \e{n} chunks.
+ is typically used. This causes \e{n - 1} allocations when building
+ a string from \e{n} chunks. The same is true for QByteArray.
QStringBuilder uses expression templates to collect the individual
chunks, compute the total size, allocate the required amount of
- memory for the final QString object, and copy the chunks into the
+ memory for the final string object, and copy the chunks into the
allocated memory.
The QStringBuilder class is not to be used explicitly in user
code. Instances of the class are created as return values of the
- operator%() function, acting on objects of type QString,
- QLatin1String, QStringRef, QChar, QCharRef,
- QLatin1Char, and \c char.
+ operator%() function, acting on objects of the following types:
+
+ For building QStrings:
+
+ \li QString, QStringRef,
+ \li QChar, QCharRef, QLatin1Char,
+ \li QLatin1String,
+ \li QByteArray, \c char, \c{const char[]}.
+
+ The types in the last list point are only available when
+ QT_NO_CAST_FROM_ASCII is not defined.
+
+ For building QByteArrays:
+
+ \li QByteArray, \c char, \c{const char[]}.
Concatenating strings with operator%() generally yields better
- performance then using \c QString::operator+() on the same chunks
+ performance than using \c QString::operator+() on the same chunks
if there are three or more of them, and performs equally well in other
cases.
diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h
index 0038908160..74b79dce16 100644
--- a/src/corelib/tools/qtimezoneprivate_p.h
+++ b/src/corelib/tools/qtimezoneprivate_p.h
@@ -154,12 +154,12 @@ public:
QLocale::Country country);
// returns "UTC" QString and QByteArray
- static inline QString utcQString() Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT static inline QString utcQString()
{
return QStringLiteral("UTC");
}
- static inline QByteArray utcQByteArray() Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT static inline QByteArray utcQByteArray()
{
return QByteArrayLiteral("UTC");
}
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index a7f91e220c..3836bc2119 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -248,43 +248,43 @@ public:
inline explicit QVersionNumber(int maj, int min, int mic)
{ m_segments.setSegments(3, maj, min, mic); }
- inline bool isNull() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline bool isNull() const Q_DECL_NOTHROW
{ return segmentCount() == 0; }
- inline bool isNormalized() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline bool isNormalized() const Q_DECL_NOTHROW
{ return isNull() || segmentAt(segmentCount() - 1) != 0; }
- inline int majorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline int majorVersion() const Q_DECL_NOTHROW
{ return segmentAt(0); }
- inline int minorVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline int minorVersion() const Q_DECL_NOTHROW
{ return segmentAt(1); }
- inline int microVersion() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline int microVersion() const Q_DECL_NOTHROW
{ return segmentAt(2); }
- Q_CORE_EXPORT QVersionNumber normalized() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT QVersionNumber normalized() const;
- Q_CORE_EXPORT QVector<int> segments() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT QVector<int> segments() const;
- inline int segmentAt(int index) const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline int segmentAt(int index) const Q_DECL_NOTHROW
{ return (m_segments.size() > index) ? m_segments.at(index) : 0; }
- inline int segmentCount() const Q_DECL_NOTHROW Q_REQUIRED_RESULT
+ Q_REQUIRED_RESULT inline int segmentCount() const Q_DECL_NOTHROW
{ return m_segments.size(); }
- Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT bool isPrefixOf(const QVersionNumber &other) const Q_DECL_NOTHROW;
- Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static int compare(const QVersionNumber &v1, const QVersionNumber &v2) Q_DECL_NOTHROW;
- Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2);
- Q_CORE_EXPORT QString toString() const Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT QString toString() const;
#if QT_STRINGVIEW_LEVEL < 2
- Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR);
#endif
- Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr) Q_REQUIRED_RESULT;
- Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr) Q_REQUIRED_RESULT;
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QLatin1String string, int *suffixIndex = nullptr);
+ Q_REQUIRED_RESULT Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(QStringView string, int *suffixIndex = nullptr);
private:
#ifndef QT_NO_DATASTREAM