9#include <QtCore/qglobal.h>
10#include <QtCore/qatomic.h>
11#include <QtCore/qbytearray.h>
12#include <QtCore/qcompare.h>
13#include <QtCore/qdatastream.h>
14#include <QtCore/qflags.h>
15#include <QtCore/qfloat16.h>
16#include <QtCore/qhashfunctions.h>
17#include <QtCore/qiterable.h>
18#include <QtCore/qmetacontainer.h>
20#include <QtCore/qobjectdefs.h>
22#include <QtCore/qscopeguard.h>
23#include <QtCore/qttypetraits.h>
32#include <QtCore/qxptype_traits.h>
35#error qmetatype.h must be included before any header file that defines Bool
41enum class QCborSimpleType : quint8;
50#define QT_FOR_EACH_STATIC_PRIMITIVE_NON_VOID_TYPE(F)
54 F(LongLong, 4
, qlonglong)
55 F(ULongLong, 5
, qulonglong)
60 F(Char16, 56
, char16_t)
61 F(Char32, 57
, char32_t)
66 F(SChar, 40
, signed char)
67 F(Nullptr, 51
, std::nullptr_t)
68 F(QCborSimpleType, 52
, QCborSimpleType)
70#define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)
74#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)
75 F(VoidStar, 31
, void*)
77#if QT_CONFIG(easingcurve)
78#define QT_FOR_EACH_STATIC_EASINGCURVE(F)
79 F(QEasingCurve, 29
, QEasingCurve)
81#define QT_FOR_EACH_STATIC_EASINGCURVE(F)
84#if QT_CONFIG(itemmodel)
85#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
86 F(QModelIndex, 42
, QModelIndex)
87 F(QPersistentModelIndex, 50
, QPersistentModelIndex)
89#define QT_FOR_EACH_STATIC_ITEMMODEL_CLASS(F)
92#if QT_CONFIG(regularexpression)
93# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F)
94 F(QRegularExpression, 44
, QRegularExpression)
96# define QT_FOR_EACH_STATIC_REGULAR_EXPRESSION(F)
99# define QT_FOR_EACH_STATIC_QVARIANT(F)
100 F(QVariant, 41
, QVariant)
102# define QT_FOR_EACH_STATIC_QVARIANT(F)
105#define QT_FOR_EACH_STATIC_CORE_CLASS(F)
107 F(QString, 10
, QString)
108 F(QByteArray, 12
, QByteArray)
109 F(QBitArray, 13
, QBitArray)
112 F(QDateTime, 16
, QDateTime)
114 F(QLocale, 18
, QLocale)
116 F(QRectF, 20
, QRectF)
118 F(QSizeF, 22
, QSizeF)
120 F(QLineF, 24
, QLineF)
121 F(QPoint, 25
, QPoint)
122 F(QPointF, 26
, QPointF)
127 F(QJsonValue, 45
, QJsonValue)
128 F(QJsonObject, 46
, QJsonObject)
129 F(QJsonArray, 47
, QJsonArray)
130 F(QJsonDocument, 48
, QJsonDocument)
131 F(QCborValue, 53
, QCborValue)
132 F(QCborArray, 54
, QCborArray)
133 F(QCborMap, 55
, QCborMap)
134 F(Float16, 63
, qfloat16)
137#define QT_FOR_EACH_STATIC_CORE_POINTER(F)
138 F(QObjectStar, 39
, QObject*)
141# define QT_FOR_EACH_STATIC_CORE_QVARIANT_TEMPLATE(F)
142 F(QVariantMap, 8
, QVariantMap)
143 F(QVariantList, 9
, QVariantList)
144 F(QVariantHash, 28
, QVariantHash)
145 F(QVariantPair, 58
, QVariantPair)
148# define QT_FOR_EACH_STATIC_CORE_QVARIANT_TEMPLATE(F)
151#define QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)
153 F(QByteArrayList, 49
, QByteArrayList)
154 F(QStringList, 11
, QStringList)
156#if QT_CONFIG(shortcut)
157#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)
158 F(QKeySequence, 0x100b
, QKeySequence)
160#define QT_FOR_EACH_STATIC_KEYSEQUENCE_CLASS(F)
163#define QT_FOR_EACH_STATIC_GUI_CLASS(F)
164 F(QFont, 0x1000
, QFont)
165 F(QPixmap, 0x1001
, QPixmap)
166 F(QBrush, 0x1002
, QBrush)
167 F(QColor, 0x1003
, QColor)
168 F(QPalette, 0x1004
, QPalette)
169 F(QIcon, 0x1005
, QIcon)
170 F(QImage, 0x1006
, QImage)
171 F(QPolygon, 0x1007
, QPolygon)
172 F(QRegion, 0x1008
, QRegion)
173 F(QBitmap, 0x1009
, QBitmap)
174 F(QCursor, 0x100a
, QCursor)
176 F(QPen, 0x100c
, QPen)
177 F(QTextLength, 0x100d
, QTextLength)
178 F(QTextFormat, 0x100e
, QTextFormat)
179 F(QTransform, 0x1010
, QTransform)
180 F(QMatrix4x4, 0x1011
, QMatrix4x4)
181 F(QVector2D, 0x1012
, QVector2D)
182 F(QVector3D, 0x1013
, QVector3D)
183 F(QVector4D, 0x1014
, QVector4D)
184 F(QQuaternion, 0x1015
, QQuaternion)
185 F(QPolygonF, 0x1016
, QPolygonF)
186 F(QColorSpace, 0x1017
, QColorSpace)
189#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)
190 F(QSizePolicy, 0x2000
, QSizePolicy)
193#define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)
194 F(ULong, -1
, ulong, "unsigned long")
195 F(UInt, -1
, uint, "unsigned int")
196 F(UShort, -1
, ushort, "unsigned short")
197 F(UChar, -1
, uchar, "unsigned char")
198 F(LongLong, -1
, qlonglong, "long long")
199 F(ULongLong, -1
, qulonglong, "unsigned long long")
200 F(SChar, -1
, signed char, "qint8")
201 F(UChar, -1
, uchar, "quint8")
202 F(Short, -1
, short, "qint16")
203 F(UShort, -1
, ushort, "quint16")
204 F(Int, -1
, int, "qint32")
205 F(UInt, -1
, uint, "quint32")
206 F(LongLong, -1
, qlonglong, "qint64")
207 F(ULongLong, -1
, qulonglong, "quint64")
208 F(QByteArrayList, -1
, QByteArrayList, "QList<QByteArray>")
209 F(QStringList, -1
, QStringList, "QList<QString>")
213#define QT_FOR_EACH_STATIC_VARIANT_ALIAS_TYPE(F)
214 F(QVariantList, -1
, QVariantList, "QList<QVariant>")
215 F(QVariantMap, -1
, QVariantMap, "QMap<QString,QVariant>")
216 F(QVariantHash, -1
, QVariantHash, "QHash<QString,QVariant>")
217 F(QVariantPair, -1
, QVariantPair, "QPair<QVariant,QVariant>")
220#define QT_FOR_EACH_STATIC_VARIANT_ALIAS_TYPE(F)
223#define QT_FOR_EACH_STATIC_TYPE(F)
232#define QT_DEFINE_METATYPE_ID(TypeName, Id, Name)
235#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F)
242#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F)
246#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F)
263#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
) || defined(QT_BOOTSTRAPPED) || !defined(Q_CC_MSVC)
267# define QMTI_MUTABLE mutable
317
318
319
320template<
typename From,
typename To>
326 template<
typename T,
bool>
328 template<
typename T,
bool>
330 template<
typename T,
bool>
332 template<
typename,
typename>
347 FirstCoreType = Bool,
348 LastCoreType = Float16,
349 FirstGuiType = QFont,
350 LastGuiType = QColorSpace,
351 FirstWidgetsType = QSizePolicy,
352 LastWidgetsType = QSizePolicy,
353 HighestInternalId = LastWidgetsType,
355 QReal =
sizeof(qreal) ==
sizeof(
double) ? Double : Float,
363 UnknownType = 0, Bool = 1, Int = 2, UInt = 3, LongLong = 4, ULongLong = 5,
364 Double = 6, Long = 32, Short = 33, Char = 34, ULong = 35, UShort = 36,
365 UChar = 37, Float = 38,
367 QChar = 7, QString = 10, QStringList = 11, QByteArray = 12,
368 QBitArray = 13, QDate = 14, QTime = 15, QDateTime = 16, QUrl = 17,
369 QLocale = 18, QRect = 19, QRectF = 20, QSize = 21, QSizeF = 22,
370 QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26,
371 QEasingCurve = 29, QUuid = 30, QVariant = 41, QModelIndex = 42,
372 QPersistentModelIndex = 50, QRegularExpression = 44,
373 QJsonValue = 45, QJsonObject = 46, QJsonArray = 47, QJsonDocument = 48,
374 QByteArrayList = 49, QObjectStar = 39, SChar = 40,
377 QVariantMap = 8, QVariantList = 9, QVariantHash = 28, QVariantPair = 58,
378 QCborSimpleType = 52, QCborValue = 53, QCborArray = 54, QCborMap = 55,
379 Char16 = 56, Char32 = 57,
380 Int128 = 59, UInt128 = 60, Float128 = 61, BFloat16 = 62, Float16 = 63,
383 QFont = 0x1000, QPixmap = 0x1001, QBrush = 0x1002, QColor = 0x1003, QPalette = 0x1004,
384 QIcon = 0x1005, QImage = 0x1006, QPolygon = 0x1007, QRegion = 0x1008, QBitmap = 0x1009,
385 QCursor = 0x100a, QKeySequence = 0x100b, QPen = 0x100c, QTextLength = 0x100d, QTextFormat = 0x100e,
386 QTransform = 0x1010, QMatrix4x4 = 0x1011, QVector2D = 0x1012,
387 QVector3D = 0x1013, QVector4D = 0x1014, QQuaternion = 0x1015, QPolygonF = 0x1016, QColorSpace = 0x1017,
390 QSizePolicy = 0x2000,
398 NeedsConstruction = 0x1,
399 NeedsDestruction = 0x2,
400 RelocatableType = 0x4,
401#if QT_DEPRECATED_SINCE(6
, 0
)
402 MovableType Q_DECL_ENUMERATOR_DEPRECATED_X(
"Use RelocatableType instead.") = RelocatableType,
404 PointerToQObject = 0x8,
405 IsEnumeration = 0x10,
406 SharedPointerToQObject = 0x20,
407 WeakPointerToQObject = 0x40,
408 TrackingPointerToQObject = 0x80,
409 IsUnsignedEnumeration = 0x100,
411 PointerToGadget = 0x400,
416 NeedsCopyConstruction = 0x4000,
417 NeedsMoveConstruction = 0x8000,
419 Q_DECLARE_FLAGS(TypeFlags, TypeFlag)
421 static void registerNormalizedTypedef(
const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, QMetaType type);
423#if QT_DEPRECATED_SINCE(6
, 0
)
424 QT_DEPRECATED_VERSION_6_0
425 static int type(
const char *typeName)
426 {
return QMetaType::fromName(typeName).id(); }
427 QT_DEPRECATED_VERSION_6_0
428 static int type(
const QT_PREPEND_NAMESPACE(QByteArray) &typeName)
429 {
return QMetaType::fromName(typeName).id(); }
430 QT_DEPRECATED_VERSION_6_0
431 static const char *typeName(
int type)
432 {
return QMetaType(type).name(); }
433 QT_DEPRECATED_VERSION_6_0
434 static int sizeOf(
int type)
435 {
return int(QMetaType(type).sizeOf()); }
436 QT_DEPRECATED_VERSION_6_0
437 static TypeFlags typeFlags(
int type)
438 {
return QMetaType(type).flags(); }
439 QT_DEPRECATED_VERSION_6_0
440 static const QMetaObject *metaObjectForType(
int type)
441 {
return QMetaType(type).metaObject(); }
442 QT_DEPRECATED_VERSION_6_0
443 static void *create(
int type,
const void *copy =
nullptr)
444 {
return QMetaType(type).create(copy); }
445 QT_DEPRECATED_VERSION_6_0
446 static void destroy(
int type,
void *data)
447 {
return QMetaType(type).destroy(data); }
448 QT_DEPRECATED_VERSION_6_0
449 static void *construct(
int type,
void *where,
const void *copy)
450 {
return QMetaType(type).construct(where, copy); }
451 QT_DEPRECATED_VERSION_6_0
452 static void destruct(
int type,
void *where)
453 {
return QMetaType(type).destruct(where); }
455 static bool isRegistered(
int type);
457 explicit QMetaType(
int type);
458 explicit constexpr QMetaType(
const QtPrivate::QMetaTypeInterface *d) : d_ptr(d) {}
459 constexpr QMetaType() =
default;
461#if QT_CORE_REMOVED_SINCE(6
, 9
)
462 bool isValid()
const;
463 bool isRegistered()
const;
465 constexpr bool isValid(QT6_DECL_NEW_OVERLOAD)
const noexcept;
466 inline bool isRegistered(QT6_DECL_NEW_OVERLOAD)
const noexcept;
467 void registerType()
const
472#if QT_CORE_REMOVED_SINCE(6
, 1
) || defined(Q_QDOC)
477 int id(
int = 0)
const
479 return registerHelper();
482 constexpr qsizetype sizeOf()
const;
483 constexpr qsizetype alignOf()
const;
484 constexpr TypeFlags flags()
const;
485 constexpr const QMetaObject *metaObject()
const;
486 constexpr const char *name()
const;
488 void *create(
const void *copy =
nullptr)
const;
489 void destroy(
void *data)
const;
490 void *construct(
void *where,
const void *copy =
nullptr)
const;
491 void destruct(
void *data)
const;
492 QPartialOrdering compare(
const void *lhs,
const void *rhs)
const;
493 bool equals(
const void *lhs,
const void *rhs)
const;
495 bool isDefaultConstructible()
const noexcept {
return d_ptr && isDefaultConstructible(d_ptr); }
496 bool isCopyConstructible()
const noexcept {
return d_ptr && isCopyConstructible(d_ptr); }
497 bool isMoveConstructible()
const noexcept {
return d_ptr && isMoveConstructible(d_ptr); }
498 bool isDestructible()
const noexcept {
return d_ptr && isDestructible(d_ptr); }
499 bool isEqualityComparable()
const;
500 bool isOrdered()
const;
502#ifndef QT_NO_DATASTREAM
503 bool save(QDataStream &stream,
const void *data)
const;
504 bool load(QDataStream &stream,
void *data)
const;
505 bool hasRegisteredDataStreamOperators()
const;
507#if QT_DEPRECATED_SINCE(6
, 0
)
508 QT_DEPRECATED_VERSION_6_0
509 static bool save(QDataStream &stream,
int type,
const void *data)
510 {
return QMetaType(type).save(stream, data); }
511 QT_DEPRECATED_VERSION_6_0
512 static bool load(QDataStream &stream,
int type,
void *data)
513 {
return QMetaType(type).load(stream, data); }
517 QMetaType underlyingType()
const;
520 constexpr static QMetaType fromType();
521 static QMetaType fromName(QByteArrayView name);
523 friend bool comparesEqual(
const QMetaType &lhs,
524 const QMetaType &rhs)
526 if (lhs.d_ptr == rhs.d_ptr)
528 if (!lhs.d_ptr || !rhs.d_ptr)
531 const int aId = lhs.id();
532 const int bId = rhs.id();
535 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QMetaType)
536#ifndef QT_NO_DEBUG_STREAM
538 friend Q_CORE_EXPORT QDebug operator<<(QDebug d, QMetaType m);
540 bool debugStream(QDebug& dbg,
const void *rhs);
541 bool hasRegisteredDebugStreamOperator()
const;
543#if QT_DEPRECATED_SINCE(6
, 0
)
544 QT_DEPRECATED_VERSION_6_0
545 static bool debugStream(QDebug& dbg,
const void *rhs,
int typeId)
546 {
return QMetaType(typeId).debugStream(dbg, rhs); }
548 QT_DEPRECATED_VERSION_6_0
549 static bool hasRegisteredDebugStreamOperator()
550 {
return QMetaType::fromType<T>().hasRegisteredDebugStreamOperator(); }
551 QT_DEPRECATED_VERSION_6_0
552 static bool hasRegisteredDebugStreamOperator(
int typeId)
553 {
return QMetaType(typeId).hasRegisteredDebugStreamOperator(); }
559 using ConverterFunction = std::function<
bool(
const void *src,
void *target)>;
562 using MutableViewFunction = std::function<
bool(
void *src,
void *target)>;
565 template<
typename From,
typename To>
566 static bool registerConverter()
568 return registerConverter<From, To>(QtPrivate::convertImplicit<From, To>);
572 template<
typename From,
typename To>
573 static bool registerConverter(To(From::*function)()
const)
575 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
576 "QMetaType::registerConverter: At least one of the types must be a custom type.");
578 const QMetaType fromType = QMetaType::fromType<From>();
579 const QMetaType toType = QMetaType::fromType<To>();
580 auto converter = [function](
const void *from,
void *to) ->
bool {
581 const From *f =
static_cast<
const From *>(from);
582 To *t =
static_cast<To *>(to);
583 *t = (f->*function)();
586 return registerConverterImpl<From, To>(converter, fromType, toType);
590 template<
typename From,
typename To>
591 static bool registerMutableView(To(From::*function)())
593 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
594 "QMetaType::registerMutableView: At least one of the types must be a custom type.");
596 const QMetaType fromType = QMetaType::fromType<From>();
597 const QMetaType toType = QMetaType::fromType<To>();
598 auto view = [function](
void *from,
void *to) ->
bool {
599 From *f =
static_cast<From *>(from);
600 To *t =
static_cast<To *>(to);
601 *t = (f->*function)();
604 return registerMutableViewImpl<From, To>(view, fromType, toType);
608 template<
typename From,
typename To>
609 static bool registerConverter(To(From::*function)(
bool*)
const)
611 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
612 "QMetaType::registerConverter: At least one of the types must be a custom type.");
614 const QMetaType fromType = QMetaType::fromType<From>();
615 const QMetaType toType = QMetaType::fromType<To>();
616 auto converter = [function](
const void *from,
void *to) ->
bool {
617 const From *f =
static_cast<
const From *>(from);
618 To *t =
static_cast<To *>(to);
620 *t = (f->*function)(&result);
625 return registerConverterImpl<From, To>(converter, fromType, toType);
629 template<
typename From,
typename To,
typename UnaryFunction>
630 static bool registerConverter(UnaryFunction function)
632 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
633 "QMetaType::registerConverter: At least one of the types must be a custom type.");
635 const QMetaType fromType = QMetaType::fromType<From>();
636 const QMetaType toType = QMetaType::fromType<To>();
637 auto converter = [function = std::move(function)](
const void *from,
void *to) ->
bool {
638 const From *f =
static_cast<
const From *>(from);
639 To *t =
static_cast<To *>(to);
640 auto &&r = function(*f);
641 if constexpr (std::is_same_v<q20::remove_cvref_t<
decltype(r)>, std::optional<To>>) {
644 *t = *std::forward<
decltype(r)>(r);
646 *t = std::forward<
decltype(r)>(r);
650 return registerConverterImpl<From, To>(std::move(converter), fromType, toType);
654 template<
typename From,
typename To,
typename UnaryFunction>
655 static bool registerMutableView(UnaryFunction function)
657 static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
658 "QMetaType::registerMutableView: At least one of the types must be a custom type.");
660 const QMetaType fromType = QMetaType::fromType<From>();
661 const QMetaType toType = QMetaType::fromType<To>();
662 auto view = [function = std::move(function)](
void *from,
void *to) ->
bool {
663 From *f =
static_cast<From *>(from);
664 To *t =
static_cast<To *>(to);
668 return registerMutableViewImpl<From, To>(std::move(view), fromType, toType);
672 template<
typename From,
typename To>
673 static bool registerConverterImpl(ConverterFunction converter, QMetaType fromType, QMetaType toType)
675 if (registerConverterFunction(std::move(converter), fromType, toType)) {
676 static const auto unregister = qScopeGuard([=] {
677 unregisterConverterFunction(fromType, toType);
685 template<
typename From,
typename To>
686 static bool registerMutableViewImpl(MutableViewFunction view, QMetaType fromType, QMetaType toType)
688 if (registerMutableViewFunction(std::move(view), fromType, toType)) {
689 static const auto unregister = qScopeGuard([=] {
690 unregisterMutableViewFunction(fromType, toType);
699 static bool convert(QMetaType fromType,
const void *from, QMetaType toType,
void *to);
700 static bool canConvert(QMetaType fromType, QMetaType toType);
702 static bool view(QMetaType fromType,
void *from, QMetaType toType,
void *to);
703 static bool canView(QMetaType fromType, QMetaType toType);
704#if QT_DEPRECATED_SINCE(6
, 0
)
705 QT_DEPRECATED_VERSION_6_0
706 static bool convert(
const void *from,
int fromTypeId,
void *to,
int toTypeId)
707 {
return convert(QMetaType(fromTypeId), from, QMetaType(toTypeId), to); }
708 QT_DEPRECATED_VERSION_6_0
709 static bool compare(
const void *lhs,
const void *rhs,
int typeId,
int *result)
712 auto c = t.compare(lhs, rhs);
713 if (c == QPartialOrdering::Unordered) {
716 }
else if (c == QPartialOrdering::Less) {
719 }
else if (c == QPartialOrdering::Equivalent) {
727 QT_DEPRECATED_VERSION_6_0
728 static bool equals(
const void *lhs,
const void *rhs,
int typeId,
int *result)
731 if (!t.isEqualityComparable())
733 *result = t.equals(lhs, rhs) ? 0 : -1;
738 template<
typename From,
typename To>
739 static bool hasRegisteredConverterFunction()
741 return hasRegisteredConverterFunction(
742 QMetaType::fromType<From>(), QMetaType::fromType<To>());
745 static bool hasRegisteredConverterFunction(QMetaType fromType, QMetaType toType);
747 template<
typename From,
typename To>
748 static bool hasRegisteredMutableViewFunction()
750 return hasRegisteredMutableViewFunction(
751 QMetaType::fromType<From>(), QMetaType::fromType<To>());
754 static bool hasRegisteredMutableViewFunction(QMetaType fromType, QMetaType toType);
757 template<
typename,
bool>
friend struct QtPrivate::SequentialValueTypeIsMetaType;
758 template<
typename,
bool>
friend struct QtPrivate::AssociativeValueTypeIsMetaType;
759 template<
typename,
bool>
friend struct QtPrivate::IsMetaTypePair;
760 template<
typename,
typename>
friend struct QtPrivate::MetaTypeSmartPointerHelper;
762 static bool registerConverterFunction(
const ConverterFunction &f, QMetaType from, QMetaType to);
763 static void unregisterConverterFunction(QMetaType from, QMetaType to);
765 static bool registerMutableViewFunction(
const MutableViewFunction &f, QMetaType from, QMetaType to);
766 static void unregisterMutableViewFunction(QMetaType from, QMetaType to);
768 static void unregisterMetaType(QMetaType type);
770#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
771 constexpr const QtPrivate::QMetaTypeInterface *iface() {
return d_ptr; }
773 constexpr const QtPrivate::QMetaTypeInterface *iface()
const {
return d_ptr; }
776 Q_DECL_PURE_FUNCTION
static bool isDefaultConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
777 Q_DECL_PURE_FUNCTION
static bool isCopyConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
778 Q_DECL_PURE_FUNCTION
static bool isMoveConstructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
779 Q_DECL_PURE_FUNCTION
static bool isDestructible(
const QtPrivate::QMetaTypeInterface *)
noexcept;
781#if QT_CORE_REMOVED_SINCE(6
, 5
)
782 int idHelper()
const;
784 static int registerHelper(
const QtPrivate::QMetaTypeInterface *iface);
785 int registerHelper()
const
788 if (
int id = d_ptr->typeId.loadRelaxed())
790 return registerHelper(d_ptr);
795 friend int qRegisterMetaType(QMetaType meta);
797 friend class QVariant;
798 const QtPrivate::QMetaTypeInterface *d_ptr =
nullptr;
801#undef QT_DEFINE_METATYPE_ID
803Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
805#define QT_METATYPE_PRIVATE_DECLARE_TYPEINFO(C, F)
807 Q_DECLARE_TYPEINFO(QtMetaTypePrivate:: C, (F));
808 namespace QtMetaTypePrivate {
820 typedef void (*
getFunc)(
const void *
const *p,
void *);
827 { *
static_cast<
typename T::first_type *>(dataPtr) =
static_cast<
const T*>(*pair)->first; }
830 { *
static_cast<
typename T::second_type *>(dataPtr) =
static_cast<
const T*>(*pair)->second; }
854template<
typename From>
857template<
typename T,
typename U>
870#define QT_FORWARD_DECLARE_SHARED_POINTER_TYPES_ITER(Name)
871 template <class T> class Name;
878 template<
typename T,
typename ODR_VIOLATION_PREVENTER>
884 using type =
decltype(check(
static_cast<T *>(
nullptr)));
888 template <
typename T,
typename ODR_VIOLATION_PREVENTER>
939 enum {
Value =
sizeof(checkType(
static_cast<T*>(
nullptr))) ==
sizeof(
yes_type) };
942 template<
typename T,
typename Enable =
void>
948 template <
typename X>
952 IsRealGadget =
sizeof(checkType(&T::qt_check_for_QGADGET_macro)) ==
sizeof(
void *),
957 template <
typename T>
960 template<
typename T,
typename Enable =
void>
967 template <
typename X>
986 enum {
Value =
sizeof(qt_getEnumMetaObject(
declval())) ==
sizeof(QMetaObject*) };
990 template<
typename T,
typename Enable =
void>
993 static constexpr const QMetaObject *
value() {
return nullptr; }
1004 template<
typename T>
1015 template<
typename T>
1024 template<
typename T>
1032 template<
typename T>
1038 template<
typename T>
1043 template<
typename T>
1049 template<
typename T>
1054 template<
typename T>
1060 template<
typename T>
1066 template<
typename T>
1072 template<
typename T>
1092 template<
typename T,
bool =
QMetaTypeId2<
typename T::value_type>::Defined>
1106 template<
typename T>
1125 template<
typename T,
bool =
QMetaTypeId2<
typename T::key_type>::Defined>
1139 template<
typename T,
bool =
QMetaTypeId2<
typename T::mapped_type>::Defined>
1153 template<
typename T>
1158 template<
typename T,
bool =
QMetaTypeId2<
typename T::first_type>::Defined
1168 template<
typename T>
1174 template<
typename T>
1182 template<
typename T,
typename U>
1185 template<
typename T>
1188 template<
typename T,
typename =
void>
1194#if QT_CONFIG(future)
1195 template<
typename T>
1206 "Meta Types must be fully defined");
1207 static_assert(!
std::is_reference_v<T>,
1208 "Meta Types cannot be non-const references or rvalue references.");
1210 using Pointed = std::remove_pointer_t<T>;
1211 static_assert(is_complete<Pointed,
void>::value,
1212 "Pointer Meta Types must either point to fully-defined types "
1213 "or be declared with Q_DECLARE_OPAQUE_POINTER(T *)");
1219template <
typename T,
int =
1220 QtPrivate::IsPointerToTypeDerivedFromQObject<T>::Value ? QMetaType::PointerToQObject :
1221 QtPrivate::IsRealGadget<T>::value ? QMetaType::IsGadget :
1222 QtPrivate::IsPointerToGadgetHelper<T>::IsRealGadget ? QMetaType::PointerToGadget :
1223 QtPrivate::IsQEnumHelper<T>::Value ? QMetaType::IsEnumeration : 0>
1224struct QMetaTypeIdQObject
1231template <
typename T>
1236template <
typename T>
1244template <
typename T>
1247template <
typename T>
1256 template <
typename T,
bool Defined =
QMetaTypeId2<T>::Defined>
1267 template <
typename Result,
typename... Args>
1270 template<
typename T>
1275 template<
typename T>
1278 template<
typename T,
bool defined>
1284 template<
typename SmartPointer>
1289 return p.operator->();
1295 template <
typename T>
1298 template<
typename T>
1308template <
typename T>
1311#ifndef QT_NO_QOBJECT
1312 Q_ASSERT_X(normalizedTypeName == QMetaObject::normalizedType(normalizedTypeName.constData()),
1313 "qRegisterNormalizedMetaType",
1314 "qRegisterNormalizedMetaType was called with a not normalized type name, "
1315 "please call qRegisterMetaType instead.");
1318 const QMetaType metaType = QMetaType::fromType<T>();
1319 const int id = metaType.id();
1321 QtPrivate::SequentialContainerTransformationHelper<T>::registerConverter();
1322 QtPrivate::SequentialContainerTransformationHelper<T>::registerMutableView();
1323 QtPrivate::AssociativeContainerTransformationHelper<T>::registerConverter();
1324 QtPrivate::AssociativeContainerTransformationHelper<T>::registerMutableView();
1326 QtPrivate::MetaTypeSmartPointerHelper<T>::registerConverter();
1327#if QT_CONFIG(future)
1328 QtPrivate::MetaTypeQFutureHelper<T>::registerConverter();
1331 if (normalizedTypeName != metaType.name())
1332 QMetaType::registerNormalizedTypedef(normalizedTypeName, metaType);
1347template <
typename T>
1350 return qRegisterNormalizedMetaTypeImplementation<T>(normalizedTypeName);
1353#if defined(QT_BOOTSTRAPPED)
1354#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
1355#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
1357#define QT_DECL_METATYPE_EXTERN_TAGGED(TYPE, TAG, EXPORT)
1359 EXPORT int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &);
1360 template <> inline int qRegisterNormalizedMetaType< TYPE >(const QByteArray &name)
1361 { return qRegisterNormalizedMetaType_ ## TAG (name); }
1365#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
1366 int qRegisterNormalizedMetaType_ ## TAG (const QByteArray &name)
1367 { return qRegisterNormalizedMetaTypeImplementation< TYPE >(name); }
1370#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
1372#define QT_IMPL_METATYPE_EXTERN(TYPE)
1375template <
typename T>
1379 QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = typeName;
1381 QT_PREPEND_NAMESPACE(QByteArray) normalizedTypeName = QMetaObject::normalizedType(typeName);
1383 return qRegisterNormalizedMetaType<T>(normalizedTypeName);
1386template <
typename T>
1395 return QMetaType::fromType<T>().id();
1399template <
typename T>
1402 int id = qMetaTypeId<T>();
1408 return meta.registerHelper();
1411#ifndef QT_NO_QOBJECT
1412template <
typename T>
1421 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1422 if (
const int id = metatype_id.loadAcquire())
1424 const char *
const cName = T::staticMetaObject.className();
1425 QByteArray typeName;
1426 typeName.reserve(strlen(cName) + 1);
1427 typeName.append(cName).append(
'*');
1428 const int newId = qRegisterNormalizedMetaType<T *>(typeName);
1429 metatype_id.storeRelease(newId);
1434template <
typename T>
1435struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
1438 Defined = std::is_default_constructible<T>::value
1441 static int qt_metatype_id()
1443 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1444 if (
const int id = metatype_id.loadAcquire())
1446 const char *
const cName = T::staticMetaObject.className();
1447 const int newId = qRegisterNormalizedMetaType<T>(cName);
1448 metatype_id.storeRelease(newId);
1453template <
typename T>
1454struct QMetaTypeIdQObject<T*, QMetaType::PointerToGadget>
1460 static int qt_metatype_id()
1462 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1463 if (
const int id = metatype_id.loadAcquire())
1465 const char *
const cName = T::staticMetaObject.className();
1466 QByteArray typeName;
1467 typeName.reserve(strlen(cName) + 1);
1468 typeName.append(cName).append(
'*');
1469 const int newId = qRegisterNormalizedMetaType<T *>(typeName);
1470 metatype_id.storeRelease(newId);
1475template <
typename T>
1476struct QMetaTypeIdQObject<T, QMetaType::IsEnumeration>
1482 static int qt_metatype_id()
1484 Q_CONSTINIT
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
1485 if (
const int id = metatype_id.loadAcquire())
1487 const char *eName = qt_getEnumName(T());
1488 const char *cName = qt_getEnumMetaObject(T())->className();
1489 QByteArray typeName;
1490 typeName.reserve(strlen(cName) + 2 + strlen(eName));
1491 typeName.append(cName).append(
"::").append(eName);
1492 const int newId = qRegisterNormalizedMetaType<T>(typeName);
1493 metatype_id.storeRelease(newId);
1499#define Q_DECLARE_OPAQUE_POINTER(POINTER)
1500 QT_BEGIN_NAMESPACE namespace QtPrivate {
1501 template <> struct IsPointerDeclaredOpaque<POINTER>
1502 : std::true_type {};
1508#define Q_DECLARE_METATYPE_IMPL(TYPE)
1511 struct QMetaTypeId< TYPE >
1513 enum { Defined = 1
};
1514 static_assert(QtPrivate::checkTypeIsSuitableForMetaType<TYPE>());
1515 static int qt_metatype_id()
1517 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1518 if (const int id = metatype_id.loadAcquire())
1520 constexpr auto arr = QtPrivate::typenameHelper<TYPE>();
1521 auto name = arr.data();
1522 if (QByteArrayView(name) == (#TYPE)) {
1523 const int id = qRegisterNormalizedMetaType<TYPE>(name);
1524 metatype_id.storeRelease(id);
1527 const int newId = qRegisterMetaType< TYPE >(#TYPE);
1528 metatype_id.storeRelease(newId);
1535#define Q_DECLARE_BUILTIN_METATYPE(TYPE, METATYPEID, NAME)
1537 template<> struct QMetaTypeId2<NAME>
1539 using NameAsArrayType = std::array<char, sizeof(#NAME)>;
1540 enum { Defined = 1
, IsBuiltIn = true, MetaType = METATYPEID };
1541 static inline constexpr int qt_metatype_id() { return METATYPEID; }
1542 static constexpr NameAsArrayType nameAsArray = { #NAME };
1546#define QT_FORWARD_DECLARE_STATIC_TYPES_ITER(TypeName, TypeId, Name)
1553#undef QT_FORWARD_DECLARE_STATIC_TYPES_ITER
1555#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) QT_BEGIN_NAMESPACE
1558 QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
1559{
1561 Defined = QMetaTypeId2<T>::Defined
1563 static int qt_metatype_id()
1565 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1566 if (const int id = metatype_id.loadRelaxed())
1568 const char *tName = QMetaType::fromType<T>().name();
1570 const size_t tNameLen = qstrlen(tName);
1571 QByteArray typeName;
1572 typeName.reserve(sizeof(#SINGLE_ARG_TEMPLATE) + 1
+ tNameLen + 1
+ 1
);
1573 typeName.append(#SINGLE_ARG_TEMPLATE, int(sizeof(#SINGLE_ARG_TEMPLATE)) - 1
)
1574 .append('<').append(tName, tNameLen);
1575 typeName.append('>');
1576 const int newId = qRegisterNormalizedMetaType< SINGLE_ARG_TEMPLATE<T> >(typeName);
1577 metatype_id.storeRelease(newId);
1580};QT_END_NAMESPACE
1583#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) QT_BEGIN_NAMESPACE
1585 <typename T, typename U> struct
1586 QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
1587{
1589 Defined = QMetaTypeId2<T>::Defined && QMetaTypeId2<U>::Defined
1591 static int qt_metatype_id()
1593 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1594 if (const int id = metatype_id.loadAcquire())
1596 const char *tName = QMetaType::fromType<T>().name();
1597 const char *uName = QMetaType::fromType<U>().name();
1600 const size_t tNameLen = qstrlen(tName);
1601 const size_t uNameLen = qstrlen(uName);
1602 QByteArray typeName;
1603 typeName.reserve(sizeof(#DOUBLE_ARG_TEMPLATE) + 1
+ tNameLen + 1
+ uNameLen + 1
+ 1
);
1604 typeName.append(#DOUBLE_ARG_TEMPLATE, int(sizeof(#DOUBLE_ARG_TEMPLATE)) - 1
)
1605 .append('<').append(tName, tNameLen).append(',').append(uName, uNameLen);
1606 typeName.append('>');
1607 const int newId = qRegisterNormalizedMetaType< DOUBLE_ARG_TEMPLATE<T, U> >(typeName);
1608 metatype_id.storeRelease(newId);
1611};QT_END_NAMESPACE
1616template<
typename T,
bool =
false>
1630#define Q_DECLARE_SMART_POINTER_METATYPE(SMART_POINTER) QT_BEGIN_NAMESPACE
1632 QtPrivate { template
1634 SharedPointerMetaTypeIdHelper<SMART_POINTER<T>, true> \
1635{
1639 static int qt_metatype_id()
1641 Q_CONSTINIT static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0
);
1642 if (const int id = metatype_id.loadAcquire())
1644 const char * const cName = T::staticMetaObject.className();
1645 QByteArray typeName;
1646 typeName.reserve(sizeof(#SMART_POINTER) + 1
+ strlen(cName) + 1
);
1647 typeName.append(#SMART_POINTER, int(sizeof(#SMART_POINTER)) - 1
)
1648 .append('<').append(cName).append('>');
1649 const int newId = qRegisterNormalizedMetaType< SMART_POINTER<T> >(typeName);
1650 metatype_id.storeRelease(newId);
1653};template
1655 MetaTypeSmartPointerHelper<SMART_POINTER<T> ,
1656 typename std::enable_if<IsPointerToTypeDerivedFromQObject<T*>::Value && !std::is_const_v<T>>::type> \
1657{
1658 static bool registerConverter()
1660 const QMetaType to = QMetaType(QMetaType::QObjectStar);
1661 if (!QMetaType::hasRegisteredConverterFunction(QMetaType::fromType<SMART_POINTER<T>>(), to)) {
1662 QtPrivate::QSmartPointerConvertFunctor<SMART_POINTER<T> > o;
1663 return QMetaType::registerConverter<SMART_POINTER<T>, QObject*>(o);
1667};\
1668}template
1670 QMetaTypeId< SMART_POINTER<T> >
1671 : QtPrivate::SharedPointerMetaTypeIdHelper< SMART_POINTER<T>,
1672 QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value> \
1673{\
1674};QT_END_NAMESPACE
1677#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(SINGLE_ARG_TEMPLATE)
1679 namespace QtPrivate {
1680 template<typename T>
1681 struct IsSequentialContainer<SINGLE_ARG_TEMPLATE<T> >
1683 enum { Value = true };
1689#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER(TEMPLATENAME)
1696#undef Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER
1701#define Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(TEMPLATENAME)
1703 namespace QtPrivate {
1704 template<typename T, typename U>
1705 struct IsAssociativeContainer<TEMPLATENAME<T, U> >
1707 enum { Value = true };
1719#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME)
1726#undef Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER
1744template <
typename T>
1747 if (!QtPrivate::hasRegisteredConverterFunctionToPairVariantInterface(QMetaType::fromType<T>())) {
1749 return QMetaType::registerConverter<T, QtMetaTypePrivate::QPairVariantInterfaceImpl>(o);
1756template<
typename From>
1761 return QIterable<QMetaSequence>(QMetaSequence::fromContainer<From>(), &f);
1765template<
typename From>
1770 return QIterable<QMetaSequence>(QMetaSequence::fromContainer<From>(), &f);
1779 if (!QtPrivate::hasRegisteredConverterFunctionToIterableMetaSequence(QMetaType::fromType<T>())) {
1781 return QMetaType::registerConverter<T, QIterable<QMetaSequence>>(o);
1788 if (!QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaSequence(QMetaType::fromType<T>())) {
1790 return QMetaType::registerMutableView<T, QIterable<QMetaSequence>>(o);
1796template<
typename From>
1801 return QIterable<QMetaAssociation>(QMetaAssociation::fromContainer<From>(), &f);
1805template<
typename From>
1810 return QIterable<QMetaAssociation>(QMetaAssociation::fromContainer<From>(), &f);
1821 if (!QtPrivate::hasRegisteredConverterFunctionToIterableMetaAssociation(QMetaType::fromType<T>())) {
1823 return QMetaType::registerConverter<T, QIterable<QMetaAssociation>>(o);
1830 if (!QtPrivate::hasRegisteredMutableViewFunctionToIterableMetaAssociation(QMetaType::fromType<T>())) {
1832 return QMetaType::registerMutableView<T, QIterable<QMetaAssociation>>(o);
1845 static constexpr bool is_ident_char(
char s)
1847 return ((s >=
'a' && s <=
'z') || (s >=
'A' && s <=
'Z') || (s >=
'0' && s <=
'9')
1850 static constexpr bool is_space(
char s) {
return (s ==
' ' || s ==
'\t' || s ==
'\n'); }
1851 static constexpr bool is_number(
char s) {
return s >=
'0' && s <=
'9'; }
1852 static constexpr bool starts_with_token(
const char *b,
const char *e,
const char *token,
1853 bool msvcKw =
false)
1855 while (b != e && *token && *b == *token) {
1864 if (msvcKw && !is_ident_char(*b))
1868 return b == e || !is_ident_char(*b);
1870 static constexpr bool skipToken(
const char *&x,
const char *e,
const char *token,
1871 bool msvcKw =
false)
1873 if (!starts_with_token(x, e, token, msvcKw))
1877 while (x != e && is_space(*x))
1881 static constexpr const char *skipString(
const char *x,
const char *e)
1885 while (x != e && *x != delim) {
1897 static constexpr const char *skipTemplate(
const char *x,
const char *e,
bool stopAtComa =
false)
1900 int templateDepth = 0;
1908 if (stopAtComa && !scopeDepth && !templateDepth)
1913 if (--templateDepth < 0)
1927 if (is_number(x[-1]))
1931 x = skipString(x, e);
1939 constexpr void append(
char x)
1947 constexpr void replaceLast(
char x)
1954 constexpr void appendStr(
const char *x)
1960 constexpr void normalizeIntegerTypes(
const char *&begin,
const char *end)
1964 int numUnsigned = 0;
1968 while (begin < end) {
1969 if (skipToken(begin, end,
"long")) {
1973 if (skipToken(begin, end,
"int")) {
1977 if (skipToken(begin, end,
"short")) {
1981 if (skipToken(begin, end,
"unsigned")) {
1985 if (skipToken(begin, end,
"signed")) {
1989 if (skipToken(begin, end,
"char")) {
1994 if (skipToken(begin, end,
"__int64")) {
2003 if (numSigned && numChar)
2004 appendStr(
"signed ");
2005 else if (numUnsigned)
2011 else if (numLong == 1)
2013 else if (numLong == 2)
2014 appendStr(
"longlong");
2015 else if (numUnsigned || numSigned || numInt)
2019 constexpr void skipStructClassOrEnum(
const char *&begin,
const char *end)
2023 skipToken(begin, end,
"struct",
true) || skipToken(begin, end,
"class",
true)
2024 || skipToken(begin, end,
"enum",
true);
2027 constexpr void skipQtNamespace(
const char *&begin,
const char *end)
2030 const char *nsbeg = begin;
2031 if (skipToken(nsbeg, end, QT_STRINGIFY(QT_NAMESPACE)) && nsbeg + 2 < end && nsbeg[0] ==
':'
2032 && nsbeg[1] ==
':') {
2034 while (begin != end && is_space(*begin))
2044#if defined(Q_CC_CLANG) || defined (Q_CC_GNU)
2052#if defined (Q_CC_CLANG)
2059 if (*
begin ==
' ') {
2097 constexpr int normalizeType(
const char *begin,
const char *end,
bool adjustConst =
true)
2100 while (begin != end && is_space(*begin))
2102 while (begin != end && is_space(*(end - 1)))
2110 const char *cst = begin + 1;
2111 if (*begin ==
'\'' || *begin ==
'"')
2112 cst = skipString(begin, end);
2113 bool seenStar =
false;
2114 bool hasMiddleConst =
false;
2116 if (*cst ==
'\"' || (*cst ==
'\'' && !is_number(cst[-1]))) {
2117 cst = skipString(cst, end);
2124 if (*cst ==
'&' || *cst ==
'*' || *cst ==
'[') {
2125 seenStar = *cst !=
'&' || cst != (end - 1);
2129 cst = skipTemplate(cst + 1, end);
2134 const char *skipedCst = cst;
2135 if (!is_ident_char(*(cst - 1)) && skipToken(skipedCst, end,
"const")) {
2136 const char *testEnd = end;
2137 while (skipedCst < testEnd--) {
2138 if (*testEnd ==
'*' || *testEnd ==
'['
2139 || (*testEnd ==
'&' && testEnd != (end - 1))) {
2143 if (*testEnd ==
'>')
2146 if (adjustConst && !seenStar) {
2147 if (*(end - 1) ==
'&')
2150 appendStr(
"const ");
2154 hasMiddleConst =
true;
2158 if (skipToken(begin, end,
"const")) {
2159 if (adjustConst && !seenStar) {
2160 if (*(end - 1) ==
'&')
2163 appendStr(
"const ");
2166 if (seenStar && adjustConst) {
2167 const char *e = end;
2168 if (*(end - 1) ==
'&' && *(end - 2) !=
'&')
2170 while (begin != e && is_space(*(e - 1)))
2172 const char *token =
"tsnoc";
2173 while (*token && begin != e && *(--e) == *token++)
2175 if (!*token && begin != e && !is_ident_char(*(e - 1))) {
2176 while (begin != e && is_space(*(e - 1)))
2182 skipStructClassOrEnum(begin, end);
2183 skipQtNamespace(begin, end);
2185 if (skipToken(begin, end,
"QVector")) {
2190 if (skipToken(begin, end,
"QPair")) {
2192 appendStr(
"std::pair");
2195 if (!hasMiddleConst)
2197 normalizeIntegerTypes(begin, end);
2199 bool spaceSkiped =
true;
2200 while (begin != end) {
2204 }
else if ((c ==
'\'' && !is_number(
last)) || c ==
'\"') {
2206 auto x = skipString(begin, end);
2210 if (spaceSkiped && is_ident_char(
last) && is_ident_char(c))
2213 spaceSkiped =
false;
2217 const char *tpl = skipTemplate(begin, end,
true);
2223 }
while (*begin++ ==
',');
2242template <
typename T1_,
typename T2_>
2255 std::remove_const_t<std::conditional_t<
bool (QMetaTypeId2<T1>::IsBuiltIn),
typename QMetaTypeId2<T1>::NameAsArrayType,
decltype(typenameHelper<T1>())>> t1Name {};
2256 std::remove_const_t<std::conditional_t<
bool (QMetaTypeId2<T2>::IsBuiltIn),
typename QMetaTypeId2<T2>::NameAsArrayType,
decltype(typenameHelper<T2>())>> t2Name {};
2260 t1Name = typenameHelper<T1>();
2265 t2Name = typenameHelper<T2>();
2267 constexpr auto nonTypeDependentLen =
sizeof(
"std::pair<,>");
2268 constexpr auto t1Len = t1Name.size() - 1;
2269 constexpr auto t2Len = t2Name.size() - 1;
2270 constexpr auto length = nonTypeDependentLen + t1Len + t2Len;
2271 std::array<
char, length + 1> result {};
2272 constexpr auto prefix =
"std::pair<";
2273 int currentLength = 0;
2274 for (; currentLength <
int(
sizeof(
"std::pair<") - 1); ++currentLength)
2275 result[currentLength] = prefix[currentLength];
2276 for (
int i = 0; i <
int(t1Len); ++currentLength, ++i)
2277 result[currentLength] = t1Name[i];
2278 result[currentLength++] =
',';
2279 for (
int i = 0; i <
int(t2Len); ++currentLength, ++i)
2280 result[currentLength] = t2Name[i];
2281 result[currentLength++] =
'>';
2282 result[currentLength++] =
'\0';
2285 constexpr auto prefix =
sizeof(
2287 QT_STRINGIFY(QT_NAMESPACE)
"::"
2289#if defined(Q_CC_MSVC) && defined(Q_CC_CLANG)
2290 "auto __cdecl QtPrivate::TypeNameHelper::typenameHelper(void) [T = "
2291#elif defined(Q_CC_MSVC)
2292 "auto __cdecl QtPrivate::TypeNameHelper::typenameHelper<"
2293#elif defined(Q_CC_CLANG)
2294 "auto QtPrivate::TypeNameHelper::typenameHelper() [T = "
2295#elif defined(Q_CC_GHS)
2296 "auto QtPrivate::TypeNameHelper::typenameHelper<T>()[with T="
2298 "constexpr auto QtPrivate::TypeNameHelper::typenameHelper() [with T = "
2301#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG)
2302 constexpr int suffix =
sizeof(
">(void)");
2304 constexpr int suffix =
sizeof(
"]");
2307#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU_ONLY < 804
2308 auto func = Q_FUNC_INFO;
2309 const char *begin = func + prefix;
2310 const char *end = func +
sizeof(Q_FUNC_INFO) - suffix;
2312 constexpr int len =
sizeof(Q_FUNC_INFO) - suffix - prefix;
2314 constexpr auto func = Q_FUNC_INFO;
2315 constexpr const char *begin = func + prefix;
2316 constexpr const char *end = func +
sizeof(Q_FUNC_INFO) - suffix;
2319 std::array<
char, len + 1> result {};
2327template<
typename T,
typename =
void>
2341QT_WARNING_DISABLE_FLOAT_COMPARE
2343 {
return *
reinterpret_cast<
const T *>(
a) == *
reinterpret_cast<
const T *>(
b); }
2357 {
return *
reinterpret_cast<
const T *>(a) < *
reinterpret_cast<
const T *>(b); }
2372#ifndef QT_NO_DEBUG_STREAM
2377 { dbg << *
reinterpret_cast<
const T *>(a); }
2388#ifndef QT_NO_DATASTREAM
2393 { ds << *
reinterpret_cast<
const T *>(a); }
2395 { ds >> *
reinterpret_cast<T *>(a); }
2409#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG)
2410# pragma GCC visibility push(hidden)
2419 template <
typename T>
2422#if !defined(QT_BOOTSTRAPPED)
2431 static constexpr decltype(typenameHelper<S>())
name = typenameHelper<S>();
2436 if constexpr (QTypeInfo<S>::isRelocatable)
2437 flags |= QMetaType::RelocatableType;
2438 if constexpr (!std::is_default_constructible_v<S> || !QTypeInfo<S>::isValueInitializationBitwiseZero)
2439 flags |= QMetaType::NeedsConstruction;
2440 if constexpr (!std::is_trivially_destructible_v<S>)
2441 flags |= QMetaType::NeedsDestruction;
2442 if constexpr (!std::is_trivially_copy_constructible_v<S>)
2443 flags |= QMetaType::NeedsCopyConstruction;
2444 if constexpr (!std::is_trivially_move_constructible_v<S>)
2445 flags |= QMetaType::NeedsMoveConstruction;
2446 if constexpr (IsPointerToTypeDerivedFromQObject<S>::Value)
2447 flags |= QMetaType::PointerToQObject;
2448 if constexpr (IsSharedPointerToTypeDerivedFromQObject<S>::Value)
2449 flags |= QMetaType::SharedPointerToQObject;
2450 if constexpr (IsWeakPointerToTypeDerivedFromQObject<S>::Value)
2451 flags |= QMetaType::WeakPointerToQObject;
2452 if constexpr (IsTrackingPointerToTypeDerivedFromQObject<S>::Value)
2453 flags |= QMetaType::TrackingPointerToQObject;
2454 if constexpr (IsEnumOrFlags<S>::value)
2455 flags |= QMetaType::IsEnumeration;
2456 if constexpr (IsGadgetHelper<S>::IsGadgetOrDerivedFrom)
2457 flags |= QMetaType::IsGadget;
2458 if constexpr (IsPointerToGadgetHelper<S>::IsGadgetOrDerivedFrom)
2459 flags |= QMetaType::PointerToGadget;
2460 if constexpr (std::is_pointer_v<S>)
2461 flags |= QMetaType::IsPointer;
2462 if constexpr (IsUnsignedEnum<S>)
2463 flags |= QMetaType::IsUnsignedEnumeration;
2464 if constexpr (IsQmlListType<S>)
2465 flags |= QMetaType::IsQmlList;
2466 if constexpr (std::is_const_v<std::remove_pointer_t<S>>)
2467 flags |= QMetaType::IsConst;
2473 if constexpr (std::is_default_constructible_v<S> && !QTypeInfo<S>::isValueInitializationBitwiseZero) {
2482 if constexpr (
std::is_copy_constructible_v<S> && !
std::is_trivially_copy_constructible_v<S>) {
2484 if constexpr (qxp::is_detected_v<QMetaTypeCopyTraits::HasDeprecatedCopyConstructorTest, S>) {
2485#if !defined(QT_BOOTSTRAPPED)
2488 QT_IGNORE_DEPRECATIONS(
new (addr) S(*
reinterpret_cast<
const S *>(other));)
2490 new (addr) S(*
reinterpret_cast<
const S *>(other));
2500 if constexpr (
std::is_move_constructible_v<S> && !
std::is_trivially_move_constructible_v<S>) {
2502 new (addr) S(
std::move(*
reinterpret_cast<S *>(other)));
2511 if constexpr (
std::is_destructible_v<S> && !
std::is_trivially_destructible_v<S>)
2513 reinterpret_cast<S *>(addr)->~S();
2570#if !defined(Q_OS_WIN) && defined(Q_CC_CLANG)
2571# pragma GCC visibility pop
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610#if !defined(QT_BOOTSTRAPPED) && !defined(Q_CC_MSVC) && !defined(Q_OS_INTEGRITY)
2612#ifdef QT_NO_DATA_RELOCATION
2613# define QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER(TypeName, Id, Name)
2614 extern template class Q_CORE_EXPORT QMetaTypeForType<Name>;
2616# define QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER(TypeName, Id, Name)
2617 extern template class Q_CORE_EXPORT QMetaTypeForType<Name>;
2618 extern template struct Q_CORE_EXPORT QMetaTypeInterfaceWrapper<Name>;
2626#undef QT_METATYPE_DECLARE_EXTERN_TEMPLATE_ITER
2635#define Q_REMOVE_POINTER_LIKE_IMPL(Pointer) template
2637 QRemovePointerLike<Pointer<T>> \
2638{
2640};
2643#undef Q_REMOVE_POINTER_LIKE_IMPL
2658template<
typename Unique,
typename T>
2664 if constexpr (
std::is_void_v<Tz>) {
2667 }
else if constexpr (
std::is_void_v<Unique>) {
2668 checkTypeIsSuitableForMetaType<Ty>();
2670 }
else if constexpr (
std::is_reference_v<Tz>) {
2672 }
else if constexpr (!
is_complete<Tz, Unique>::value) {
2683constexpr QMetaType QMetaType::fromType()
2685 QtPrivate::checkTypeIsSuitableForMetaType<T>();
2686 return QMetaType(QtPrivate::qMetaTypeInterfaceForType<T>());
2689constexpr bool QMetaType::isValid(QT6_IMPL_NEW_OVERLOAD)
const noexcept
2694bool QMetaType::isRegistered(QT6_IMPL_NEW_OVERLOAD)
const noexcept
2696 return d_ptr && d_ptr->typeId.loadRelaxed();
2699constexpr qsizetype QMetaType::sizeOf()
const
2701 return d_ptr ? d_ptr->size : 0;
2704constexpr qsizetype QMetaType::alignOf()
const
2706 return d_ptr ? d_ptr->alignment : 0;
2709constexpr QMetaType::TypeFlags QMetaType::flags()
const
2711 return d_ptr ? TypeFlags(d_ptr->flags) : TypeFlags{};
2714constexpr const QMetaObject *QMetaType::metaObject()
const
2716 return d_ptr && d_ptr->metaObjectFn ? d_ptr->metaObjectFn(d_ptr) :
nullptr;
2719constexpr const char *QMetaType::name()
const
2721 return d_ptr ? d_ptr->name :
nullptr;
2728 return qHash(type.id(), seed);
2734 QPairVariantInterfaceImpl, Q_CORE_EXPORT)
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