summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-09-25 11:08:51 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-10-25 12:01:58 -0700
commitf4101f9953ec63ee09e73b4b72bf6ed561d7568f (patch)
tree662ad587c009908f448ca33a4af610f4270cb792 /src/corelib/compat
parent2fd0996324304c4c055059a980b6f9b32b843574 (diff)
QString/QBA: add lvalue and rvalue overloads to first/last/sliced/chopped
Those ought to have been the original implementation, when they were added in commit 38096a3d7040edac4f769270d2402ff4e39d7694, for Qt 6.0. Because these classes are exported, we need to provide the previous only implementations for MSVC. All other compilers would provide inline or emit local, out-of-line copies. Change-Id: Ifeb6206a9fa04424964bfffd178836a2ae56157d Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/compat')
-rw-r--r--src/corelib/compat/removed_api.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index 591ef0fc68..5c3a587f6e 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -618,6 +618,22 @@ QStringView QXmlStreamAttributes::value(QLatin1StringView qualifiedName) const
#if QT_CORE_REMOVED_SINCE(6, 7)
+#include "qbytearray.h"
+
+#ifdef Q_CC_MSVC
+// previously inline methods, only needed for MSVC compat
+QByteArray QByteArray::first(qsizetype n) const
+{ return sliced(0, n); }
+QByteArray QByteArray::last(qsizetype n) const
+{ return sliced(size() - n, n); }
+QByteArray QByteArray::sliced(qsizetype pos) const
+{ return sliced(pos, size() - pos); }
+QByteArray QByteArray::sliced(qsizetype pos, qsizetype n) const
+{ verify(pos, n); return QByteArray(d.data() + pos, n); }
+QByteArray QByteArray::chopped(qsizetype n) const
+{ return sliced(0, size() - n); }
+#endif
+
#include "qdatetime.h"
QDateTime::QDateTime(QDate date, QTime time, const QTimeZone &timeZone)
@@ -726,6 +742,22 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
return invokeMethodImpl(object, slot, type, 1, &ret, nullptr, nullptr);
}
+#include "qstring.h"
+
+#ifdef Q_CC_MSVC
+// previously inline methods, only needed for MSVC compat
+QString QString::first(qsizetype n) const
+{ return sliced(0, n); }
+QString QString::last(qsizetype n) const
+{ return sliced(size() - n, n); }
+QString QString::sliced(qsizetype pos) const
+{ return sliced(pos, size() - pos); }
+QString QString::sliced(qsizetype pos, qsizetype n) const
+{ verify(pos, n); return QString(begin() + pos, n); }
+QString QString::chopped(qsizetype n) const
+{ return sliced(0, size() - n); }
+#endif
+
#include "qurl.h"
QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode)