summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
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/text/qbytearray.cpp
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/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 9135dd8523..1821dd2c26 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -3102,7 +3102,8 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const
}
/*!
- \fn QByteArray QByteArray::first(qsizetype n) const
+ \fn QByteArray QByteArray::first(qsizetype n) const &
+ \fn QByteArray QByteArray::first(qsizetype n) &&
\since 6.0
Returns the first \a n bytes of the byte array.
@@ -3116,7 +3117,8 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const
*/
/*!
- \fn QByteArray QByteArray::last(qsizetype n) const
+ \fn QByteArray QByteArray::last(qsizetype n) const &
+ \fn QByteArray QByteArray::last(qsizetype n) &&
\since 6.0
Returns the last \a n bytes of the byte array.
@@ -3130,7 +3132,8 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const
*/
/*!
- \fn QByteArray QByteArray::sliced(qsizetype pos, qsizetype n) const
+ \fn QByteArray QByteArray::sliced(qsizetype pos, qsizetype n) const &
+ \fn QByteArray QByteArray::sliced(qsizetype pos, qsizetype n) &&
\since 6.0
Returns a byte array containing the \a n bytes of this object starting
@@ -3144,9 +3147,18 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const
\sa first(), last(), chopped(), chop(), truncate()
*/
+QByteArray QByteArray::sliced_helper(QByteArray &a, qsizetype pos, qsizetype n)
+{
+ if (n == 0)
+ return fromRawData(&_empty, 0);
+ DataPointer d = std::move(a.d).sliced(pos, n);
+ d.data()[n] = 0;
+ return QByteArray(std::move(d));
+}
/*!
- \fn QByteArray QByteArray::sliced(qsizetype pos) const
+ \fn QByteArray QByteArray::sliced(qsizetype pos) const &
+ \fn QByteArray QByteArray::sliced(qsizetype pos) &&
\since 6.0
\overload
@@ -3159,7 +3171,8 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const
*/
/*!
- \fn QByteArray QByteArray::chopped(qsizetype len) const
+ \fn QByteArray QByteArray::chopped(qsizetype len) const &
+ \fn QByteArray QByteArray::chopped(qsizetype len) &&
\since 5.10
Returns a byte array that contains the leftmost size() - \a len bytes of