summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qstringview.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-05-22 14:29:30 +0200
committerMarc Mutz <marc.mutz@qt.io>2024-12-03 22:44:54 +0100
commitf7e8e54d7e6803c91cc453afdfc46f3d0b4da9c2 (patch)
treeb7bbd5f28ee2d630b3326e996aefd9d7a6ac9300 /src/corelib/text/qstringview.cpp
parent563ed822f867c6c3040956017d4ca7f3795f172c (diff)
QString: toward UTF-8 arg() support [4/4]: accept QAnyStringViews (incl. UTF-8 ones)
This is the public API for the functionality already implemented in pt.1 of this patch series (except the replacement of the remaining Q_UNREACHABLE). I opted to do the minimal change to enable this important functionality: the ArgBase hierarchy stays and gets extended a bit differently than originally envisioned. ArgBase, of course, is just yet another QAnyStringView re-implementation, so eventually, this will go. But the churn to do this in a binary-compatible way would just be too big. Instead of the U8 tag representing UTF-8 arguments, repurpose this up-to-now unused tag to mean QAnyStringView. This allows to get rid of the qStringLikeToArg() overloads, leaving only one accepting QAnyStringView. This is the only one that new code will ever call. But we still need to support L1 and U16 ArgBases for old code. [ChangeLog][QtCore][QString/QStringView/QAnyStringView] Added (multi-)arg() support for UTF-8 (QUtf8StringView) and QAnyStringView arguments. Passing C string literals or QByteArrays to arg() now no longer implicitly converts to QString first. Fixes: QTBUG-124365 Change-Id: I0d710365a45d2c62af26184e8a857c3f4cdeeae2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qstringview.cpp')
-rw-r--r--src/corelib/text/qstringview.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp
index 1510c31bca5..64d4ffc1f1d 100644
--- a/src/corelib/text/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -517,12 +517,13 @@ QT_BEGIN_NAMESPACE
the \a args replaces the \c{%N} with the lowest \c{N} (all of them), the
second of the \a args the \c{%N} with the next-lowest \c{N} etc.
- \c Args can consist of anything that implicitly converts to QString,
- QStringView or QLatin1StringView.
-
- In addition, the following types are also supported: QChar, QLatin1Char.
+ \c Args can consist of anything that implicitly converts to QAnyStringView.
//![qstring-multi-arg]
+ \note In Qt versions prior to 6.9, QAnyStringView and UTF-8 strings
+ (QUtf8StringView, QByteArray, QByteArrayView, \c{const char8_t*}, etc) were
+ not supported as \a args.
+
\sa QString::arg()
*/