diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-12-09 10:37:28 +0100 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2020-02-25 15:43:15 +0100 |
commit | a68e4f3b96a82a93898f381e8ddc7f50f9c89d40 (patch) | |
tree | 3c9261a96178ac053ab1b777997aa6566d02be3f /src/corelib/kernel/qvariant_p.h | |
parent | 5e908ada6759b27cd50cf860b8028f8bd0d6c94c (diff) |
Use the new QMetaType API in QVariant
Change-Id: I5495ee1159864ebd64083fadbfac7e07177ed406
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant_p.h')
-rw-r--r-- | src/corelib/kernel/qvariant_p.h | 109 |
1 files changed, 1 insertions, 108 deletions
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 94781a9957..aa89d42092 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -234,7 +234,7 @@ public: QVariantComparator(const QVariant::Private *a, const QVariant::Private *b) : m_a(a), m_b(b) { - Q_ASSERT(a->type == b->type); + Q_ASSERT(a->type() == b->type()); } template<typename T> @@ -346,113 +346,6 @@ protected: const QVariant::Private *m_d; }; -template<class Filter> -class QVariantConstructor -{ - template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted> - struct FilteredConstructor { - FilteredConstructor(const QVariantConstructor &tc) - { - v_construct<T>(tc.m_x, tc.m_copy); - tc.m_x->is_null = !tc.m_copy; - } - }; - template<typename T> - struct FilteredConstructor<T, /* IsAcceptedType = */ false> { - FilteredConstructor(const QVariantConstructor &tc) - { - // ignore types that lives outside of the current library - tc.m_x->type = QMetaType::UnknownType; - } - }; -public: - QVariantConstructor(QVariant::Private *x, const void *copy) - : m_x(x) - , m_copy(copy) - {} - - template<typename T> - void delegate(const T*) - { - FilteredConstructor<T>(*this); - } - - void delegate(const QMetaTypeSwitcher::NotBuiltinType*) - { - // QVariantConstructor is used only for built-in types. - Q_ASSERT(false); - } - - void delegate(const void*) - { - qWarning("Trying to create a QVariant instance of QMetaType::Void type, an invalid QVariant will be constructed instead"); - m_x->type = QMetaType::UnknownType; - m_x->is_shared = false; - m_x->is_null = !m_copy; - } - - void delegate(const QMetaTypeSwitcher::UnknownType*) - { - if (m_x->type != QMetaType::UnknownType) { - qWarning("Trying to construct an instance of an invalid type, type id: %i", m_x->type); - m_x->type = QMetaType::UnknownType; - } - m_x->is_shared = false; - m_x->is_null = !m_copy; - } -private: - QVariant::Private *m_x; - const void *m_copy; -}; - -template<class Filter> -class QVariantDestructor -{ - template<typename T, bool IsAcceptedType = Filter::template Acceptor<T>::IsAccepted> - struct FilteredDestructor { - FilteredDestructor(QVariant::Private *d) - { - v_clear<T>(d); - } - }; - template<typename T> - struct FilteredDestructor<T, /* IsAcceptedType = */ false> { - FilteredDestructor(QVariant::Private *) - { - // It is not possible to create not accepted type - Q_ASSERT(false); - } - }; - -public: - QVariantDestructor(QVariant::Private *d) - : m_d(d) - {} - ~QVariantDestructor() - { - m_d->type = QMetaType::UnknownType; - m_d->is_null = true; - m_d->is_shared = false; - } - - template<typename T> - void delegate(const T*) - { - FilteredDestructor<T> cleaner(m_d); - } - - void delegate(const QMetaTypeSwitcher::NotBuiltinType*) - { - // QVariantDestructor class is used only for a built-in type - Q_ASSERT(false); - } - // Ignore nonconstructible type - void delegate(const QMetaTypeSwitcher::UnknownType*) {} - void delegate(const void*) { Q_ASSERT(false); } -private: - QVariant::Private *m_d; -}; - namespace QVariantPrivate { Q_CORE_EXPORT void registerHandler(const int /* Modules::Names */ name, const QVariant::Handler *handler); } |