diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-06-28 15:43:02 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-07-06 02:18:38 +0000 |
commit | b2b58624791cde5c2b24b9397f02ccad5b394ea6 (patch) | |
tree | 1ba200f0aa70e0efeabca89572238a1cfd66ad7f /src/corelib/text/qanystringview.h | |
parent | 4443d392e4f234a5315cfd773559af936cb62ddb (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.h | 4 |
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; } |