A class to serialize and deserialize c++ classes to and from CBOR. More...
#include <cborserializer.h>
Public Types | |
enum | ExtendedTags : std::underlying_type_t< QCborTag > { GenericObject = 27, RationaleNumber = 30, Identifier = 39, Homogeneous = 41, Set = 258, ExplicitMap = 259, NetworkAddress = 260, NetworkAddressPrefix = 261 } |
Additional official CBOR-Tags, taken from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml. More... | |
enum | CustomTags : std::underlying_type_t< QCborTag > { Color = 10000, Font = 10001, Enum = 10002, Flags = 10003, ConstructedObject = 10004, Pair = 10005, MultiMap = 10006, VersionNumber = 10007, Tuple = 10008, BitArray = 10009, Date = 10010, Time = 10011, LocaleISO = 10100, LocaleBCP47 = 10101, GeomSize = 10110, GeomPoint = 10111, GeomLine = 10112, GeomRect = 10113, ChronoNanoSeconds = 10120, ChronoMicroSeconds = 10121, ChronoMilliSeconds = 10122, ChronoSeconds = 10123, ChronoMinutes = 10124, ChronoHours = 10125 } |
Public Types inherited from QtJsonSerializer::SerializerBase | |
enum | ValidationFlag { ValidationFlag::StandardValidation = 0x00, ValidationFlag::NoExtraProperties = 0x01, ValidationFlag::AllProperties = 0x02, ValidationFlag::StrictBasicTypes = 0x04, ValidationFlag::FullPropertyValidation = (NoExtraProperties | AllProperties), ValidationFlag::FullValidation = (FullPropertyValidation | StrictBasicTypes) } |
Flags to specify how strict the serializer should validate when deserializing. More... | |
enum | Polymorphing { Polymorphing::Disabled, Polymorphing::Enabled, Polymorphing::Forced } |
Enum to specify the modes of polymorphism. More... | |
enum | MultiMapMode { MultiMapMode::Map, MultiMapMode::List, MultiMapMode::DenseMap } |
Enum to specify how multi maps and sets should be serialized. More... | |
Public Slots | |
void | setHandleSpecialNumbers (bool handleSpecialNumbers) |
WRITE accessor for CborSerializer::handleSpecialNumbers. | |
Public Slots inherited from QtJsonSerializer::SerializerBase | |
void | setAllowDefaultNull (bool allowDefaultNull) |
WRITE accessor for QJsonSerializer::allowDefaultNull. | |
void | setKeepObjectName (bool keepObjectName) |
WRITE accessor for QJsonSerializer::keepObjectName. | |
void | setEnumAsString (bool enumAsString) |
WRITE accessor for QJsonSerializer::enumAsString. | |
void | setVersionAsString (bool versionAsString) |
WRITE accessor for QJsonSerializer::versionAsString. | |
void | setDateAsTimeStamp (bool dateAsTimeStamp) |
WRITE accessor for QJsonSerializer::dateAsTimeStamp. | |
void | setUseBcp47Locale (bool useBcp47Locale) |
WRITE accessor for QJsonSerializer::useBcp47Locale. | |
void | setValidationFlags (ValidationFlags validationFlags) |
WRITE accessor for QJsonSerializer::validationFlags. | |
void | setPolymorphing (Polymorphing polymorphing) |
WRITE accessor for QJsonSerializer::polymorphing. | |
void | setMultiMapMode (MultiMapMode multiMapMode) |
WRITE accessor for QJsonSerializer::multiMapMode. | |
void | setIgnoreStoredAttribute (bool ignoreStoredAttribute) |
WRITE accessor for QJsonSerializer::ignoreStoredAttribute. | |
Signals | |
void | handleSpecialNumbersChanged (bool handleSpecialNumbers, QPrivateSignal) |
NOTIFY accessor for CborSerializer::handleSpecialNumbers. | |
Signals inherited from QtJsonSerializer::SerializerBase | |
void | allowDefaultNullChanged (bool allowDefaultNull, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::allowDefaultNull. | |
void | keepObjectNameChanged (bool keepObjectName, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::keepObjectName. | |
void | enumAsStringChanged (bool enumAsString, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::enumAsString. | |
void | versionAsStringChanged (bool versionAsString, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::versionAsString. | |
void | dateAsTimeStampChanged (bool dateAsTimeStamp, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::dateAsTimeStamp. | |
void | useBcp47LocaleChanged (bool useBcp47Locale, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::useBcp47Locale. | |
void | validationFlagsChanged (ValidationFlags validationFlags, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::validationFlags. | |
void | polymorphingChanged (Polymorphing polymorphing, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::polymorphing. | |
void | multiMapModeChanged (MultiMapMode multiMapMode, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::multiMapMode. | |
void | ignoreStoredAttributeChanged (bool ignoreStoredAttribute, QPrivateSignal) |
NOTIFY accessor for QJsonSerializer::ignoreStoredAttribute. | |
Public Member Functions | |
CborSerializer (QObject *parent=nullptr) | |
Default constructor. | |
bool | handleSpecialNumbers () const |
READ accessor for CborSerializer::handleSpecialNumbers. | |
template<typename T > | |
void | setTypeTag (QCborTag tag=static_cast< QCborTag >(NoTag)) |
Set a tag to always be used when serializing the given type. | |
void | setTypeTag (int metaTypeId, QCborTag tag=static_cast< QCborTag >(NoTag)) |
Set a tag to always be used when serializing the given type. | |
template<typename T > | |
QCborTag | typeTag () const |
Returns a tag registered for the given metaTypeId. | |
QCborTag | typeTag (int metaTypeId) const override |
Returns a tag registered for the given metaTypeId. | |
QCborValue | serialize (const QVariant &data) const |
Serializers a QVariant value to a QCborValue. More... | |
void | serializeTo (QIODevice *device, const QVariant &data, QCborValue::EncodingOptions options=QCborValue::NoTransformation) const |
Serializers a QVariant value to a device. More... | |
QByteArray | serializeTo (const QVariant &data, QCborValue::EncodingOptions options=QCborValue::NoTransformation) const |
Serializers a QVariant value to a byte array. More... | |
template<typename T > | |
QCborValue | serialize (const T &data) const |
Serializers a c++ type to cbor. More... | |
template<typename T > | |
void | serializeTo (QIODevice *device, const T &data, QCborValue::EncodingOptions options=QCborValue::NoTransformation) const |
Serializers a c++ type to a device. More... | |
template<typename T > | |
QByteArray | serializeTo (const T &data, QCborValue::EncodingOptions options=QCborValue::NoTransformation) const |
Serializers a c++ type to a byte array. More... | |
QVariant | deserialize (const QCborValue &cbor, int metaTypeId, QObject *parent=nullptr) const |
Deserializes a QCborValue to a QVariant value, based on the given type id. More... | |
QVariant | deserializeFrom (QIODevice *device, int metaTypeId, QObject *parent=nullptr) const |
Deserializes data from a device to a QVariant value, based on the given type id. More... | |
QVariant | deserializeFrom (const QByteArray &data, int metaTypeId, QObject *parent=nullptr) const |
Deserializes data from a device to a QVariant value, based on the given type id. More... | |
template<typename T > | |
T | deserialize (const QCborValue &cbor, QObject *parent=nullptr) const |
Deserializes cbor to the given c++ type. More... | |
template<typename T > | |
T | deserializeFrom (QIODevice *device, QObject *parent=nullptr) const |
Deserializes data from a device to the given c++ type. More... | |
template<typename T > | |
T | deserializeFrom (const QByteArray &data, QObject *parent=nullptr) const |
Deserializes data from a byte array to the given c++ type. More... | |
std::variant< QCborValue, QJsonValue > | serializeGeneric (const QVariant &value) const override |
Serializes a given variant to either CBOR or JSON, depending on the actual instance. More... | |
QVariant | deserializeGeneric (const std::variant< QCborValue, QJsonValue > &value, int metaTypeId, QObject *parent) const override |
Deserializes CBOR or JSON, depending on the actual instance, to variant. More... | |
Public Member Functions inherited from QtJsonSerializer::SerializerBase | |
bool | allowDefaultNull () const |
READ accessor for QJsonSerializer::allowDefaultNull. | |
bool | keepObjectName () const |
READ accessor for QJsonSerializer::keepObjectName. | |
bool | enumAsString () const |
READ accessor for QJsonSerializer::enumAsString. | |
bool | versionAsString () const |
READ accessor for QJsonSerializer::versionAsString. | |
bool | dateAsTimeStamp () const |
READ accessor for QJsonSerializer::dateAsTimeStamp. | |
bool | useBcp47Locale () const |
READ accessor for QJsonSerializer::useBcp47Locale. | |
ValidationFlags | validationFlags () const |
READ accessor for QJsonSerializer::validationFlags. | |
Polymorphing | polymorphing () const |
READ accessor for QJsonSerializer::polymorphing. | |
MultiMapMode | multiMapMode () const |
READ accessor for QJsonSerializer::multiMapMode. | |
bool | ignoresStoredAttribute () const |
READ accessor for QJsonSerializer::ignoreStoredAttribute. | |
template<typename TConverter > | |
void | addJsonTypeConverter () |
Adds a custom type converter to this serializer. More... | |
void | addJsonTypeConverter (const QSharedPointer< TypeConverter > &converter) |
Adds a custom type converter to this serializer. More... | |
Public Member Functions inherited from QObject | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Protected Member Functions | |
bool | jsonMode () const override |
Returns true, if de/serializing to JSON, and false for CBOR. | |
QList< int > | typesForTag (QCborTag tag) const override |
Protected Member Functions inherited from QtJsonSerializer::SerializerBase | |
SerializerBase (QObject *parent=nullptr) | |
Default constructor. | |
QVariant | getProperty (const char *name) const override |
Returns a property from the serializer. | |
QSharedPointer< const TypeExtractor > | extractor (int metaTypeId) const override |
Returns a reference to an extractor for the given type, or nullptr. | |
QCborValue | serializeSubtype (const QMetaProperty &property, const QVariant &value) const override |
Serialize a subvalue, represented by a meta property. | |
QCborValue | serializeSubtype (int propertyType, const QVariant &value, const QByteArray &traceHint) const override |
Serialize a subvalue, represented by a type id. | |
QVariant | deserializeSubtype (const QMetaProperty &property, const QCborValue &value, QObject *parent) const override |
Deserialize a subvalue, represented by a meta property. | |
QVariant | deserializeSubtype (int propertyType, const QCborValue &value, QObject *parent, const QByteArray &traceHint) const override |
Deserialize a subvalue, represented by a type id. | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
Properties | |
bool | handleSpecialNumbers |
If enabled, specially tagged number types will be automatically deserialized to their type. More... | |
Properties inherited from QtJsonSerializer::SerializerBase | |
bool | allowDefaultNull |
Specifies whether null for value types is allowed or not. More... | |
bool | keepObjectName |
Specifies whether the objectName property of QObjects should be serialized. More... | |
bool | enumAsString |
Specifies whether enums should be serialized as integer or as string. More... | |
bool | versionAsString |
Specifies whether enums should be serialized as array of integers or as string. More... | |
bool | dateAsTimeStamp |
Specifies whether datetimes should be serialized as datetime string or as unix timestamp. More... | |
bool | useBcp47Locale |
Specifies whether serializing a QLocale should use the bcp47 format. More... | |
ValidationFlags | validationFlags |
Specifies how strictly the serializer should verify data when deserializing. More... | |
Polymorphing | polymorphing |
Specifies how the serializer should treat polymorphism for QObject classes. More... | |
MultiMapMode | multiMapMode |
Specifies how multi maps and sets should be serialized. More... | |
bool | ignoreStoredAttribute |
Specifies whether the STORED attribute on properties has any effect. | |
Properties inherited from QObject | |
objectName | |
Additional Inherited Members | |
Static Public Member Functions inherited from QtJsonSerializer::SerializerBase | |
template<typename TType , typename TExtractor > | |
static void | registerExtractor () |
Registers a custom extractor for the given type. More... | |
static void | registerExtractor (int metaTypeId, const QSharedPointer< TypeExtractor > &extractor) |
Registers a custom extractor for the given type. More... | |
template<typename T > | |
static void | registerListConverters () |
Registers a custom type for list converisons. More... | |
template<typename T > | |
static void | registerSetConverters () |
Registers a custom type for set converisons. More... | |
template<typename TKey , typename TValue , bool mapTypes = true, bool hashTypes = true> | |
static void | registerMapConverters () |
Registers a custom type for map converisons. More... | |
template<typename T > | |
static void | registerPointerConverters () |
Registers a custom type for QSharedPointer and QPointer converisons. More... | |
template<typename T > | |
static void | registerBasicConverters () |
Registers a custom type for list, set map and optional converisons. Also include pointer converters, if applicable. More... | |
template<typename T , typename U > | |
static void | registerPairConverters () |
Registers two types for pair conversion. More... | |
template<typename... TArgs> | |
static void | registerTupleConverters () |
Registers a number of types for std::tuple conversion. More... | |
template<typename T > | |
static void | registerOptionalConverters () |
Registers a custom type for std::optional converisons. More... | |
template<typename... TArgs> | |
static void | registerVariantConverters () |
Registers a custom type for std::variant converisons. More... | |
template<typename TConverter , int Priority = TypeConverter::Priority::Standard> | |
static void | addJsonTypeConverterFactory () |
Globally registers a converter factory to provide converters for all QJsonSerializer instances. More... | |
static void | addJsonTypeConverterFactory (TypeConverterFactory *factory) |
Globally registers a converter factory to provide converters for all QJsonSerializer instances. More... | |
Static Public Member Functions inherited from QObject | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
Public Attributes inherited from QObject | |
typedef | QObjectList |
A class to serialize and deserialize c++ classes to and from CBOR.
This class is one of the modules core component. It performs the de/serialization of C++ classes from and to CBOR.
The serializer supports a bunch of types by default, but there are limitations. Check the main page Usage Hints for details about what is possible and what is not.
To extend the serializers functionality, create a custom implementation of the TypeConverter class. Check it's documentation for more details and an example on how to. Once you've created a custom converter class, you can add it to a serializer instance by using SerializerBase::addJsonTypeConverter.
Definition at line 11 of file cborserializer.h.
enum QtJsonSerializer::CborSerializer::CustomTags : std::underlying_type_t< QCborTag > |
Enumerator | |
---|---|
Color | Tag used for QColor. |
Font | Tag used for QFont. |
Enum | Tag used for enums. |
Flags | Tag used for flags. |
ConstructedObject | Tag used for constructed object (GenericObject + standard object) |
Pair | Tag used for QPair/std::pair. |
MultiMap | Tag used for QMultiMap/QMultiHash. |
VersionNumber | Tag used for QVersionNumber. |
Tuple | Tag used for std::tuple. |
BitArray | Tag used for QBitArray. |
Date | Tag used for QDate (short ISO format) |
Time | Tag used for QTime (short ISO format) |
LocaleISO | Tag used for QLocale, encoded via the ISO format. |
LocaleBCP47 | Tag used for QLocale, encoded via the BCP47 format. |
GeomSize | Tag used for QSize/QSizeF. |
GeomPoint | Tag used for QPoint/QPointF. |
GeomLine | Tag used for QLine/QLineF. |
GeomRect | Tag used for QRect/QRectF. |
ChronoNanoSeconds | Tag used for std::chrono::nanoseconds. |
ChronoMicroSeconds | Tag used for std::chrono::microseconds. |
ChronoMilliSeconds | Tag used for std::chrono::milliseconds. |
ChronoSeconds | Tag used for std::chrono::seconds. |
ChronoMinutes | Tag used for std::chrono::minutes. |
ChronoHours | Tag used for std::chrono::hours. |
Definition at line 33 of file cborserializer.h.
enum QtJsonSerializer::CborSerializer::ExtendedTags : std::underlying_type_t< QCborTag > |
Additional official CBOR-Tags, taken from https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml.
Definition at line 20 of file cborserializer.h.
QtJsonSerializer::CborSerializer::deserialize | ( | const QCborValue & | cbor, |
int | metaTypeId, | ||
QObject * | parent = nullptr |
||
) | const |
Deserializes a QCborValue to a QVariant value, based on the given type id.
cbor | The data to be deserialized |
metaTypeId | The target type of the deserialization |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
QtJsonSerializer::CborSerializer::deserialize | ( | const QCborValue & | cbor, |
QObject * | parent = nullptr |
||
) | const |
Deserializes cbor to the given c++ type.
T | The type of the data to be deserialized |
cbor | The data to be deserialized |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
Definition at line 172 of file cborserializer.h.
QtJsonSerializer::CborSerializer::deserializeFrom | ( | const QByteArray & | data, |
int | metaTypeId, | ||
QObject * | parent = nullptr |
||
) | const |
Deserializes data from a device to a QVariant value, based on the given type id.
data | The data to read the json to be deserialized from |
metaTypeId | The target type of the deserialization |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
QtJsonSerializer::CborSerializer::deserializeFrom | ( | const QByteArray & | data, |
QObject * | parent = nullptr |
||
) | const |
Deserializes data from a byte array to the given c++ type.
T | The type of the data to be deserialized |
data | The data to read the json to be deserialized from |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
Definition at line 186 of file cborserializer.h.
QtJsonSerializer::CborSerializer::deserializeFrom | ( | QIODevice * | device, |
int | metaTypeId, | ||
QObject * | parent = nullptr |
||
) | const |
Deserializes data from a device to a QVariant value, based on the given type id.
device | The device to read the json to be deserialized from |
metaTypeId | The target type of the deserialization |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
QtJsonSerializer::CborSerializer::deserializeFrom | ( | QIODevice * | device, |
QObject * | parent = nullptr |
||
) | const |
Deserializes data from a device to the given c++ type.
T | The type of the data to be deserialized |
device | The device to read the json to be deserialized from |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
Definition at line 179 of file cborserializer.h.
|
overridevirtual |
Deserializes CBOR or JSON, depending on the actual instance, to variant.
value | The CBOR/JSON data to be deserialized |
metaTypeId | The target type of the deserialization |
parent | The parent object of the result. Only used if the returend value is a QObject* |
DeserializationException | Thrown if the deserialization fails |
Implements QtJsonSerializer::SerializerBase.
QtJsonSerializer::CborSerializer::serialize | ( | const QVariant & | data | ) | const |
Serializers a QVariant value to a QCborValue.
data | The data to be serialized |
SerializationException | Thrown if the serialization fails |
QtJsonSerializer::CborSerializer::serialize | ( | const T & | data | ) | const |
Serializers a c++ type to cbor.
T | The type of the data to be serialized |
data | The data to be serialized |
SerializationException | Thrown if the serialization fails |
Definition at line 151 of file cborserializer.h.
|
overridevirtual |
Serializes a given variant to either CBOR or JSON, depending on the actual instance.
value | The data to be serialized |
SerializationException | Thrown if the serialization fails |
Implements QtJsonSerializer::SerializerBase.
QtJsonSerializer::CborSerializer::serializeTo | ( | const QVariant & | data, |
QCborValue::EncodingOptions | options = QCborValue::NoTransformation |
||
) | const |
Serializers a QVariant value to a byte array.
data | The data to be serialized |
options | The encoding options for the generated cbor |
SerializationException | Thrown if the serialization fails |
QtJsonSerializer::CborSerializer::serializeTo | ( | const T & | data, |
QCborValue::EncodingOptions | options = QCborValue::NoTransformation |
||
) | const |
Serializers a c++ type to a byte array.
T | The type of the data to be serialized |
data | The data to be serialized |
options | The encoding options for the generated cbor |
SerializationException | Thrown if the serialization fails |
Definition at line 165 of file cborserializer.h.
QtJsonSerializer::CborSerializer::serializeTo | ( | QIODevice * | device, |
const QVariant & | data, | ||
QCborValue::EncodingOptions | options = QCborValue::NoTransformation |
||
) | const |
Serializers a QVariant value to a device.
device | The device to write the json to |
data | The data to be serialized |
options | The encoding options for the generated cbor |
SerializationException | Thrown if the serialization fails |
QtJsonSerializer::CborSerializer::serializeTo | ( | QIODevice * | device, |
const T & | data, | ||
QCborValue::EncodingOptions | options = QCborValue::NoTransformation |
||
) | const |
Serializers a c++ type to a device.
T | The type of the data to be serialized |
device | The device to write the json to |
data | The data to be serialized |
options | The encoding options for the generated cbor |
SerializationException | Thrown if the serialization fails |
Definition at line 158 of file cborserializer.h.
|
readwrite |
If enabled, specially tagged number types will be automatically deserialized to their type.
Default: false
Applies to deserialization only.
The following table shows which tags are understood by the serializer and how they are deserialized. The 'Checked' column indicates, if the data is tested to fit into the type before deserialzing. If that's not the case, data can be lost without notice.
Tag | Types | Checked |
---|---|---|
QCborKnownTags::PositiveBignum | q[u]int8 - q[u]int64 (depends on data size) | yes |
QCborKnownTags::NegativeBignum | qint8 - qint64 (depends on data size) | yes |
QCborKnownTags::Decimal | qreal | no |
QCborKnownTags::Bigfloat | qreal | no |
CborSerializer::ExtendedTags::RationaleNumber | qreal | no |
Accessors | |
---|---|
READ | handleSpecialNumbers() |
WRITE | setHandleSpecialNumbers() |
NOTIFY | handleSpecialNumbersChanged() |
Definition at line 16 of file cborserializer.h.