1 #ifndef QTJSONSERIALIZER_CBORSERIALIZER_H
2 #define QTJSONSERIALIZER_CBORSERIALIZER_H
4 #include "QtJsonSerializer/qtjsonserializer_global.h"
5 #include "QtJsonSerializer/serializerbase.h"
9 class CborSerializerPrivate;
16 Q_PROPERTY(
bool handleSpecialNumbers READ handleSpecialNumbers WRITE setHandleSpecialNumbers NOTIFY handleSpecialNumbersChanged)
28 NetworkAddressPrefix = 261,
38 ConstructedObject = 10004,
41 VersionNumber = 10007,
55 ChronoNanoSeconds = 10120,
56 ChronoMicroSeconds = 10121,
57 ChronoMilliSeconds = 10122,
58 ChronoSeconds = 10123,
59 ChronoMinutes = 10124,
62 NoTag = std::numeric_limits<std::underlying_type_t<QCborTag>>::max()
70 bool handleSpecialNumbers()
const;
74 void setTypeTag(QCborTag tag = static_cast<QCborTag>(NoTag));
76 void setTypeTag(
int metaTypeId, QCborTag tag = static_cast<QCborTag>(NoTag));
79 QCborTag typeTag()
const;
80 QCborTag typeTag(
int metaTypeId)
const override;
107 template <
typename T>
110 template <
typename T>
113 template <
typename T>
116 std::variant<QCborValue, QJsonValue> serializeGeneric(
const QVariant &value)
const override;
117 QVariant deserializeGeneric(
const std::variant<QCborValue, QJsonValue> &value,
int metaTypeId,
QObject *parent)
const override;
121 void setHandleSpecialNumbers(
bool handleSpecialNumbers);
125 void handleSpecialNumbersChanged(
bool handleSpecialNumbers, QPrivateSignal);
129 bool jsonMode()
const override;
130 QList<int> typesForTag(QCborTag tag)
const override;
147 return typeTag(qMetaTypeId<T>());
153 static_assert(__private::is_serializable<T>::value,
"T cannot be serialized");
154 return serialize(__private::variant_helper<T>::toVariant(data));
160 static_assert(__private::is_serializable<T>::value,
"T cannot be serialized");
161 serializeTo(device, __private::variant_helper<T>::toVariant(data), options);
167 static_assert(__private::is_serializable<T>::value,
"T cannot be serialized");
168 return serializeTo(__private::variant_helper<T>::toVariant(data), options);
174 static_assert(__private::is_serializable<T>::value,
"T cannot be deserialized");
175 return __private::variant_helper<T>::fromVariant(
deserialize(cbor, qMetaTypeId<T>(),
parent));
181 static_assert(__private::is_serializable<T>::value,
"T cannot be deserialized");
188 static_assert(__private::is_serializable<T>::value,
"T cannot be deserialized");
194 #endif // QTJSONSERIALIZER_CBORSERIALIZER_H