Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmetatype.cpp File Reference

(2ce6fd48e0219615d16ff2f93f85462c67848171)

#include "qmetatype.h"
#include "qmetatype_p.h"
#include "qbytearray.h"
#include "qdatetime.h"
#include "qdebug.h"
#include "qhash.h"
#include "qlist.h"
#include "qlocale.h"
#include "qmap.h"
#include "private/qnumeric_p.h"
#include "qobjectdefs.h"
#include "private/qoffsetstringarray_p.h"
#include "qreadwritelock.h"
#include "qstring.h"
#include "qstringlist.h"
#include "qdatastream.h"
#include "qassociativeiterable.h"
#include "qbitarray.h"
#include "qbytearraylist.h"
#include "qcborarray.h"
#include "qcbormap.h"
#include "qcborvalue.h"
#include "qjsonarray.h"
#include "qjsondocument.h"
#include "qjsonobject.h"
#include "qjsonvalue.h"
#include "qline.h"
#include "qloggingcategory.h"
#include "qmetaobject.h"
#include "qobject.h"
#include "qpoint.h"
#include "qrect.h"
#include "qsequentialiterable.h"
#include "qsize.h"
#include "qurl.h"
#include "quuid.h"
#include "qvariant.h"
#include <new>
#include <cstring>
Include dependency graph for qmetatype.cpp:

Go to the source code of this file.

Classes

class  QMetaTypeFunctionRegistry< T, Key >

Namespaces

namespace  QtPrivate

Macros

#define NS(x)
#define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName)
#define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr)
#define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName)
#define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr)
#define QMETATYPE_CONVERTER_ASSIGN_DOUBLE(To, From)
#define QMETATYPE_CONVERTER_ASSIGN_NUMBER(To, From)
#define CONVERT_CBOR_AND_JSON(To)
#define INTEGRAL_CONVERTER(To)
#define FLOAT_CONVERTER(To)
#define QMETATYPE_CONVERTER_ASSIGN_QCHAR(From)
#define QT_METATYPE_DECLARE_TEMPLATE_ITER(TypeName, Id, Name)

Typedefs

using QMetaTypeConverterRegistry = QMetaTypeFunctionRegistry<QMetaType::ConverterFunction, std::pair<int,int>>
using QMetaTypeMutableViewRegistry = QMetaTypeFunctionRegistry<QMetaType::MutableViewFunction, std::pair<int,int>>

Functions

QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY (lcMetatypeDeprecated, "qt.core.qmetatype.deprecated")
static QPartialOrdering threeWayCompare (const void *ptr1, const void *ptr2)
static constexpr auto createStaticTypeToIdMap ()
template<typename From, typename To>
static bool qIntegerConversionFromFPHelper (From from, To *to)
static bool tryConvertBuiltinTypes (const void *from, int fromTypeId, void *to, int toTypeId)
QDebug operator<< (QDebug d, QMetaType m)
static QMetaEnum metaEnumFromType (QMetaType t)
static bool convertFromEnum (QMetaType fromType, const void *from, QMetaType toType, void *to)
static bool convertToEnum (QMetaType fromType, const void *from, QMetaType toType, void *to)
static bool convertIterableToVariantList (QMetaType fromType, const void *from, void *to)
static bool convertIterableToVariantMap (QMetaType fromType, const void *from, void *to)
static bool convertIterableToVariantHash (QMetaType fromType, const void *from, void *to)
static bool convertIterableToVariantPair (QMetaType fromType, const void *from, void *to)
static bool convertToSequentialIterable (QMetaType fromType, const void *from, void *to)
static bool canConvertToSequentialIterable (QMetaType fromType)
static bool canImplicitlyViewAsSequentialIterable (QMetaType fromType)
static bool viewAsSequentialIterable (QMetaType fromType, void *from, void *to)
static bool convertToAssociativeIterable (QMetaType fromType, const void *from, void *to)
static bool canConvertMetaObject (QMetaType fromType, QMetaType toType)
static bool canConvertToAssociativeIterable (QMetaType fromType)
static bool canImplicitlyViewAsAssociativeIterable (QMetaType fromType)
static bool viewAsAssociativeIterable (QMetaType fromType, void *from, void *to)
static bool convertMetaObject (QMetaType fromType, const void *from, QMetaType toType, void *to)
static int qMetaTypeStaticType (QByteArrayView name)
static const QtPrivate::QMetaTypeInterfaceinterfaceForStaticType (int typeId)
static const QtPrivate::QMetaTypeInterfaceinterfaceForTypeNoWarning (int typeId)
static const QtPrivate::QMetaTypeInterfacefindMetaTypeByName (QByteArrayView name)
int qMetaTypeTypeInternal (QByteArrayView name)
static const QtPrivate::QMetaTypeInterfaceinterfaceForType (int typeId)
template<typename T>
bool isInterfaceFor (const QtPrivate::QMetaTypeInterface *iface)
template<typename T>
bool isInterfaceFor (const QtPrivate::QMetaTypeInterface *iface)

