From 794150e5bda0c203a5373c3fa2f9785f9941f6dd Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 14 May 2020 12:59:42 +0200 Subject: QMetaType: Support char16_t and char32_t Change-Id: Ieec6d4bc64967d875ea12b31638aab05bc682ea3 Reviewed-by: Lars Knoll --- src/corelib/serialization/qdatastream.cpp | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/corelib/serialization/qdatastream.cpp') diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index df286085bc4..3026e554bf3 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -1025,6 +1025,31 @@ QDataStream &QDataStream::operator>>(char *&s) return readBytes(s, len); } +/*! + \overload + + Reads a char from the stream into char \a chr. +*/ +QDataStream &QDataStream::operator>>(char16_t &c) +{ + quint16 u; + *this >> u; + c = char16_t(u); + return *this; +} + +/*! + \overload + + Reads a char from the stream into char \a chr. +*/ +QDataStream &QDataStream::operator>>(char32_t &c) +{ + quint32 u; + *this >> u; + c = char32_t(u); + return *this; +} /*! Reads the buffer \a s from the stream and returns a reference to @@ -1337,6 +1362,30 @@ QDataStream &QDataStream::operator<<(const char *s) return *this; } +/*! + \overload + \since 6.0 + + Writes a character, \a c, to the stream. Returns a reference to + the stream +*/ +QDataStream &QDataStream::operator<<(char16_t c) +{ + return *this << qint16(c); +} + +/*! + \overload + \since 6.0 + + Writes a character, \a c, to the stream. Returns a reference to + the stream +*/ +QDataStream &QDataStream::operator<<(char32_t c) +{ + return *this << qint32(c); +} + /*! 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