From 0f128fd7c5a9ee721d1e631743f6eb61d927cf3b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 Jan 2025 11:38:43 -0800 Subject: QDataStream: move the QChar streaming operators to qdatastream.h That frees qchar.h/cpp from having to know about QDataStream. Change-Id: I7c217e32021f67ab27ecfffd47ba5ee025ecb1bf Reviewed-by: Ivan Solovev Reviewed-by: Edward Welbourne --- src/corelib/serialization/qdatastream.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/corelib/serialization/qdatastream.cpp') diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index f9c08cd78e4..4a18c6b781e 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -1031,6 +1031,21 @@ QDataStream &QDataStream::operator>>(char32_t &c) return *this; } +/*! + \relates QChar + + Reads a char from the stream \a in into char \a chr. + + \sa {Serializing Qt Data Types} +*/ +QDataStream &operator>>(QDataStream &in, QChar &chr) +{ + quint16 u; + in >> u; + chr.unicode() = char16_t(u); + return in; +} + #if QT_DEPRECATED_SINCE(6, 11) /*! @@ -1383,6 +1398,19 @@ QDataStream &QDataStream::operator<<(char32_t c) return *this << qint32(c); } +/*! + \relates QChar + + Writes the char \a chr to the stream \a out. + + \sa {Serializing Qt Data Types} +*/ +QDataStream &operator<<(QDataStream &out, QChar chr) +{ + out << quint16(chr.unicode()); + return out; +} + /*! Writes the length specifier \a len and the buffer \a s to the stream and returns a reference to the stream. -- cgit v1.2.3