Variables

static constexpr auto types = createStaticTypeToIdMap()
Q_CONSTINIT Q_CORE_EXPORT QMetaTypeModuleHelper qMetaTypeGuiHelper = {}
Q_CONSTINIT Q_CORE_EXPORT QMetaTypeModuleHelper qMetaTypeWidgetsHelper = {}

Macro Definition Documentation

◆ CONVERT_CBOR_AND_JSON

#define CONVERT_CBOR_AND_JSON ( To)
Value:
if constexpr(std::is_same_v<To, Bool>) { \
if (!source.isBool()) \
return false; \
result = source.toBool(); \
} else { \
if (!source.isInteger() && !source.isDouble()) \
return false; \
if constexpr(std::is_integral_v<To>) \
result = source.toInteger(); \
else \
result = To(source.toDouble()); \
} \
return true; \
); \
QMETATYPE_CONVERTER(To, QJsonValue, \
if constexpr(std::is_same_v<To, Bool>) { \
if (!source.isBool()) \
return false; \
result = source.toBool(); \
} else { \
if (!source.isDouble()) \
return false; \
if constexpr(std::is_integral_v<To>) \
result = source.toInteger(); \
else \
result = To(source.toDouble()); \
} \
return true; \
)
\inmodule QtCore\reentrant
Definition qcborvalue.h:48
#define QMETATYPE_CONVERTER(To, From, assign_and_return)
Definition qmetatype_p.h:23
GLsizei GLsizei GLchar * source
GLuint64EXT * result
[6]

◆ FLOAT_CONVERTER

#define FLOAT_CONVERTER ( To)
Value:
QMETATYPE_CONVERTER_ASSIGN(To, Char); \
QMETATYPE_CONVERTER_ASSIGN(To, UChar); \
QMETATYPE_CONVERTER_ASSIGN(To, SChar); \
QMETATYPE_CONVERTER_ASSIGN(To, Short); \
QMETATYPE_CONVERTER_ASSIGN(To, UShort); \
QMETATYPE_CONVERTER_ASSIGN(To, Int); \
QMETATYPE_CONVERTER_ASSIGN(To, UInt); \
QMETATYPE_CONVERTER_ASSIGN(To, Long); \
QMETATYPE_CONVERTER_ASSIGN(To, ULong); \
QMETATYPE_CONVERTER_ASSIGN(To, LongLong); \
QMETATYPE_CONVERTER_ASSIGN(To, ULongLong); \
QMETATYPE_CONVERTER_ASSIGN(To, Float16); \
QMETATYPE_CONVERTER_ASSIGN(To, Float); \
QMETATYPE_CONVERTER_ASSIGN(To, Double); \
QMETATYPE_CONVERTER(To, QString, \
bool ok = false; \
result = To(source.toDouble(&ok)); \
return ok; \
); \
QMETATYPE_CONVERTER(To, QByteArray, \
bool ok = false; \
result = To(source.toDouble(&ok)); \
return ok; \
); \
CONVERT_CBOR_AND_JSON(To)
\inmodule QtCore
Definition qbytearray.h:58
static bool ok(QGradientStop stop)
Definition qbrush.cpp:1681
#define QMETATYPE_CONVERTER_ASSIGN(To, From)
Definition qmetatype_p.h:34
char Char

◆ INTEGRAL_CONVERTER

#define INTEGRAL_CONVERTER ( To)

◆ NS

#define NS ( x)
Value:
QT_PREPEND_NAMESPACE(x)
GLint GLint GLint GLint GLint x

Definition at line 70 of file qmetatype.cpp.

◆ QMETATYPE_CONVERTER_ASSIGN_DOUBLE

