diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2023-07-02 02:39:48 +0300 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-08-28 15:32:19 +0000 |
| commit | 8f68bd9e6353a42d3b71d893b27fec6bedced501 (patch) | |
| tree | 1d30b833668214c8e36dedcb7d39bc50f7f0a688 /src/corelib/text/qstringview.cpp | |
| parent | 8e63cf282cb248ddd7fbc908766091659b3a0b22 (diff) | |
String Views: add slice() methods
Methods with preconditions can't be noexcept (from Marc in code
review).
[ChangeLog][QtCore][String Views] Added slice() methods to
Q{String,ByteArray,Latin1String,Utf8String,AnyString}View which work
like sliced() but modify the view they are called on.
Found in API review.
Pick-to: 6.8
Task-number: QTBUG-99218
Change-Id: Ic8ef3085f7cfac86b8404fb28d491ca38ad121eb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/text/qstringview.cpp')
| -rw-r--r-- | src/corelib/text/qstringview.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index 29b83ffe8fa..3eb26cdd832 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -592,7 +592,7 @@ QT_BEGIN_NAMESPACE \a length is negative (default), the function returns all characters that are available from \a start. - \sa first(), last(), sliced(), chopped(), chop(), truncate() + \sa first(), last(), sliced(), chopped(), chop(), truncate(), slice() */ /*! @@ -606,7 +606,7 @@ QT_BEGIN_NAMESPACE The entire string view is returned if \a length is greater than or equal to size(), or less than zero. - \sa first(), last(), sliced(), startsWith(), chopped(), chop(), truncate() + \sa first(), last(), sliced(), startsWith(), chopped(), chop(), truncate(), slice() */ /*! @@ -620,7 +620,7 @@ QT_BEGIN_NAMESPACE The entire string view is returned if \a length is greater than or equal to size(), or less than zero. - \sa first(), last(), sliced(), endsWith(), chopped(), chop(), truncate() + \sa first(), last(), sliced(), endsWith(), chopped(), chop(), truncate(), slice() */ /*! @@ -632,7 +632,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a n < 0 or \a n > size(). - \sa last(), sliced(), startsWith(), chopped(), chop(), truncate() + \sa last(), sliced(), startsWith(), chopped(), chop(), truncate(), slice() */ /*! @@ -644,7 +644,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a n < 0 or \a n > size(). - \sa first(), sliced(), endsWith(), chopped(), chop(), truncate() + \sa first(), sliced(), endsWith(), chopped(), chop(), truncate(), slice() */ /*! @@ -659,7 +659,7 @@ QT_BEGIN_NAMESPACE or \a pos + \a n > size(). //! [UB-sliced-index-length] - \sa first(), last(), chopped(), chop(), truncate() + \sa first(), last(), chopped(), chop(), truncate(), slice() */ /*! @@ -674,7 +674,32 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a pos < 0 or \a pos > size(). //! [UB-sliced-index-only] - \sa first(), last(), chopped(), chop(), truncate() + \sa first(), last(), chopped(), chop(), truncate(), slice() +*/ + +/*! + \fn QStringView &QStringView::slice(qsizetype pos, qsizetype n) + \since 6.8 + + Modifies this string view to start from position \a pos, extending + for \a n code points. + + \include qstringview.cpp UB-sliced-index-length + + \sa sliced(), first(), last(), chopped(), chop(), truncate() +*/ + +/*! + \fn QStringView &QStringView::slice(qsizetype pos) + \since 6.8 + \overload + + Modifies this string view to start from position \a pos, extending + to its end. + + \include qstringview.cpp UB-sliced-index-only + + \sa sliced(), first(), last(), chopped(), chop(), truncate() */ /*! @@ -687,7 +712,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a length < 0 or \a length > size(). - \sa mid(), left(), right(), chop(), truncate() + \sa mid(), left(), right(), chop(), truncate(), slice() */ /*! @@ -711,7 +736,7 @@ QT_BEGIN_NAMESPACE \note The behavior is undefined when \a length < 0 or \a length > size(). - \sa mid(), left(), right(), chopped(), truncate() + \sa mid(), left(), right(), chopped(), truncate(), slice() */ /*! |
