QMetaType: Support char16_t and char32_t
Change-Id: Ieec6d4bc64967d875ea12b31638aab05bc682ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
45cf8da63c
commit
794150e5bd
@ -85,6 +85,8 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
|
||||
F(Long, 32, long) \
|
||||
F(Short, 33, short) \
|
||||
F(Char, 34, char) \
|
||||
F(Char16, 56, char16_t) \
|
||||
F(Char32, 57, char32_t) \
|
||||
F(ULong, 35, ulong) \
|
||||
F(UShort, 36, ushort) \
|
||||
F(UChar, 37, uchar) \
|
||||
@ -451,7 +453,7 @@ public:
|
||||
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
|
||||
|
||||
FirstCoreType = Bool,
|
||||
LastCoreType = QCborMap,
|
||||
LastCoreType = Char32,
|
||||
FirstGuiType = QFont,
|
||||
LastGuiType = QColorSpace,
|
||||
FirstWidgetsType = QSizePolicy,
|
||||
@ -482,6 +484,7 @@ public:
|
||||
Nullptr = 51,
|
||||
QVariantMap = 8, QVariantList = 9, QVariantHash = 28,
|
||||
QCborSimpleType = 52, QCborValue = 53, QCborArray = 54, QCborMap = 55,
|
||||
Char16 = 56, Char32 = 57,
|
||||
|
||||
// Gui types
|
||||
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
|
||||
|
@ -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.
|
||||
|
@ -163,6 +163,8 @@ public:
|
||||
QDataStream &operator>>(float &f);
|
||||
QDataStream &operator>>(double &f);
|
||||
QDataStream &operator>>(char *&str);
|
||||
QDataStream &operator>>(char16_t &c);
|
||||
QDataStream &operator>>(char32_t &c);
|
||||
|
||||
QDataStream &operator<<(qint8 i);
|
||||
QDataStream &operator<<(quint8 i);
|
||||
@ -178,6 +180,9 @@ public:
|
||||
QDataStream &operator<<(float f);
|
||||
QDataStream &operator<<(double f);
|
||||
QDataStream &operator<<(const char *str);
|
||||
QDataStream &operator<<(char16_t c);
|
||||
QDataStream &operator<<(char32_t c);
|
||||
|
||||
|
||||
QDataStream &readBytes(char *&, uint &len);
|
||||
int readRawData(char *, int len);
|
||||
|
@ -136,6 +136,12 @@ template<> struct TestValueFactory<QMetaType::Short> {
|
||||
template<> struct TestValueFactory<QMetaType::Char> {
|
||||
static char *create() { return new char('c'); }
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::Char16> {
|
||||
static char16_t *create() { return new char16_t('c'); }
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::Char32> {
|
||||
static char32_t *create() { return new char32_t('c'); }
|
||||
};
|
||||
template<> struct TestValueFactory<QMetaType::ULong> {
|
||||
static ulong *create() { return new ulong(ULONG_MAX); }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user