#define QMETATYPE_CONVERTER_ASSIGN_DOUBLE ( To,
From )
Value:
QMETATYPE_CONVERTER(To, From, result = double(source); return true;)

◆ QMETATYPE_CONVERTER_ASSIGN_NUMBER

#define QMETATYPE_CONVERTER_ASSIGN_NUMBER ( To,
From )
Value:
QMETATYPE_CONVERTER(To, From, result = To::number(source); return true;)

◆ QMETATYPE_CONVERTER_ASSIGN_QCHAR

#define QMETATYPE_CONVERTER_ASSIGN_QCHAR ( From)
Value:
QMETATYPE_CONVERTER(QChar, From, result = QChar::fromUcs2(source); return true;)
\inmodule QtCore

◆ QT_ADD_STATIC_METATYPE [1/2]

#define QT_ADD_STATIC_METATYPE ( MetaTypeName,
MetaTypeId,
RealName )
Value:
#RealName,

◆ QT_ADD_STATIC_METATYPE [2/2]

#define QT_ADD_STATIC_METATYPE ( MetaTypeName,
MetaTypeId,
RealName )
Value:
MetaTypeId,

◆ QT_ADD_STATIC_METATYPE_ALIASES_ITER [1/2]

#define QT_ADD_STATIC_METATYPE_ALIASES_ITER ( MetaTypeName,
MetaTypeId,
AliasingName,
RealNameStr )
Value:
RealNameStr,

◆ QT_ADD_STATIC_METATYPE_ALIASES_ITER [2/2]

#define QT_ADD_STATIC_METATYPE_ALIASES_ITER ( MetaTypeName,
MetaTypeId,
AliasingName,
RealNameStr )
Value:
QMetaType::MetaTypeName,

◆ QT_METATYPE_DECLARE_TEMPLATE_ITER

#define QT_METATYPE_DECLARE_TEMPLATE_ITER ( TypeName,
Id,
Name )
Value:
template class QMetaTypeForType<Name>; \
template struct QMetaTypeInterfaceWrapper<Name>;

Definition at line 3385 of file qmetatype.cpp.

Typedef Documentation

◆ QMetaTypeConverterRegistry

◆ QMetaTypeMutableViewRegistry

Function Documentation

◆ canConvertMetaObject()

bool canConvertMetaObject ( QMetaType fromType,
QMetaType toType )
static

Definition at line 2349 of file qmetatype.cpp.

◆ canConvertToAssociativeIterable()

bool canConvertToAssociativeIterable ( QMetaType fromType)
static

Definition at line 2362 of file qmetatype.cpp.

◆ canConvertToSequentialIterable()

bool canConvertToSequentialIterable ( QMetaType fromType)
static

Definition at line 2261 of file qmetatype.cpp.

◆ canImplicitlyViewAsAssociativeIterable()

bool canImplicitlyViewAsAssociativeIterable ( QMetaType fromType)
static

Definition at line 2373 of file qmetatype.cpp.

◆ canImplicitlyViewAsSequentialIterable()

bool canImplicitlyViewAsSequentialIterable ( QMetaType fromType)
static

Definition at line 2275 of file qmetatype.cpp.

◆ convertFromEnum()

bool convertFromEnum ( QMetaType fromType,
const void * from,
QMetaType toType,
void * to )
static

Definition at line 2027 of file qmetatype.cpp.

◆ convertIterableToVariantHash()

bool convertIterableToVariantHash ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2181 of file qmetatype.cpp.

◆ convertIterableToVariantList()

bool convertIterableToVariantList ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2152 of file qmetatype.cpp.

◆ convertIterableToVariantMap()

bool convertIterableToVariantMap ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2167 of file qmetatype.cpp.

◆ convertIterableToVariantPair()

bool convertIterableToVariantPair ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2196 of file qmetatype.cpp.

References QtMetaTypePrivate::QPairVariantInterfaceImpl::first(), and QtMetaTypePrivate::QPairVariantInterfaceImpl::second().

Here is the call graph for this function:

◆ convertMetaObject()

bool convertMetaObject ( QMetaType fromType,
const void * from,
QMetaType toType,
void * to )
static

Definition at line 2410 of file qmetatype.cpp.

◆ convertToAssociativeIterable()

bool convertToAssociativeIterable ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2325 of file qmetatype.cpp.

◆ convertToEnum()

bool convertToEnum ( QMetaType fromType,
const void * from,
QMetaType toType,
void * to )
static

