From 4d9bedc97b42e439e91b3858f102ea4bc69e3f35 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Tue, 2 Jul 2024 15:29:34 +0300 Subject: [PATCH] QString: move empty "before" note to the relevant replace() overloads Amends 3e56757d651ffcba9ea65aa990b4e02b05e00b17. Pick-to: 6.7 Change-Id: I91a59a8b9e3abfeb14272554d5ca0833141ff2ee Reviewed-by: Ivan Solovev (cherry picked from commit d16f4cf826d25a7fd1e8c617e4cafaf7cc9a2711) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qstring.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index fd276e1ac6a..98efc903012 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -3786,9 +3786,6 @@ static void replace_helper(QString &str, QSpan indices, qsizetype blen, but \a position + \a n goes outside the strings range, then \a n will be adjusted to stop at the end of the string. - \note If you use an empty \a before argument, the \a after argument will be - inserted \e {before and after} each character of the string. - Example: \snippet qstring/main.cpp 40 @@ -3847,6 +3844,12 @@ QString &QString::replace(qsizetype pos, qsizetype len, QChar after) Example: \snippet qstring/main.cpp 86 + +//! [empty-before-arg-in-replace] + \note If you use an empty \a before argument, the \a after argument will be + inserted \e {before and after} each character of the string. +//! [empty-before-arg-in-replace] + */ QString &QString::replace(const QString &before, const QString &after, Qt::CaseSensitivity cs) { @@ -3862,6 +3865,10 @@ QString &QString::replace(const QString &before, const QString &after, Qt::CaseS after and returns a reference to this string. \include qstring.qdocinc {search-comparison-case-sensitivity} {search} + + \note If \a before points to an \e empty string (that is, \a blen == 0), + the string pointed to by \a after will be inserted \e {before and after} + each character in this string. */ QString &QString::replace(const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, @@ -3997,6 +4004,8 @@ QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs) \include qstring.qdocinc {search-comparison-case-sensitivity} {search} \note The text is not rescanned after a replacement. + + \include qstring.cpp empty-before-arg-in-replace */ QString &QString::replace(QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs) { @@ -4021,6 +4030,8 @@ QString &QString::replace(QLatin1StringView before, QLatin1StringView after, Qt: \include qstring.qdocinc {search-comparison-case-sensitivity} {search} \note The text is not rescanned after a replacement. + + \include qstring.cpp empty-before-arg-in-replace */ QString &QString::replace(QLatin1StringView before, const QString &after, Qt::CaseSensitivity cs) { @@ -4042,6 +4053,8 @@ QString &QString::replace(QLatin1StringView before, const QString &after, Qt::Ca \include qstring.qdocinc {search-comparison-case-sensitivity} {search} \note The text is not rescanned after a replacement. + + \include qstring.cpp empty-before-arg-in-replace */ QString &QString::replace(const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs) {