summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qanystringview.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-07-02 02:39:48 +0300
committerMarc Mutz <marc.mutz@qt.io>2024-08-28 15:32:19 +0000
commit8f68bd9e6353a42d3b71d893b27fec6bedced501 (patch)
tree1d30b833668214c8e36dedcb7d39bc50f7f0a688 /src/corelib/text/qanystringview.cpp
parent8e63cf282cb248ddd7fbc908766091659b3a0b22 (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/qanystringview.cpp')
-rw-r--r--src/corelib/text/qanystringview.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/corelib/text/qanystringview.cpp b/src/corelib/text/qanystringview.cpp
index 4129257c02d..14e07bd4f17 100644
--- a/src/corelib/text/qanystringview.cpp
+++ b/src/corelib/text/qanystringview.cpp
@@ -383,7 +383,7 @@ QT_BEGIN_NAMESPACE
\a n is negative (default), the function returns all code points that
are available from \a pos.
- \sa first(), last(), sliced(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa first(), last(), sliced(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -398,7 +398,7 @@ QT_BEGIN_NAMESPACE
The entire string view is returned if \a n is greater than or equal
to size(), or less than zero.
- \sa first(), last(), sliced(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa first(), last(), sliced(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -413,7 +413,7 @@ QT_BEGIN_NAMESPACE
The entire string view is returned if \a n is greater than or equal
to size(), or less than zero.
- \sa first(), last(), sliced(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa first(), last(), sliced(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -425,7 +425,7 @@ QT_BEGIN_NAMESPACE
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa last(), sliced(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa last(), sliced(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -436,7 +436,7 @@ QT_BEGIN_NAMESPACE
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa first(), sliced(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa first(), sliced(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -451,7 +451,7 @@ QT_BEGIN_NAMESPACE
or \a pos + \a n > size().
//! [UB-sliced-index-length]
- \sa first(), last(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa first(), last(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -465,7 +465,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(), {Sizes and Sub-Strings}
+ \sa first(), last(), chopped(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
+*/
+
+/*!
+ \fn QAnyStringView &QAnyStringView::slice(qsizetype pos, qsizetype n)
+ \since 6.8
+
+ Modifies this string view to start at position \a pos, extending for
+ \a n code points.
+
+ \include qanystringview.cpp UB-sliced-index-length
+
+ \sa sliced(), first(), last(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
+*/
+
+/*!
+ \fn QAnyStringView &QAnyStringView::slice(qsizetype pos)
+ \since 6.8
+ \overload
+
+ Modifies this string view to start at position \a pos, extending to
+ its end.
+
+ \include qanystringview.cpp UB-sliced-index-only
+
+ \sa sliced(), first(), last(), chopped(), chop(), truncate(), {Sizes and Sub-Strings}
*/
/*!
@@ -479,7 +504,7 @@ QT_BEGIN_NAMESPACE
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa sliced(), first(), last(), chop(), truncate(), {Sizes and Sub-Strings}
+ \sa sliced(), first(), last(), chop(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*!
@@ -505,7 +530,7 @@ QT_BEGIN_NAMESPACE
\note The behavior is undefined when \a n < 0 or \a n > size().
- \sa sliced(), first(), last(), chopped(), truncate(), {Sizes and Sub-Strings}
+ \sa sliced(), first(), last(), chopped(), truncate(), slice(), {Sizes and Sub-Strings}
*/
/*! \fn template <typename Visitor> decltype(auto) QAnyStringView::visit(Visitor &&v) const