From 42c4d6c249f3627e7106844dbcda0f6e42e542a4 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 1 Oct 2023 18:24:22 +0300 Subject: [PATCH] String views: de-duplicate API docs Will be reused in later commits. Change-Id: I078ad7eb0aac6eb389453d8bc32c414c840bc22e Reviewed-by: Thiago Macieira --- src/corelib/text/qanystringview.cpp | 4 ++++ src/corelib/text/qbytearrayview.qdoc | 4 ++++ src/corelib/text/qlatin1stringview.qdoc | 4 ++++ src/corelib/text/qstringview.cpp | 4 ++++ src/corelib/text/qutf8stringview.qdoc | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/src/corelib/text/qanystringview.cpp b/src/corelib/text/qanystringview.cpp index 65655a5e97..89ff248f8d 100644 --- a/src/corelib/text/qanystringview.cpp +++ b/src/corelib/text/qanystringview.cpp @@ -440,8 +440,10 @@ QT_BEGIN_NAMESPACE Returns a string view containing \a n code points of this string view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \a pos + \a n > size(). +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate(), {Sizes and Sub-Strings} */ @@ -453,7 +455,9 @@ QT_BEGIN_NAMESPACE Returns a string view starting at position \a pos in this object, and extending to its end. +//! [UB-sliced-index-only] \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} */ diff --git a/src/corelib/text/qbytearrayview.qdoc b/src/corelib/text/qbytearrayview.qdoc index 60c68024b4..9a149a4814 100644 --- a/src/corelib/text/qbytearrayview.qdoc +++ b/src/corelib/text/qbytearrayview.qdoc @@ -562,8 +562,10 @@ Returns a byte array view that points to \a n bytes of this byte array view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \a pos + \a n > size(). +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate() */ @@ -574,7 +576,9 @@ Returns a byte array view starting at position \a pos in this object, and extending to its end. +//! [UB-sliced-index-only] \note The behavior is undefined when \a pos < 0 or \a pos > size(). +//! [UB-sliced-index-only] \sa first(), last(), chopped(), chop(), truncate() */ diff --git a/src/corelib/text/qlatin1stringview.qdoc b/src/corelib/text/qlatin1stringview.qdoc index 3bd9312232..a39554d344 100644 --- a/src/corelib/text/qlatin1stringview.qdoc +++ b/src/corelib/text/qlatin1stringview.qdoc @@ -756,8 +756,10 @@ Returns a Latin-1 string view that points to \a n characters of this string view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \c{pos + n > size()}. +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate() */ @@ -769,7 +771,9 @@ Returns a Latin-1 string view starting at position \a pos in this string view, and extending to its end. +//! [UB-sliced-index-only] \note The behavior is undefined when \a pos < 0 or \a pos > size(). +//! [UB-sliced-index-only] \sa first(), last(), chopped(), chop(), truncate() */ diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp index 226ab4da9c..6f26a04d34 100644 --- a/src/corelib/text/qstringview.cpp +++ b/src/corelib/text/qstringview.cpp @@ -654,8 +654,10 @@ QT_BEGIN_NAMESPACE Returns a string view that points to \a n characters of this string view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \a pos + \a n > size(). +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate() */ @@ -668,7 +670,9 @@ QT_BEGIN_NAMESPACE Returns a string view starting at position \a pos in this object, and extending to its end. +//! [UB-sliced-index-only] \note The behavior is undefined when \a pos < 0 or \a pos > size(). +//! [UB-sliced-index-only] \sa first(), last(), chopped(), chop(), truncate() */ diff --git a/src/corelib/text/qutf8stringview.qdoc b/src/corelib/text/qutf8stringview.qdoc index 60d0d7cd1d..5f3d7509f7 100644 --- a/src/corelib/text/qutf8stringview.qdoc +++ b/src/corelib/text/qutf8stringview.qdoc @@ -605,8 +605,10 @@ Returns a string view containing \a n code points of this string view, starting at position \a pos. +//! [UB-sliced-index-length] \note The behavior is undefined when \a pos < 0, \a n < 0, or \a pos + \a n > size(). +//! [UB-sliced-index-length] \sa first(), last(), chopped(), chop(), truncate() */ @@ -617,7 +619,9 @@ Returns a string view starting at position \a pos in this object, and extending to its end. +//! [UB-sliced-index-only] \note The behavior is undefined when \a pos < 0 or \a pos > size(). +//! [UB-sliced-index-only] \sa first(), last(), chopped(), chop(), truncate() */