Definition at line 2103 of file qmetatype.cpp.

◆ convertToSequentialIterable()

bool convertToSequentialIterable ( QMetaType fromType,
const void * from,
void * to )
static

Definition at line 2226 of file qmetatype.cpp.

◆ createStaticTypeToIdMap()

constexpr auto createStaticTypeToIdMap ( )
staticconstexpr

Definition at line 984 of file qmetatype.cpp.

◆ findMetaTypeByName()

const QtPrivate::QMetaTypeInterface * findMetaTypeByName ( QByteArrayView name)
static

Definition at line 2911 of file qmetatype.cpp.

◆ interfaceForStaticType()

const QtPrivate::QMetaTypeInterface * interfaceForStaticType ( int typeId)
static

Definition at line 2874 of file qmetatype.cpp.

◆ interfaceForType()

const QtPrivate::QMetaTypeInterface * interfaceForType ( int typeId)
static

Definition at line 3343 of file qmetatype.cpp.

◆ interfaceForTypeNoWarning()

const QtPrivate::QMetaTypeInterface * interfaceForTypeNoWarning ( int typeId)
static

Definition at line 2886 of file qmetatype.cpp.

◆ isInterfaceFor() [1/2]

template<typename T>
bool QtMetaTypePrivate::isInterfaceFor ( const QtPrivate::QMetaTypeInterface * iface)
inline

Definition at line 126 of file qmetatype_p.h.

◆ isInterfaceFor() [2/2]

template<typename T>
bool QtMetaTypePrivate::isInterfaceFor ( const QtPrivate::QMetaTypeInterface * iface)
inline

Definition at line 126 of file qmetatype_p.h.

◆ metaEnumFromType()

QMetaEnum metaEnumFromType ( QMetaType t)
static

returns a QMetaEnum for a given meta tape type id if possible

Definition at line 2006 of file qmetatype.cpp.

◆ operator<<()

QDebug operator<< ( QDebug d,
QMetaType m )

Definition at line 1942 of file qmetatype.cpp.

◆ Q_STATIC_LOGGING_CATEGORY()

QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY ( lcMetatypeDeprecated ,
"qt.core.qmetatype.deprecated"  )

◆ qIntegerConversionFromFPHelper()

template<typename From, typename To>
bool qIntegerConversionFromFPHelper ( From from,
To * to )
static

Definition at line 1025 of file qmetatype.cpp.

◆ qMetaTypeStaticType()

int qMetaTypeStaticType ( QByteArrayView name)
inlinestatic

Definition at line 2839 of file qmetatype.cpp.

◆ qMetaTypeTypeInternal()

int qMetaTypeTypeInternal ( QByteArrayView name)

Similar to QMetaType::type(); the only difference is that this function doesn't attempt to normalize the type name (i.e., the lookup will fail for type names in non-normalized form).

Used by only QMetaObject, which means the type is always already normalized.

Definition at line 2947 of file qmetatype.cpp.

◆ threeWayCompare()

QPartialOrdering threeWayCompare ( const void * ptr1,
const void * ptr2 )
static

Definition at line 764 of file qmetatype.cpp.

◆ tryConvertBuiltinTypes()

bool tryConvertBuiltinTypes ( const void * from,
int fromTypeId,
void * to,
int toTypeId )
static

Definition at line 1758 of file qmetatype.cpp.

◆ viewAsAssociativeIterable()

bool viewAsAssociativeIterable ( QMetaType fromType,
void * from,
void * to )
static

Definition at line 2385 of file qmetatype.cpp.

◆ viewAsSequentialIterable()

bool viewAsSequentialIterable ( QMetaType fromType,
void * from,
void * to )
static

Definition at line 2290 of file qmetatype.cpp.

Variable Documentation

◆ qMetaTypeGuiHelper

Q_CONSTINIT Q_CORE_EXPORT QMetaTypeModuleHelper qMetaTypeGuiHelper = {}

Definition at line 1754 of file qmetatype.cpp.

◆ qMetaTypeWidgetsHelper

Q_CONSTINIT Q_CORE_EXPORT QMetaTypeModuleHelper qMetaTypeWidgetsHelper = {}

Definition at line 1755 of file qmetatype.cpp.

◆ types

auto types = createStaticTypeToIdMap()
staticconstexpr

Definition at line 1022 of file qmetatype.cpp.