Implement QDataStream operator for QCborSimpleValue

That allows us to remove custom handling in QMetaType.

Change-Id: Ic09fb96e1a05c6897803811d70aebbc6ea6e4f2e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jędrzej Nowacki 2018-09-10 08:47:32 +02:00
parent e74cb37159
commit 31f3facac3
4 changed files with 21 additions and 27 deletions

View File

@ -84,19 +84,6 @@ static const char diagnosticHelp[] =
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &ds, QCborSimpleType st)
{
return ds << quint8(st);
}
QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st)
{
quint8 v;
ds >> v;
st = QCborSimpleType(v);
return ds;
}
QDataStream &operator<<(QDataStream &ds, QCborTag tag)
{
return ds << quint64(tag);

View File

@ -1485,12 +1485,6 @@ public:
stream << qulonglong(*data);
return true;
}
bool delegate(const QCborSimpleType *data)
{
// TODO just define a normal QDataStream operator
stream << quint8(*data);
return true;
}
bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
{
const QVector<QCustomTypeInfo> * const ct = customTypes();
@ -1542,14 +1536,6 @@ public:
*const_cast<unsigned long*>(data) = l;
return true;
}
bool delegate(const QCborSimpleType *data)
{
// TODO just define a normal QDataStream operator
quint8 l;
stream >> l;
*const_cast<QCborSimpleType*>(data) = QCborSimpleType(l);
return true;
}
bool delegate(const QMetaTypeSwitcher::NotBuiltinType *data)
{
const QVector<QCustomTypeInfo> * const ct = customTypes();

View File

@ -133,6 +133,11 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, QCborKnownTags tg);
Q_CORE_EXPORT QDebug operator<<(QDebug, QCborTag tg);
#endif
#if !defined(QT_NO_DEBUG_STREAM)
QDataStream &operator<<(QDataStream &ds, QCborSimpleType st);
QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st);
#endif
QT_END_NAMESPACE
Q_DECLARE_METATYPE(QCborTag)

View File

@ -44,6 +44,7 @@
#include <qbuffer.h>
#include <qdebug.h>
#include <qstack.h>
#include <qdatastream.h>
QT_BEGIN_NAMESPACE
@ -170,6 +171,21 @@ Q_CORE_EXPORT const char *qt_cbor_simpletype_id(QCborSimpleType st)
return nullptr;
}
#if !defined(QT_NO_DATASTREAM)
QDataStream &operator<<(QDataStream &ds, QCborSimpleType st)
{
return ds << quint8(st);
}
QDataStream &operator>>(QDataStream &ds, QCborSimpleType &st)
{
quint8 v;
ds >> v;
st = QCborSimpleType(v);
return ds;
}
#endif
#if !defined(QT_NO_DEBUG_STREAM)
QDebug operator<<(QDebug dbg, QCborSimpleType st)
{