10#include <QtCore/qglobal.h>
11#include <QtCore/qatomic.h>
12#include <QtCore/qbytearray.h>
13#include <QtCore/qcompare.h>
14#include <QtCore/qdatastream.h>
15#include <QtCore/qflags.h>
16#include <QtCore/qfloat16.h>
17#include <QtCore/qhashfunctions.h>
18#include <QtCore/qiterable.h>
19#include <QtCore/qmetacontainer.h>
21#include <QtCore/qobjectdefs.h>
23#include <QtCore/qscopeguard.h>
24#include <QtCore/qttypetraits.h>
33#include <QtCore/qxptype_traits.h>
36#error qmetatype.h must be included before any header file that defines Bool
42enum class QCborSimpleType : quint8;
51#define QT_FOR_EACH_STATIC_PRIMITIVE_NON_VOID_TYPE(F)
55 F(LongLong, 4
, qlonglong)
56 F(ULongLong, 5
, qulonglong)
61 F(Char16, 56
, char16_t)
62 F(Char32, 57
, char32_t)
67 F(SChar, 40
, signed char)
68 F(Nullptr, 51
, std::nullptr_t)
69 F(QCborSimpleType, 52
, QCborSimpleType)
71#define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)
75#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)
76 F(VoidStar, 31
, void*)
78#if QT_CONFIG(easingcurve)
79#define QT_FOR_EACH_STATIC_EASINGCURVE(F)
80 F(QEasingCurve, 29
, QEasingCurve)
82#define QT_FOR_EACH_STATIC_EASINGCURVE(F)
85#if QT_CONFIG(itemmodel)
86#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
87 F(QModelIndex, 42
, QModelIndex)
88 F(QPersistentModelIndex, 50
, QPersistentModelIndex)
90#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
93#if QT_CONFIG(regularexpression)
94# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F)
95 F(QRegularExpression, 44
, QRegularExpression)
97# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F)
100# define QT_FOR_EACH_STATIC_QVARIANT(F)
101 F(QVariant, 41
, QVariant)
103# define QT_FOR_EACH_STATIC_QVARIANT(F)
106#define QT_FOR_EACH_STATIC_CORE_CLASS(F)
108 F(QString, 10
, QString)
109 F(QByteArray, 12
, QByteArray)
110 F(QBitArray, 13
, QBitArray)
113 F(QDateTime, 16
, QDateTime)
115 F(QLocale, 18
, QLocale)
117 F(QRectF, 20
, QRectF)
119 F(QSizeF, 22
, QSizeF)
121 F(QLineF, 24
, QLineF)
122 F(QPoint, 25
, QPoint)
123 F(QPointF, 26
, QPointF)
128 F(QJsonValue, 45
, QJsonValue)
129 F(QJsonObject, 46
, QJsonObject)
130 F(QJsonArray, 47
, QJsonArray)
131 F(QJsonDocument, 48
, QJsonDocument)
132 F(QCborValue, 53
, QCborValue)
133 F(QCborArray, 54
, QCborArray)
134 F(QCborMap, 55
, QCborMap)
135 F(Float16, 63
, qfloat16)
138#define QT_FOR_EACH_STATIC_CORE_POINTER(F)
139 F(QObjectStar, 39
, QObject*)
142# define QT_FOR_EACH_STATIC_CORE_QVARIANT_TEMPLATE(F)
143 F(QVariantMap, 8
, QVariantMap)
144 F(QVariantList, 9
, QVariantList)
145 F(QVariantHash, 28
, QVariantHash)
146 F(QVariantPair, 58
, QVariantPair)
149# define QT_FOR_EACH_STATIC_CORE_QVARIANT_TEMPLATE(F)
152#define QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)
154 F(QByteArrayList, 49
, QByteArrayList)
155 F(QStringList, 11
, QStringList)
157#if QT_CONFIG(shortcut)
158#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)
159 F(QKeySequence, 0x100b
, QKeySequence)
161#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)
164#define QT_FOR_EACH_STATIC_GUI_CLASS(F)
165 F(QFont, 0x1000
, QFont)
166 F(QPixmap, 0x1001
, QPixmap)
167 F(QBrush, 0x1002
, QBrush)
168 F(QColor, 0x1003
, QColor)
169 F(QPalette, 0x1004
, QPalette)
170 F(QIcon, 0x1005
, QIcon)
171 F(QImage, 0x1006
, QImage)
172 F(QPolygon, 0x1007
, QPolygon)
173 F(QRegion, 0x1008
, QRegion)
174 F(QBitmap, 0x1009
, QBitmap)
175 F(QCursor, 0x100a
, QCursor)
177 F(QPen, 0x100c
, QPen)
178 F(QTextLength, 0x100d
, QTextLength)
179 F(QTextFormat, 0x100e
, QTextFormat)
180 F(QTransform, 0x1010
, QTransform)
181 F(QMatrix4x4, 0x1011
, QMatrix4x4)
182 F(QVector2D, 0x1012
, QVector2D)
183 F(QVector3D, 0x1013
, QVector3D)
184 F(QVector4D, 0x1014
, QVector4D)
185 F(QQuaternion, 0x1015
, QQuaternion)
186 F(QPolygonF, 0x1016
, QPolygonF)
187 F(QColorSpace, 0x1017
, QColorSpace)
190#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)
191 F(QSizePolicy, 0x2000
, QSizePolicy)
194#define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)
195 F(ULong, -1
, ulong, "unsigned long")
196 F(UInt, -1
, uint, "unsigned int")
197 F(UShort, -1
, ushort, "unsigned short")
198 F(UChar, -1
, uchar, "unsigned char")
199 F(LongLong, -1
, qlonglong, "long long")
200 F(ULongLong, -1
, qulonglong, "unsigned long long")
201 F(SChar, -1
, signed char, "qint8")
202 F(UChar, -1
, uchar, "quint8")
203 F(Short, -1
, short, "qint16")
204 F(UShort, -1
, ushort, "quint16")
205 F(Int, -1
, int, "qint32")
206 F(UInt, -1
, uint, "quint32")
207 F(LongLong, -1
, qlonglong, "qint64")
208 F(ULongLong, -1
, qulonglong, "quint64")
209 F(QByteArrayList, -1
, QByteArrayList, "QList<QByteArray>")
210 F(QStringList, -1
, QStringList, "QList<QString>")
214#define QT_FOR_EACH_STATIC_VARIANT_ALIAS_TYPE(F)
215 F(QVariantList, -1
, QVariantList, "QList<QVariant>")
216 F(QVariantMap, -1
, QVariantMap, "QMap<QString,QVariant>")
217 F(QVariantHash, -1
, QVariantHash, "QHash<QString,QVariant>")
218 F(QVariantPair, -1
, QVariantPair, "QPair<QVariant,QVariant>")
221#define QT_FOR_EACH_STATIC_VARIANT_ALIAS_TYPE(F)
224#define QT_FOR_EACH_STATIC_TYPE(F)
233#define QT_DEFINE_METATYPE_ID(TypeName, Id, Name)
236#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F)
243#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F)
247#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F)
264#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
) || defined(QT_BOOTSTRAPPED) || !defined(Q_CC_MSVC)
268# define QMTI_MUTABLE mutable
318
319
320
321template<
typename From,
typename To>
327 template<
typename T,
bool>
329 template<
typename T,
bool>
331 template<
typename T,
bool>
333 template<
typename,
typename>
340 template<
typename T,
typename ODR_VIOLATION_PREVENTER>
346 using type =
decltype(check(
static_cast<T *>(
nullptr)));
350 template <
typename T,
typename ODR_VIOLATION_PREVENTER =
void>
370 "Meta Types must be fully defined");
371 static_assert(!
std::is_reference_v<T>,
372 "Meta Types cannot be non-const references or rvalue references.");
374 using Pointed = std::remove_pointer_t<T>;
375 static_assert(is_complete<Pointed,
void>::value,
376 "Pointer Meta Types must either point to fully-defined types "
377 "or be declared with Q_DECLARE_OPAQUE_POINTER(T *)");
391 FirstCoreType = Bool,
392 LastCoreType = Float16,
393 FirstGuiType = QFont,
394 LastGuiType = QColorSpace,
395 FirstWidgetsType = QSizePolicy,
396 LastWidgetsType = QSizePolicy,
397 HighestInternalId = LastWidgetsType,
399 QReal =
sizeof(qreal) ==
sizeof(
double) ? Double : Float,
407 UnknownType = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5,
408 Double = 6, Long = 32, Short = 33, Char = 34, ULong = 35, UShort = 36,
409 UChar = 37, Float = 38,
411 QChar = 7, QString = 10, QStringList = 11, QByteArray = 12,
412 QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
413 QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
414 QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26,
415 QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
416 QPersistentModelIndex = 50, QRegularExpression = 44,
417 QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
418 QByteArrayList = 49, QObjectStar = 39, SChar = 40,
421 QVariantMap = 8, QVariantList = 9, QVariantHash = 28, QVariantPair = 58,
422 QCborSimpleType = 52, QCborValue = 53, QCborArray = 54, QCborMap = 55,
423 Char16 = 56, Char32 = 57,
424 Int128 = 59, UInt128 = 60, Float128 = 61, BFloat16 = 62, Float16 = 63,
427 QFont = 0x1000, QPixmap = 0x1001, QBrush = 0x1002, QColor = 0x1003, QPalette = 0x1004,
428 QIcon = 0x1005, QImage = 0x1006, QPolygon = 0x1007, QRegion = 0x1008, QBitmap = 0x1009,
429 QCursor = 0x100a, QKeySequence = 0x100b, QPen = 0x100c, QTextLength = 0x100d, QTextFormat = 0x100e,
430 QTransform = 0x1010, QMatrix4x4 = 0x1011, QVector2D = 0x1012,
431 QVector3D = 0x1013, QVector4D = 0x1014, QQuaternion = 0x1015, QPolygonF = 0x1016, QColorSpace = 0x1017,
434 QSizePolicy = 0x2000,
442 NeedsConstruction = 0x1,
443 NeedsDestruction = 0x2,
444 RelocatableType = 0x4,
445#if QT_DEPRECATED_SINCE(6
, 0
)
446 MovableType Q_DECL_ENUMERATOR_DEPRECATED_X(
"Use RelocatableType instead.") = RelocatableType,
448 PointerToQObject = 0x8,
449 IsEnumeration = 0x10,
450 SharedPointerToQObject = 0x20,
451 WeakPointerToQObject = 0x40,
452 TrackingPointerToQObject = 0x80,
453 IsUnsignedEnumeration = 0x100,
455 PointerToGadget = 0x400,
460 NeedsCopyConstruction = 0x4000,
461 NeedsMoveConstruction = 0x8000,
463 Q_DECLARE_FLAGS(TypeFlags, TypeFlag)
465 static void registerNormalizedTypedef(
const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, QMetaType type);
467#if QT_DEPRECATED_SINCE(6
, 0
)
468 QT_DEPRECATED_VERSION_6_0
469 static int type(
const char *typeName)
470 {
return QMetaType::fromName(typeName).rawId(); }
471 QT_DEPRECATED_VERSION_6_0
472 static int type(
const QT_PREPEND_NAMESPACE(QByteArray) &typeName)
473 {
return QMetaType::fromName(typeName).rawId(); }
474 QT_DEPRECATED_VERSION_6_0
475 static const char *typeName(
int type)
476 {
return QMetaType(type).name(); }
477 QT_DEPRECATED_VERSION_6_0
478 static int sizeOf(
int type)
479 {
return int(QMetaType(type).sizeOf()); }
480 QT_DEPRECATED_VERSION_6_0
481 static TypeFlags typeFlags(
int type)
482 {
return QMetaType(type).flags(); }
483 QT_DEPRECATED_VERSION_6_0
484 static const QMetaObject *metaObjectForType(
int type)
485 {
return QMetaType(type).metaObject(); }
486 QT_DEPRECATED_VERSION_6_0
487 static void *create(
int type,
const void *copy =
nullptr)
488 {
return QMetaType(type).create(copy); }
489 QT_DEPRECATED_VERSION_6_0
490 static void destroy(
int type,
void *data)
491 {
return QMetaType(type).destroy(data); }
492 QT_DEPRECATED_VERSION_6_0
493 static void *construct(
int type,
void *where,
const void *copy)
494 {
return QMetaType(type).construct(where, copy); }
495 QT_DEPRECATED_VERSION_6_0
496 static void destruct(
int type,
void *where)
497 {
return QMetaType(type).destruct(where); }
499 static bool isRegistered(
int type);
501 explicit QMetaType(
int type);
502 explicit constexpr QMetaType(
const QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {}
503 constexpr QMetaType() =
default;
505#if QT_CORE_REMOVED_SINCE(6
, 9
)
506 bool isValid()
const;
507 bool isRegistered()
const;
509 constexpr bool isValid(QT6_DECL_NEW_OVERLOAD)
const noexcept;
510 inline bool isRegistered(QT6_DECL_NEW_OVERLOAD)
const noexcept;
511 void registerType()
const
516#if QT_CORE_REMOVED_SINCE(6
, 1
) || defined(Q_QDOC)
521 int id(
int = 0)
const
523 return registerHelper();
528 Q_PRE(!isValid(QT6_CALL_NEW_OVERLOAD) || isRegistered(QT6_CALL_NEW_OVERLOAD));
529 return d_ptr ? d_ptr->typeId.loadRelaxed() : 0;
532 constexpr qsizetype sizeOf()
const;
533 constexpr qsizetype alignOf()
const;
534 constexpr TypeFlags flags()
const;
535 constexpr const QMetaObject *metaObject()
const;
536 constexpr const char *name()
const;
538 void *create(
const void *copy =
nullptr)
const;
539 void destroy(
void *data)
const;
540 void *construct(
void *where,
const void *copy =
nullptr)
const;
541 void destruct(
void *data)
const;
542 QPartialOrdering compare(
const void *lhs,
const void *rhs)
const;
543 bool equals(
const void *lhs,
const void *rhs)
const;
545 bool isDefaultConstructible()
const noexcept {
return d_ptr && isDefaultConstructible(d_ptr); }
546 bool isCopyConstructible()
const noexcept {
return d_ptr && isCopyConstructible(d_ptr); }
547 bool isMoveConstructible()
const noexcept {
return d_ptr && isMoveConstructible(d_ptr); }
548 bool isDestructible()
const noexcept {
return d_ptr && isDestructible(d_ptr); }
549 bool isEqualityComparable()
const;
550 bool isOrdered()
const;
552#ifndef QT_NO_DATASTREAM
553 bool save(QDataStream &stream,
const void *data)
const;
554 bool load(QDataStream &stream,
void *data)
const;
555 bool hasRegisteredDataStreamOperators()
const;
557#if QT_DEPRECATED_SINCE(6
, 0
)
558 QT_DEPRECATED_VERSION_6_0
559 static bool save(QDataStream &stream,
int type,
const void *data)
560 {
return QMetaType(type).save(stream, data); }
561 QT_DEPRECATED_VERSION_6_0
562 static bool load(QDataStream &stream,
int type,
void *data)
563 {
return QMetaType(type).load(stream, data); }
567 QMetaType underlyingType()
const;
570 constexpr static QMetaType fromType();
571 static QMetaType fromName(QByteArrayView name);
573 friend bool comparesEqual(
const QMetaType &lhs,
574 const QMetaType &rhs)
576 if (lhs.d_ptr == rhs.d_ptr)
578 if (!lhs.d_ptr || !rhs.d_ptr)
581 const int aId = lhs.id();
582 const int bId = rhs.id();
585 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QMetaType)
586#ifndef QT_NO_DEBUG_STREAM
588 friend Q_CORE_EXPORT QDebug operator<<(QDebug d, QMetaType m);
590 bool debugStream(QDebug& dbg,
const void *rhs);
591 bool hasRegisteredDebugStreamOperator()
const;
593#if QT_DEPRECATED_SINCE(6
, 0
)
594 QT_DEPRECATED_VERSION_6_0
595 static bool debugStream(QDebug& dbg,
const void *rhs,
int typeId)
596 {
return QMetaType(typeId).debugStream(dbg, rhs); }
598 QT_DEPRECATED_VERSION_6_0
599 static bool hasRegisteredDebugStreamOperator()
600 {
return QMetaType::fromType<T>().hasRegisteredDebugStreamOperator(); }
601 QT_DEPRECATED_VERSION_6_0
602 static bool hasRegisteredDebugStreamOperator(
int typeId)
603 {
return QMetaType(typeId).hasRegisteredDebugStreamOperator(); }
609 using ConverterFunction = std::function<
bool(
const void *src,
void *target)>;
612 using MutableViewFunction = std::function<
bool(
void *src,
void *target)>;
615 template<
typename From,
typename To>
616 static bool registerConverter()
618 return registerConverter<From, To>(QtPrivate::convertImplicit<From, To>);
622 template<
typename From,
typename To>
623 static bool registerConverter(To(From::*function)()
const)
625 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
626 "QMetaType::registerConverter: At least one of the types must be a custom type.");
628 const QMetaType fromType = QMetaType::fromType<From>();
629 const QMetaType toType = QMetaType::fromType<To>();
630 auto converter = [function](
const void *from,
void *to) ->
bool {
631 const From *f =
static_cast<
const From *>(from);
632 To *t =
static_cast<To *>(to);
633 *t = (f->*function)();
636 return registerConverterImpl<From, To>(converter, fromType, toType);
640 template<
typename From,
typename To>
641 static bool registerMutableView(To(From::*function)())
643 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
644 "QMetaType::registerMutableView: At least one of the types must be a custom type.");
646 const QMetaType fromType = QMetaType::fromType<From>();
647 const QMetaType toType = QMetaType::fromType<To>();
648 auto view = [function](
void *from,
void *to) ->
bool {
649 From *f =
static_cast<From *>(from);
650 To *t =
static_cast<To *>(to);
651 *t = (f->*function)();
654 return registerMutableViewImpl<From, To>(view, fromType, toType);
658 template<
typename From,
typename To>
659 static bool registerConverter(To(From::*function)(
bool*)
const)
661 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
662 "QMetaType::registerConverter: At least one of the types must be a custom type.");
664 const QMetaType fromType = QMetaType::fromType<From>();
665 const QMetaType toType = QMetaType::fromType<To>();
666 auto converter = [function](
const void *from,
void *to) ->
bool {
667 const From *f =
static_cast<
const From *>(from);
668 To *t =
static_cast<To *>(to);
670 *t = (f->*function)(&result);
675 return registerConverterImpl<From, To>(converter, fromType, toType);
679 template<
typename From,
typename To,
typename UnaryFunction>
680 static bool registerConverter(UnaryFunction function)
682 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
683 "QMetaType::registerConverter: At least one of the types must be a custom type.");
685 const QMetaType fromType = QMetaType::fromType<From>();
686 const QMetaType toType = QMetaType::fromType<To>();
687 auto converter = [function = std::move(function)](
const void *from,
void *to) ->
bool {
688 const From *f =
static_cast<
const From *>(from);
689 To *t =
static_cast<To *>(to);
690 auto &&r = function(*f);
691 if constexpr (std::is_same_v<q20::remove_cvref_t<
decltype(r)>, std::optional<To>>) {
694 *t = *std::forward<
decltype(r)>(r);
696 *t = std::forward<
decltype(r)>(r);
700 return registerConverterImpl<From, To>(std::move(converter), fromType, toType);
704 template<
typename From,
typename To,
typename UnaryFunction>
705 static bool registerMutableView(UnaryFunction function)
707 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
708 "QMetaType::registerMutableView: At least one of the types must be a custom type.");
710 const QMetaType fromType = QMetaType::fromType<From>();
711 const QMetaType toType = QMetaType::fromType<To>();
712 auto view = [function = std::move(function)](
void *from,
void *to) ->
bool {
713 From *f =
static_cast<From *>(from);
714 To *t =
static_cast<To *>(to);
718 return registerMutableViewImpl<From, To>(std::move(view), fromType, toType);
722 template<
typename From,
typename To>
723 static bool registerConverterImpl(ConverterFunction converter, QMetaType fromType, QMetaType toType)
725 if (registerConverterFunction(std::move(converter), fromType, toType)) {
726 static const auto unregister = qScopeGuard([=] {
727 unregisterConverterFunction(fromType, toType);
735 template<
typename From,
typename To>
736 static bool registerMutableViewImpl(MutableViewFunction view, QMetaType fromType, QMetaType toType)
738 if (registerMutableViewFunction(std::move(view), fromType, toType)) {
739 static const auto unregister = qScopeGuard([=] {
740 unregisterMutableViewFunction(fromType, toType);
749 static bool convert(QMetaType fromType,
const void *from, QMetaType toType,
void *to);
750 static bool canConvert(QMetaType fromType, QMetaType toType);
752 static bool view(QMetaType fromType,
void *from, QMetaType toType,
void *to);
753 static bool canView(QMetaType fromType, QMetaType toType);
754#if QT_DEPRECATED_SINCE(6
, 0
)
755 QT_DEPRECATED_VERSION_6_0
756 static bool convert(
const void *from,
int fromTypeId,
void *to,
int toTypeId)
757 {
return convert(QMetaType(fromTypeId), from, QMetaType(toTypeId), to); }
758 QT_DEPRECATED_VERSION_6_0
759 static bool compare(
const void *lhs,
const void *rhs,
int typeId,
int *result)
762 auto c = t.compare(lhs, rhs);
763 if (c == QPartialOrdering::Unordered) {
766 }
else if (c == QPartialOrdering::Less) {
769 }
else if (c == QPartialOrdering::Equivalent) {
777 QT_DEPRECATED_VERSION_6_0
778 static bool equals(
const void *lhs,
const void *rhs,
int typeId,
int *result)
781 if (!t.isEqualityComparable())
783 *result = t.equals(lhs, rhs) ? 0 : -1;
788 template<
typename From,
typename To>
789 static bool hasRegisteredConverterFunction()
791 return hasRegisteredConverterFunction(
792 QMetaType::fromType<From>(), QMetaType::fromType<To>());
795 static bool hasRegisteredConverterFunction(QMetaType fromType, QMetaType toType);
797 template<
typename From,
typename To>
798 static bool hasRegisteredMutableViewFunction()
800 return hasRegisteredMutableViewFunction(
801 QMetaType::fromType<From>(), QMetaType::fromType<To>());
804 static bool hasRegisteredMutableViewFunction(QMetaType fromType, QMetaType toType);
807 template<
typename,
bool>
friend struct QtPrivate::SequentialValueTypeIsMetaType;
808 template<
typename,
bool>
friend struct QtPrivate::AssociativeValueTypeIsMetaType;
809 template<
typename,
bool>
friend struct QtPrivate::IsMetaTypePair;
810 template<
typename,
typename>
friend struct QtPrivate::MetaTypeSmartPointerHelper;
812 static bool registerConverterFunction(
const ConverterFunction &f, QMetaType from, QMetaType to);
813 static void unregisterConverterFunction(QMetaType from, QMetaType to);
815 static bool registerMutableViewFunction(
const MutableViewFunction &f, QMetaType from, QMetaType to);
816 static void unregisterMutableViewFunction(QMetaType from, QMetaType to);
818 static void unregisterMetaType(QMetaType type);
820#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
821 constexpr const QtPrivate::QMetaTypeInterface *iface() {
return d_ptr; }
823 constexpr const QtPrivate::QMetaTypeInterface *iface()
const {
return d_ptr; }
826 Q_DECL_PURE_FUNCTION
static bool isDefaultConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
827 Q_DECL_PURE_FUNCTION
static bool isCopyConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
828 Q_DECL_PURE_FUNCTION
static bool isMoveConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
829 Q_DECL_PURE_FUNCTION
static bool isDestructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
831#if QT_CORE_REMOVED_SINCE(6
, 5
)
832 int idHelper()
const;
834 static int registerHelper(
const QtPrivate::QMetaTypeInterface *iface);
835 int registerHelper()
const
838 if (
int id = d_ptr->typeId.loadRelaxed(); Q_LIKELY(id))
840 return registerHelper(d_ptr);
845 friend int qRegisterMetaType(QMetaType meta);
847 friend class QVariant;
848 const QtPrivate::QMetaTypeInterface *d_ptr =
nullptr;
851#undef QT_DEFINE_METATYPE_ID
853Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
855#define QT_METATYPE_PRIVATE_DECLARE_TYPEINFO(C, F)
857 Q_DECLARE_TYPEINFO(QtMetaTypePrivate:: C, (F));
858 namespace QtMetaTypePrivate {
870 typedef void (*
getFunc)(
const void *
const *p,
void *);
877 { *
static_cast<
typename T::first_type *>(dataPtr) =
static_cast<
const T*>(*pair)->first; }
880 { *
static_cast<
typename T::second_type *>(dataPtr) =
static_cast<
const T*>(*pair)->second; }
904template<
typename From>
907template<
typename T,
typename U>
920#define QT_FORWARD_DECLARE_SHARED_POINTER_TYPES_ITER(Name)
921 template <class T> class Name;
964 enum {
Value =
sizeof(checkType(
static_cast<T*>(
nullptr))) ==
sizeof(
yes_type) };
967 template<
typename T,
typename Enable =
void>
973 template <
typename X>
977 IsRealGadget =
sizeof(checkType(&T::qt_check_for_QGADGET_macro)) ==
sizeof(
void *),
982 template <
typename T>
985 template<
typename T,
typename Enable =
void>
992 template <
typename X>
1004 template<
typename T>
1015 template<
typename T,
typename Enable =
void>
1018 static constexpr const QMetaObject *
value() {
return nullptr; }
1022#ifndef QT_NO_QOBJECT
1023 template<
typename T>
1029 template<
typename T>
1040 template<
typename T>
1049 template<
typename T>
1057 template<
typename T>
1063 template<
typename T>
1068 template<
typename T>
1074 template<
typename T>
1079 template<
typename T>
1085 template<
typename T>
1091 template<
typename T>
1097 template<
typename T>
1117 template<
typename T,
bool =
QMetaTypeId2<
typename T::value_type>::Defined>
1131 template<
typename T>
1150 template<
typename T,
bool =
QMetaTypeId2<
typename T::key_type>::Defined>
1164 template<
typename T,
bool =
QMetaTypeId2<
typename T::mapped_type>::Defined>
1178 template<
typename T>
1183 template<
typename T,
bool =
QMetaTypeId2<
typename T::first_type>::Defined
1193 template<
typename T>
1199 template<
typename T>
1207 template<
typename T,
typename U>
1210 template<
typename T>
1213 template<
typename T,
typename =
void>
1219#if QT_CONFIG(future)
1220 template<
typename T>
1229template <
typename T,
int =
1230 QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::PointerToQObject :
1231 QtPrivate::IsRealGadget<T>::value ? QMetaType::IsGadget :
1232 QtPrivate::IsPointerToGadgetHelper<T>::IsRealGadget ? QMetaType::PointerToGadget :
1233 QtPrivate::IsQEnumHelper<T>::Value ? QMetaType::IsEnumeration : 0>
1234struct QMetaTypeIdQObject
1241template <
typename T>
1246template <
typename T>
1254template <
typename T>
1257template <
typename T>
1266 template <
typename T,
bool Defined =
QMetaTypeId2<T>::Defined>
1277 template <
typename Result,
typename... Args>
1280 template<
typename T>
1285 template<
typename T>
1288 template<
typename T,
bool defined>
1294 template<
typename SmartPointer>
1299 return p.operator->();
1305 template <
typename T>
1308 template<
typename T>
1318template <
typename T>
1321#ifndef QT_NO_QOBJECT
1322 Q_ASSERT_X(normalizedTypeName == QMetaObject::normalizedType(normalizedTypeName.constData()),
1323 "qRegisterNormalizedMetaType",
1324 "qRegisterNormalizedMetaType was called with a not normalized type name, "
1325 "please call qRegisterMetaType instead.");
1328 const QMetaType metaType = QMetaType::fromType<T>();
1329 const int id = metaType.id();
1331 QtPrivate::SequentialContainerTransformationHelper<T>::registerConverter();
1332 QtPrivate::SequentialContainerTransformationHelper<T>::registerMutableView();
1333 QtPrivate::AssociativeContainerTransformationHelper<T>::registerConverter();
1334 QtPrivate::AssociativeContainerTransformationHelper<T>::registerMutableView();
1336 QtPrivate::MetaTypeSmartPointerHelper<T>::registerConverter();
1337#if QT_CONFIG(future)
1338 QtPrivate::MetaTypeQFutureHelper<T>::registerConverter();
1341 if (normalizedTypeName != metaType.name())
1342 QMetaType::registerNormalizedTypedef(normalizedTypeName, metaType);
1357template <
typename T>
1360 return qRegisterNormalizedMetaTypeImplementation<T>(normalizedTypeName);
1363#if defined(QT_BOOTSTRAPPED)
1364#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
1365#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
1367#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
1369 EXPORT int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &);
1370 template <> inline int qRegisterNormalizedMetaType< TYPE >(const QByteArray &name)
1371 { return qRegisterNormalizedMetaType_ ## TAG (name); }
1375#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
1376 int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &name)
1377 { return qRegisterNormalizedMetaTypeImplementation< TYPE >(name); }
1380#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
1382#define QT_IMPL_METATYPE_EXTERN(TYPE)
1385template <
typename T>
1389 QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = typeName;
1391 QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
1393 return qRegisterNormalizedMetaType<T>(normalizedTypeName);
1396template <
typename T>
1405 return QMetaType::fromType<T>().id();
1409template <
typename T>
1412 int id = qMetaTypeId<T>();
1418 return meta.registerHelper();
1421#ifndef QT_NO_QOBJECT
1422template <
typename T>
1431 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1432 if (
const int id = metatype_id.loadAcquire())
1434 const char *
const cName = T::staticMetaObject.className();
1435 QByteArray typeName;
1436 typeName.reserve(strlen(cName) + 1);
1437 typeName.append(cName).append(
'*');
1438 const int newId = qRegisterNormalizedMetaType<T *>(typeName);
1439 metatype_id.storeRelease(newId);
1444template <
typename T>
1445struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
1448 Defined = std::is_default_constructible<T>::value
1451 static int qt_metatype_id()
1453 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1454 if (
const int id = metatype_id.loadAcquire())
1456 const char *
const cName = T::staticMetaObject.className();
1457 const int newId = qRegisterNormalizedMetaType<T>(cName);
1458 metatype_id.storeRelease(newId);
1463template <
typename T>
1464struct QMetaTypeIdQObject<T*, QMetaType::PointerToGadget>
1470 static int qt_metatype_id()
1472 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1473 if (
const int id = metatype_id.loadAcquire())
1475 const char *
const cName = T::staticMetaObject.className();
1476 QByteArray typeName;
1477 typeName.reserve(strlen(cName) + 1);
1478 typeName.append(cName).append(
'*');
1479 const int newId = qRegisterNormalizedMetaType<T *>(typeName);
1480 metatype_id.storeRelease(newId);
1485template <
typename T>
1486struct QMetaTypeIdQObject<T, QMetaType::IsEnumeration>
1492 static int qt_metatype_id()
1494 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1495 if (
const int id = metatype_id.loadAcquire())
1497 const char *eName = qt_getEnumName(T());
1498 const char *cName = qt_getEnumMetaObject(T())->className();
1499 QByteArray typeName;
1500 typeName.reserve(strlen(cName) + 2 + strlen(eName));
1501 typeName.append(cName).append(
"::").append(eName);
1502 const int newId = qRegisterNormalizedMetaType<T>(typeName);
1503 metatype_id.storeRelease(newId);
1509#define Q_DECLARE_OPAQUE_POINTER(POINTER)
1510 QT_BEGIN_NAMESPACE namespace QtPrivate {
1511 template <> struct IsPointerDeclaredOpaque<POINTER>
1512 : std::true_type {};
1518#define Q_DECLARE_METATYPE_IMPL(TYPE)
1521 struct QMetaTypeId< TYPE >
1523 enum { Defined = 1
};
1524 static_assert(QtPrivate::checkTypeIsSuitableForMetaType<TYPE>());
1525 static int qt_metatype_id()
1527 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1528 if (const int id = metatype_id.loadAcquire())
1530 constexpr auto arr = QtPrivate::typenameHelper<TYPE>();
1531 auto name = arr.data();
1532 if (QByteArrayView(name) == (#TYPE)) {
1533 const int id = qRegisterNormalizedMetaType<TYPE>(name);
1534 metatype_id.storeRelease(id);
1537 const int newId = qRegisterMetaType< TYPE >(#TYPE);
1538 metatype_id.storeRelease(newId);
1545#define Q_DECLARE_BUILTIN_METATYPE(TYPE, METATYPEID, NAME)
1547 template<> struct QMetaTypeId2<NAME>
1549 using NameAsArrayType = std::array<char, sizeof(#NAME)>;
1550 enum { Defined = 1
, IsBuiltIn = true, MetaType = METATYPEID };
1551 static inline constexpr int qt_metatype_id() { return METATYPEID; }
1552 static constexpr NameAsArrayType nameAsArray = { #NAME };
1556#define QT_FORWARD_DECLARE_STATIC_TYPES_ITER(TypeName, TypeId, Name)
1563#undef QT_FORWARD_DECLARE_STATIC_TYPES_ITER
1565#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) QT_BEGIN_NAMESPACE
1568 QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
1569{
1571 Defined = QMetaTypeId2<T>::Defined
1573 static int qt_metatype_id()
1575 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1576 if (const int id = metatype_id.loadRelaxed())
1578 const char *tName = QMetaType::fromType<T>().name();
1580 const size_t tNameLen = qstrlen(tName);
1581 QByteArray typeName;
1582 typeName.reserve(sizeof(#SINGLE_ARG_TEMPLATE) + 1
+ tNameLen + 1
+ 1
);
1583 typeName.append(#SINGLE_ARG_TEMPLATE, int(sizeof(#SINGLE_ARG_TEMPLATE)) - 1
)
1584 .append('<').append(tName, tNameLen);
1585 typeName.append('>');
1586 const int newId = qRegisterNormalizedMetaType< SINGLE_ARG_TEMPLATE<T> >(typeName);
1587 metatype_id.storeRelease(newId);
1590};QT_END_NAMESPACE
1593#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) QT_BEGIN_NAMESPACE
1595 <typename T, typename U> struct
1596 QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
1597{
1599 Defined = QMetaTypeId2<T>::Defined && QMetaTypeId2<U>::Defined
1601 static int qt_metatype_id()
1603 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1604 if (const int id = metatype_id.loadAcquire())
1606 const char *tName = QMetaType::fromType<T>().name();
1607 const char *uName = QMetaType::fromType<U>().name();
1610 const size_t tNameLen = qstrlen(tName);
1611 const size_t uNameLen = qstrlen(uName);
1612 QByteArray typeName;
1613 typeName.reserve(sizeof(#DOUBLE_ARG_TEMPLATE) + 1
+ tNameLen + 1
+ uNameLen + 1
+ 1
);
1614 typeName.append(#DOUBLE_ARG_TEMPLATE, int(sizeof(#DOUBLE_ARG_TEMPLATE)) - 1
)
1615 .append('<').append(tName, tNameLen).append(',').append(uName, uNameLen);
1616 typeName.append('>');
1617 const int newId = qRegisterNormalizedMetaType< DOUBLE_ARG_TEMPLATE<T, U> >(typeName);
1618 metatype_id.storeRelease(newId);
1621};QT_END_NAMESPACE
1626template<
typename T,
bool =
false>
1640#define Q_DECLARE_SMART_POINTER_METATYPE(SMART_POINTER) QT_BEGIN_NAMESPACE
1642 QtPrivate { template
1644 SharedPointerMetaTypeIdHelper<SMART_POINTER<T>, true> \
1645{
1649 static int qt_metatype_id()
1651 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1652 if (const int id = metatype_id.loadAcquire())
1654 const char * const cName = T::staticMetaObject.className();
1655 QByteArray typeName;
1656 typeName.reserve(sizeof(#SMART_POINTER) + 1
+ strlen(cName) + 1
);
1657 typeName.append(#SMART_POINTER, int(sizeof(#SMART_POINTER)) - 1
)
1658 .append('<').append(cName).append('>');
1659 const int newId = qRegisterNormalizedMetaType< SMART_POINTER<T> >(typeName);
1660 metatype_id.storeRelease(newId);
1663};template
1665 MetaTypeSmartPointerHelper<SMART_POINTER<T> ,
1666 typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value && !std::is_const_v<T>>::type> \
1667{
1668 static bool registerConverter()
1670 const QMetaType to = QMetaType(QMetaType::QObjectStar);
1671 if (!QMetaType::hasRegisteredConverterFunction(QMetaType::fromType<SMART_POINTER<T>>(), to)) {
1672 QtPrivate::QSmartPointerConvertFunctor<SMART_POINTER<T> > o;
1673 return QMetaType::registerConverter<SMART_POINTER<T>, QObject*>(o);
1677};\
1678}template
1680 QMetaTypeId< SMART_POINTER<T> >
1681 : QtPrivate::SharedPointerMetaTypeIdHelper< SMART_POINTER<T>,
1682 QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value> \
1683{\
1684};QT_END_NAMESPACE
1687#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(SINGLE_ARG_TEMPLATE)
1689 namespace QtPrivate {
1690 template<typename T>
1691 struct IsSequentialContainer<SINGLE_ARG_TEMPLATE<T> >
1693 enum { Value = true };
1699#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER(TEMPLATENAME)
1706#undef Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER
1711#define Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(TEMPLATENAME)
1713 namespace QtPrivate {
1714 template<typename T, typename U>
1715 struct IsAssociativeContainer<TEMPLATENAME<T, U> >
1717 enum { Value = true };
1729#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME)
1736#undef Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER
1754template <
typename T>
1759 return QMetaType::registerConverter<T, QtMetaTypePrivate::QPairVariantInterfaceImpl>(o);
1766template<
typename From>
1771 return QIterable<
QMetaSequence>(QMetaSequence::fromContainer<From>(), &f);
1775template<
typename From>
1780 return QIterable<
QMetaSequence>(QMetaSequence::fromContainer<From>(), &f);
1791 return QMetaType::registerConverter<T, QIterable<QMetaSequence>>(o);
1800 return QMetaType::registerMutableView<T, QIterable<QMetaSequence>>(o);
1806template<
typename From>
1811 return QIterable<
QMetaAssociation>(QMetaAssociation::fromContainer<From>(), &f);
1815template<
typename From>
1820 return QIterable<
QMetaAssociation>(QMetaAssociation::fromContainer<From>(), &f);
1833 return QMetaType::registerConverter<T, QIterable<QMetaAssociation>>(o);
1842 return QMetaType::registerMutableView<T, QIterable<QMetaAssociation>>(o);
1855 static constexpr bool is_ident_char(
char s)
1857 return ((s >=
'a' && s <=
'z') || (s >=
'A' && s <=
'Z') || (s >=
'0' && s <=
'9')
1860 static constexpr bool is_space(
char s) {
return (s ==
' ' || s ==
'\t' || s ==
'\n'); }
1861 static constexpr bool is_number(
char s) {
return s >=
'0' && s <=
'9'; }
1862 static constexpr bool starts_with_token(
const char *b,
const char *e,
const char *token,
1863 bool msvcKw =
false)
1865 while (b != e && *token && *b == *token) {
1874 if (msvcKw && !is_ident_char(*b))
1878 return b == e || !is_ident_char(*b);
1880 static constexpr bool skipToken(
const char *&x,
const char *e,
const char *token,
1881 bool msvcKw =
false)
1883 if (!starts_with_token(x, e, token, msvcKw))
1887 while (x != e && is_space(*x))
1891 static constexpr const char *skipString(
const char *x,
const char *e)
1895 while (x != e && *x != delim) {
1907 static constexpr const char *skipTemplate(
const char *x,
const char *e,
bool stopAtComa =
false)
1910 int templateDepth = 0;
1918 if (stopAtComa && !scopeDepth && !templateDepth)
1923 if (--templateDepth < 0)
1937 if (is_number(x[-1]))
1941 x = skipString(x, e);
1949 constexpr void append(
char x)
1957 constexpr void replaceLast(
char x)
1964 constexpr void appendStr(
const char *x)
1970 constexpr void normalizeIntegerTypes(
const char *&begin,
const char *end)
1974 int numUnsigned = 0;
1978 while (begin < end) {
1979 if (skipToken(begin, end,
"long")) {
1983 if (skipToken(begin, end,
"int")) {
1987 if (skipToken(begin, end,
"short")) {
1991 if (skipToken(begin, end,
"unsigned")) {
1995 if (skipToken(begin, end,
"signed")) {
1999 if (skipToken(begin, end,
"char")) {
2004 if (skipToken(begin, end,
"__int64")) {
2013 if (numSigned && numChar)
2014 appendStr(
"signed ");
2015 else if (numUnsigned)
2021 else if (numLong == 1)
2023 else if (numLong == 2)
2024 appendStr(
"longlong");
2025 else if (numUnsigned || numSigned || numInt)
2029 constexpr void skipStructClassOrEnum(
const char *&begin,
const char *end)
2033 skipToken(begin, end,
"struct",
true) || skipToken(begin, end,
"class",
true)
2034 || skipToken(begin, end,
"enum",
true);
2037 constexpr void skipQtNamespace(
const char *&begin,
const char *end)
2040 const char *nsbeg = begin;
2041 if (skipToken(nsbeg, end, QT_STRINGIFY(QT_NAMESPACE)) && nsbeg + 2 < end && nsbeg[0] ==
':'
2042 && nsbeg[1] ==
':') {
2044 while (begin != end && is_space(*begin))
2054#if defined(Q_CC_CLANG) || defined (Q_CC_GNU)
2062#if defined (Q_CC_CLANG)
2069 if (*
begin ==
' ') {
2107 constexpr int normalizeType(
const char *begin,
const char *end,
bool adjustConst =
true)
2110 while (begin != end && is_space(*begin))
2112 while (begin != end && is_space(*(end - 1)))
2120 const char *cst = begin + 1;
2121 if (*begin ==
'\'' || *begin ==
'"')
2122 cst = skipString(begin, end);
2123 bool seenStar =
false;
2124 bool hasMiddleConst =
false;
2126 if (*cst ==
'\"' || (*cst ==
'\'' && !is_number(cst[-1]))) {
2127 cst = skipString(cst, end);
2134 if (*cst ==
'&' || *cst ==
'*' || *cst ==
'[') {
2135 seenStar = *cst !=
'&' || cst != (end - 1);
2139 cst = skipTemplate(cst + 1, end);
2144 const char *skipedCst = cst;
2145 if (!is_ident_char(*(cst - 1)) && skipToken(skipedCst, end,
"const")) {
2146 const char *testEnd = end;
2147 while (skipedCst < testEnd--) {
2148 if (*testEnd ==
'*' || *testEnd ==
'['
2149 || (*testEnd ==
'&' && testEnd != (end - 1))) {
2153 if (*testEnd ==
'>')
2156 if (adjustConst && !seenStar) {
2157 if (*(end - 1) ==
'&')
2160 appendStr(
"const ");
2164 hasMiddleConst =
true;
2168 if (skipToken(begin, end,
"const")) {
2169 if (adjustConst && !seenStar) {
2170 if (*(end - 1) ==
'&')
2173 appendStr(
"const ");
2176 if (seenStar && adjustConst) {
2177 const char *e = end;
2178 if (*(end - 1) ==
'&' && *(end - 2) !=
'&')
2180 while (begin != e && is_space(*(e - 1)))
2182 const char *token =
"tsnoc";
2183 while (*token && begin != e && *(--e) == *token++)
2185 if (!*token && begin != e && !is_ident_char(*(e - 1))) {
2186 while (begin != e && is_space(*(e - 1)))
2192 skipStructClassOrEnum(begin, end);
2193 skipQtNamespace(begin, end);
2195 if (skipToken(begin, end,
"QVector")) {
2200 if (skipToken(begin, end,
"QPair")) {
2202 appendStr(
"std::pair");
2205 if (!hasMiddleConst)
2207 normalizeIntegerTypes(begin, end);
2209 bool spaceSkiped =
true;
2210 while (begin != end) {
2214 }
else if ((c ==
'\'' && !is_number(
last)) || c ==
'\"') {
2216 auto x = skipString(begin, end);
2220 if (spaceSkiped && is_ident_char(
last) && is_ident_char(c))
2223 spaceSkiped =
false;
2227 const char *tpl = skipTemplate(begin, end,
true);
2233 }
while (*begin++ ==
',');
2252template <
typename T1_,
typename T2_>
2265 std::remove_const_t<std::conditional_t<
bool (QMetaTypeId2<T1>::IsBuiltIn),
typename QMetaTypeId2<T1>::NameAsArrayType,
decltype(typenameHelper<T1>())>> t1Name {};
2266 std::remove_const_t<std::conditional_t<
bool (QMetaTypeId2<T2>::IsBuiltIn),
typename QMetaTypeId2<T2>::NameAsArrayType,
decltype(typenameHelper<T2>())>> t2Name {};
2270 t1Name = typenameHelper<T1>();
2275 t2Name = typenameHelper<T2>();
2277 constexpr auto nonTypeDependentLen =
sizeof(
"std::pair<,>");
2278 constexpr auto t1Len = t1Name.size() - 1;
2279 constexpr auto t2Len = t2Name.size() - 1;
2280 constexpr auto length = nonTypeDependentLen + t1Len + t2Len;
2281 std::array<
char, length + 1> result {};
2282 constexpr auto prefix =
"std::pair<";
2283 int currentLength = 0;
2284 for (; currentLength <
int(
sizeof(
"std::pair<") - 1); ++currentLength)
2285 result[currentLength] = prefix[currentLength];
2286 for (
int i = 0; i <
int(t1Len); ++currentLength, ++i)
2287 result[currentLength] = t1Name[i];
2288 result[currentLength++] =
',';
2289 for (
int i = 0; i <
int(t2Len); ++currentLength, ++i)
2290 result[currentLength] = t2Name[i];
2291 result[currentLength++] =
'>';
2292 result[currentLength++] =
'\0';
2295 constexpr auto prefix =
sizeof(
2297 QT_STRINGIFY(QT_NAMESPACE)
"::"
2299#if defined(Q_CC_MSVC) && defined(Q_CC_CLANG)
2300 "auto __cdecl QtPrivate::TypeNameHelper::typenameHelper(void) [T = "
2301#elif defined(Q_CC_MSVC)
2302 "auto __cdecl QtPrivate::TypeNameHelper::typenameHelper<"
2303#elif defined(Q_CC_CLANG)
2304 "auto QtPrivate::TypeNameHelper::typenameHelper() [T = "
2305#elif defined(Q_CC_GHS)
2306 "auto QtPrivate::TypeNameHelper::typenameHelper<T>()[with T="
2308 "constexpr auto QtPrivate::TypeNameHelper::typenameHelper() [with T = "
2311#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
2312 constexpr int suffix =
sizeof(
">(void)");
2314 constexpr int suffix =
sizeof(
"]");
2317#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU_ONLY < 804
2318 auto func = Q_FUNC_INFO;
2319 const char *begin = func + prefix;
2320 const char *end = func +
sizeof(Q_FUNC_INFO) - suffix;
2322 constexpr int len =
sizeof(Q_FUNC_INFO) - suffix - prefix;
2324 constexpr auto func = Q_FUNC_INFO;
2325 constexpr const char *begin = func + prefix;
2326 constexpr const char *end = func +
sizeof(Q_FUNC_INFO) - suffix;
2329 std::array<
char, len + 1> result {};
2337template<
typename T,
typename =
void>
2351QT_WARNING_DISABLE_FLOAT_COMPARE
2353 {
return *
reinterpret_cast<
const T *>(
a) == *
reinterpret_cast<
const T *>(
b); }
2367 {
return *
reinterpret_cast<
const T *>(a) < *
reinterpret_cast<
const T *>(b); }
2382#ifndef QT_NO_DEBUG_STREAM
2387 { dbg << *
reinterpret_cast<
const T *>(a); }
2398#ifndef QT_NO_DATASTREAM
2403 { ds << *
reinterpret_cast<
const T *>(a); }
2405 { ds >> *
reinterpret_cast<T *>(a); }
2419#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG)
2420# pragma GCC visibility push(hidden)
2429 template <
typename T>
2432#if !defined(QT_BOOTSTRAPPED)
2441 static constexpr decltype(typenameHelper<S>())
name = typenameHelper<S>();
2446 if constexpr (QTypeInfo<S>::isRelocatable)
2447 flags |= QMetaType::RelocatableType;
2448 if constexpr (!std::is_default_constructible_v<S> || !QTypeInfo<S>::isValueInitializationBitwiseZero)
2449 flags |= QMetaType::NeedsConstruction;
2450 if constexpr (!std::is_trivially_destructible_v<S>)
2451 flags |= QMetaType::NeedsDestruction;
2452 if constexpr (!std::is_trivially_copy_constructible_v<S>)
2453 flags |= QMetaType::NeedsCopyConstruction;
2454 if constexpr (!std::is_trivially_move_constructible_v<S>)
2455 flags |= QMetaType::NeedsMoveConstruction;
2456 if constexpr (IsPointerToTypeDerivedFromQObject<S>::Value)
2457 flags |= QMetaType::PointerToQObject;
2458 if constexpr (IsSharedPointerToTypeDerivedFromQObject<S>::Value)
2459 flags |= QMetaType::SharedPointerToQObject;
2460 if constexpr (IsWeakPointerToTypeDerivedFromQObject<S>::Value)
2461 flags |= QMetaType::WeakPointerToQObject;
2462 if constexpr (IsTrackingPointerToTypeDerivedFromQObject<S>::Value)
2463 flags |= QMetaType::TrackingPointerToQObject;
2464 if constexpr (IsEnumOrFlags<S>::value)
2465 flags |= QMetaType::IsEnumeration;
2466 if constexpr (IsGadgetHelper<S>::IsGadgetOrDerivedFrom)
2467 flags |= QMetaType::IsGadget;
2468 if constexpr (IsPointerToGadgetHelper<S>::IsGadgetOrDerivedFrom)
2469 flags |= QMetaType::PointerToGadget;
2470 if constexpr (std::is_pointer_v<S>)
2471 flags |= QMetaType::IsPointer;
2472 if constexpr (IsUnsignedEnum<S>)
2473 flags |= QMetaType::IsUnsignedEnumeration;
2474 if constexpr (IsQmlListType<S>)
2475 flags |= QMetaType::IsQmlList;
2476 if constexpr (std::is_const_v<std::remove_pointer_t<S>>)
2477 flags |= QMetaType::IsConst;
2483 if constexpr (std::is_default_constructible_v<S> && !QTypeInfo<S>::isValueInitializationBitwiseZero) {
2492 if constexpr (
std::is_copy_constructible_v<S> && !
std::is_trivially_copy_constructible_v<S>) {
2494 if constexpr (qxp::is_detected_v<QMetaTypeCopyTraits::HasDeprecatedCopyConstructorTest, S>) {
2495#if !defined(QT_BOOTSTRAPPED)
2498 QT_IGNORE_DEPRECATIONS(
new (addr) S(*
reinterpret_cast<
const S *>(other));)
2500 new (addr) S(*
reinterpret_cast<
const S *>(other));
2510 if constexpr (
std::is_move_constructible_v<S> && !
std::is_trivially_move_constructible_v<S>) {
2512 new (addr) S(
std::move(*
reinterpret_cast<S *>(other)));
2521 if constexpr (
std::is_destructible_v<S> && !
std::is_trivially_destructible_v<S>)
2523 reinterpret_cast<S *>(addr)->~S();
2580#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG)
2581# pragma GCC visibility pop
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620#if !defined(QT_BOOTSTRAPPED) && !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY)
2622#ifdef QT_NO_DATA_RELOCATION
2623# define QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER(TypeName, Id, Name)
2624 extern template class Q_CORE_EXPORT QMetaTypeForType<Name>;
2626# define QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER(TypeName, Id, Name)
2627 extern template class Q_CORE_EXPORT QMetaTypeForType<Name>;
2628 extern template struct Q_CORE_EXPORT QMetaTypeInterfaceWrapper<Name>;
2636#undef QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER
2645#define Q_REMOVE_POINTER_LIKE_IMPL(Pointer) template
2647 QRemovePointerLike<Pointer<T>> \
2648{
2650};
2653#undef Q_REMOVE_POINTER_LIKE_IMPL
2668template<
typename Unique,
typename T>
2674 if constexpr (
std::is_void_v<Tz>) {
2677 }
else if constexpr (
std::is_void_v<Unique>) {
2678 checkTypeIsSuitableForMetaType<Ty>();
2680 }
else if constexpr (
std::is_reference_v<Tz>) {
2682 }
else if constexpr (!
is_complete<Tz, Unique>::value) {
2693constexpr QMetaType QMetaType::fromType()
2695 QtPrivate::checkTypeIsSuitableForMetaType<T>();
2696 return QMetaType(QtPrivate::qMetaTypeInterfaceForType<T>());
2699constexpr bool QMetaType::isValid(QT6_IMPL_NEW_OVERLOAD)
const noexcept
2704bool QMetaType::isRegistered(QT6_IMPL_NEW_OVERLOAD)
const noexcept
2706 return d_ptr && Q_LIKELY(d_ptr->typeId.loadRelaxed());
2709constexpr qsizetype QMetaType::sizeOf()
const
2711 return d_ptr ? d_ptr->size : 0;
2714constexpr qsizetype QMetaType::alignOf()
const
2716 return d_ptr ? d_ptr->alignment : 0;
2719constexpr QMetaType::TypeFlags QMetaType::flags()
const
2721 return d_ptr ? TypeFlags(d_ptr->flags) : TypeFlags{};
2724constexpr const QMetaObject *QMetaType::metaObject()
const
2726 return d_ptr && d_ptr->metaObjectFn ? d_ptr->metaObjectFn(d_ptr) :
nullptr;
2729constexpr const char *QMetaType::name()
const
2731 return d_ptr ? d_ptr->name :
nullptr;
2738 return qHash(type.id(), seed);
2744 QPairVariantInterfaceImpl, Q_CORE_EXPORT)
Combined button and popup list for selecting options.
constexpr auto typenameHelper()
Q_CORE_EXPORT bool hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType m)
Q_CORE_EXPORT bool hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType m)
static constexpr bool checkTypeIsSuitableForMetaType()
constexpr bool IsQmlListType
constexpr int qNormalizeType(const char *begin, const char *end, char *output)
constexpr bool IsUnsignedEnum
Q_CORE_EXPORT bool hasRegisteredConverterFunctionToPairVariantInterface(QMetaType m)
constexpr const QMetaTypeInterface * qTryMetaTypeInterfaceForType()
constexpr bool IsUnsignedEnum< T, true >
Q_CORE_EXPORT bool hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType m)
Q_CORE_EXPORT bool hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType m)
To convertImplicit(const From &from)
This template is used for implicit conversion from type From to type To.
constexpr const QMetaTypeInterface * qMetaTypeInterfaceForType()
char qt_getEnumMetaObject(const T &)
static void * checkType(void(T::*)())
static char checkType(void(X::*)())
static bool registerConverter()
static char checkType(void(X::*)())
static void * checkType(void(T::*)())
static no_type checkType(...)
static yes_type checkType(QObject *)
static yes_type checkType(const QObject *)
static const T & declval()
QIterable< QMetaAssociation > operator()(const From &f) const
QIterable< QMetaAssociation > operator()(From &f) const
static void dataStreamIn(const QMetaTypeInterface *, QDataStream &ds, void *a)
static void dataStreamOut(const QMetaTypeInterface *, QDataStream &ds, const void *a)
static void debugStream(const QMetaTypeInterface *, QDebug &dbg, const void *a)
static constexpr QMetaTypeInterface::DebugStreamFn debugStream
static constexpr QMetaTypeInterface::EqualsFn equals
static constexpr QMetaTypeInterface::LessThanFn lessThan
static bool lessThan(const QMetaTypeInterface *, const void *a, const void *b)
QIterable< QMetaSequence > operator()(const From &f) const
QIterable< QMetaSequence > operator()(From &f) const
QObject * operator()(const QWeakPointer< T > &p) const
QObject * operator()(const SmartPointer &p) const
constexpr int normalizeType(const char *begin, const char *end, bool adjustConst=true)
constexpr int normalizeTypeFromSignature(const char *begin, const char *end)
static auto check(...) -> std::false_type
static auto check(U *) -> std::integral_constant< bool, sizeof(U) !=0 >
decltype(check(static_cast< T * >(nullptr))) type