summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qbytearray.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-06-03 21:59:19 +0200
committerLars Knoll <lars.knoll@qt.io>2020-06-08 13:17:32 +0200
commit38096a3d7040edac4f769270d2402ff4e39d7694 (patch)
tree159f8de28301b992190e5a25553dd5b9c5991eb0 /src/corelib/text/qbytearray.cpp
parent6ec41bd550703aa06ed772fb0f58b7395db40fd3 (diff)
Implement first/last/from and slice() for string-like classes
These methods are scheduled as a replacement for left/right/mid() in Qt 6 with a consistent, narrow contract that does not allow out of bounds indices, and therefore does permit faster implementations. Change-Id: Iabf22e8d4f3fef3c5e69a17f103e6cddebe420b1 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r--src/corelib/text/qbytearray.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index 1a0237c225..008ce7298b 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -2989,6 +2989,53 @@ QByteArray QByteArray::mid(int pos, int len) const
}
/*!
+ \fn QByteArray QByteArray::first(qsizetype n) const
+ \since 6.0
+
+ Returns the first \a n bytes of the byte array.
+
+ \note The behavior is undefined when \a n < 0 or \a n > size().
+
+ \sa last(), slice(), from(), startsWith(), chopped(), chop(), truncate()
+*/
+
+/*!
+ \fn QByteArray QByteArray::last(qsizetype n) const
+ \since 6.0
+
+ Returns the last \a n bytes of the byte array.
+
+ \note The behavior is undefined when \a n < 0 or \a n > size().
+
+ \sa first(), slice(), from(), endsWith(), chopped(), chop(), truncate()
+*/
+
+/*!
+ \fn QByteArray QByteArray::slice(qsizetype pos, qsizetype n) const
+ \since 6.0
+
+ Returns a byte array containing the \a n bytes of this object starting
+ at position \a pos.
+
+ \note The behavior is undefined when \a pos < 0, \a n < 0,
+ or \a pos + \a n > size().
+
+ \sa first(), last(), from(), chopped(), chop(), truncate()
+*/
+
+/*!
+ \fn QByteArray QByteArray::from(qsizetype pos) const
+ \since 6.0
+
+ Returns a byte array containing the bytes starting at position \a pos
+ in this object, and extending to the end of this object.
+
+ \note The behavior is undefined when \a pos < 0 or \a pos > size().
+
+ \sa first(), last(), slice(), chopped(), chop(), truncate()
+*/
+
+/*!
\fn QByteArray::chopped(int len) const
\since 5.10