summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qanystringview.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-28 15:43:02 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-07-06 02:18:38 +0000
commitb2b58624791cde5c2b24b9397f02ccad5b394ea6 (patch)
tree1ba200f0aa70e0efeabca89572238a1cfd66ad7f /src/corelib/text/qanystringview.h
parent4443d392e4f234a5315cfd773559af936cb62ddb (diff)
QAnyStringView: add QDebug stream operator
When QDebug::quoted(), indicates the encoding using the u/u8 prefixes or the _L1 suffix. This is information that might come in handy, and we plan to make it off-switchable (QTBUG-114936). The default should be true, though, for QAnyStringView, because we should confront users with this feature so they learn it exists. For concrete view types, changing the default behavior is probably not a good idea. [ChangeLog][QtCore][QAnyStringView/QDebug] Can now stream QAnyStringView into QDebug. Fixes: QTBUG-114935 Change-Id: Icd5bf700c8b7958e942468b54248487998f262d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text/qanystringview.h')
-rw-r--r--src/corelib/text/qanystringview.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/text/qanystringview.h b/src/corelib/text/qanystringview.h
index 2be79c2b52..ba5a179caf 100644
--- a/src/corelib/text/qanystringview.h
+++ b/src/corelib/text/qanystringview.h
@@ -312,6 +312,10 @@ private:
{ return QAnyStringView::compare(lhs, rhs) > 0; }
#endif
+#ifndef QT_NO_DEBUG_STREAM
+ Q_CORE_EXPORT friend QDebug operator<<(QDebug d, QAnyStringView s);
+#endif
+
[[nodiscard]] constexpr Tag tag() const noexcept { return Tag{m_size & TypeMask}; }
[[nodiscard]] constexpr bool isUtf16() const noexcept { return tag() == Tag::Utf16; }
[[nodiscard]] constexpr bool isUtf8() const noexcept { return tag() == Tag::Utf8; }