1 #ifndef QTJSONSERIALIZER_TYPECONVERTER_H
2 #define QTJSONSERIALIZER_TYPECONVERTER_H
4 #include "QtJsonSerializer/qtjsonserializer_global.h"
9 #include <QtCore/qmetatype.h>
10 #include <QtCore/qmetaobject.h>
11 #include <QtCore/qjsonvalue.h>
12 #include <QtCore/qcborvalue.h>
13 #include <QtCore/qvariant.h>
14 #include <QtCore/qsharedpointer.h>
34 virtual void emplace(
QVariant &target,
const QVariant &value,
int index = -1)
const = 0;
37 class TypeConverterPrivate;
44 static constexpr
auto NoTag = static_cast<QCborTag>(std::numeric_limits<std::underlying_type_t<QCborTag>>::max());
48 ExtremlyLow = -0x00FFFFFF,
49 VeryLow = -0x0000FFFF,
51 Standard = 0x00000000,
53 VeryHigh = 0x0000FFFF,
54 ExtremlyHigh = 0x00FFFFFF
74 virtual bool jsonMode()
const = 0;
76 virtual QVariant getProperty(
const char *name)
const = 0;
78 virtual QCborTag typeTag(
int metaTypeId)
const = 0;
101 int priority()
const;
103 void setPriority(
int priority);
111 virtual bool canConvert(
int metaTypeId)
const = 0;
117 virtual int guessType(QCborTag tag, QCborValue::Type dataType)
const;
121 QCborValue::Type dataType)
const;
137 #define QT_JSONSERIALIZER_TYPECONVERTER_NAME(className) inline QByteArray name() const override { \
138 static_assert(std::is_same_v<className, std::decay_t<decltype(*this)>>); \
139 return QByteArrayLiteral(#className); \
156 template <
typename TConverter,
int OverwritePriority = TypeConverter::Priority::Standard>
165 template<
typename TConverter,
int OverwritePriority>
169 if (OverwritePriority != TypeConverter::Priority::Standard)
170 converter->setPriority(OverwritePriority);
176 #endif // QTJSONSERIALIZER_TYPECONVERTER_H