Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmetatype.cpp File Reference

(d31054c31456bc840061089e37e956ad815215c6)

#include "qmetatype.h"
#include "qmetatype_p.h"
#include "qobjectdefs.h"
#include "qdatetime.h"
#include "qbytearray.h"
#include "qreadwritelock.h"
#include "qhash.h"
#include "qmap.h"
#include "qstring.h"
#include "qstringlist.h"
#include "qlist.h"
#include "qlocale.h"
#include "qdebug.h"
#include "quuid.h"
#include "qdatastream.h"
#include "qbitarray.h"
#include "qurl.h"
#include "qvariant.h"
#include "qjsonvalue.h"
#include "qjsonobject.h"
#include "qjsonarray.h"
#include "qjsondocument.h"
#include "qcborvalue.h"
#include "qcborarray.h"
#include "qcbormap.h"
#include "qbytearraylist.h"
#include "qmetaobject.h"
#include "qsequentialiterable.h"
#include "qassociativeiterable.h"
#include "qobject.h"
#include "qsize.h"
#include "qpoint.h"
#include "qrect.h"
#include "qline.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
 \macro QT_NO_KEYWORDS >
 

Macros

#define NS(x)   QT_PREPEND_NAMESPACE(x)
 
#define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName)    { #RealName, sizeof(#RealName) - 1, MetaTypeId },
 
#define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, MetaTypeId, AliasingName, RealNameStr)    { RealNameStr, sizeof(RealNameStr) - 1, QMetaType::MetaTypeName },
 
#define QMETATYPE_CONVERTER_ASSIGN_DOUBLE(To, From)    QMETATYPE_CONVERTER(To, From, result = double(source); return true;)
 
#define QMETATYPE_CONVERTER_ASSIGN_NUMBER(To, From)    QMETATYPE_CONVERTER(To, From, result = To::number(source); return true;)
 
#define CONVERT_CBOR_AND_JSON(To)
 
#define INTEGRAL_CONVERTER(To)
 
#define FLOAT_CONVERTER(To)
 
#define QMETATYPE_CONVERTER_ASSIGN_QCHAR(From)    QMETATYPE_CONVERTER(QChar, From, result = QChar::fromUcs2(source); return true;)
 
#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

static QPartialOrdering threeWayCompare (const void *ptr1, const void *ptr2)
 
static const QMetaTypeModuleHelperqModuleHelperForType (int type)
 
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 (const char *typeName, int length)
 
static int qMetaTypeCustomType_unlocked (const char *typeName, int length)
 
static const QtPrivate::QMetaTypeInterfaceinterfaceForTypeNoWarning (int typeId)
 
template<bool tryNormalizedType>
static int qMetaTypeTypeImpl (const char *typeName, int length)
 
Q_CORE_EXPORT int qMetaTypeTypeInternal (const char *typeName)
 
static const QtPrivate::QMetaTypeInterfaceinterfaceForType (int typeId)
 

Variables

struct { 
 
   const char *   typeName 
 
   int   typeNameLength 
 
   int   type 
 
types [] 
 
 metatypeHelper = {}
 
Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelperqMetaTypeGuiHelper = nullptr
 
Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelperqMetaTypeWidgetsHelper = nullptr
 

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; \
} else { \
if (!source.isInteger() && !source.isDouble()) \
return false; \
if constexpr(std::is_integral_v<To>) \
result = source.toInteger(); \
else \
result = source.toDouble(); \
} \
return true; \
); \
QMETATYPE_CONVERTER(To, QJsonValue, \
if constexpr(std::is_same_v<To, Bool>) { \
if (!source.isBool()) \
return false; \
} else { \
if (!source.isDouble()) \
return false; \
if constexpr(std::is_integral_v<To>) \
result = source.toInteger(); \
else \
result = source.toDouble(); \
} \
return true; \
)
\inmodule QtCore\reentrant
Definition qcborvalue.h:47
bool toBool(bool defaultValue=false) const
Returns the boolean value stored in this QCborValue, if it is of a boolean type.
Definition qcborvalue.h:189
\inmodule QtCore\reentrant
Definition qjsonvalue.h:25
bool toBool(bool defaultValue=false) const
Converts the value to a bool and returns it.
#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, Float); \
QMETATYPE_CONVERTER_ASSIGN(To, Double); \
QMETATYPE_CONVERTER(To, QString, \
bool ok = false; \
return ok; \
); \
QMETATYPE_CONVERTER(To, QByteArray, \
bool ok = false; \
return ok; \
); \
CONVERT_CBOR_AND_JSON(To)
\inmodule QtCore
Definition qbytearray.h:57
double toDouble(bool *ok=nullptr) const
Returns the byte array converted to a double value.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
double toDouble(bool *ok=nullptr) const
Returns the string converted to a double value.
Definition qstring.cpp:7904
#define QMETATYPE_CONVERTER_ASSIGN(To, From)
Definition qmetatype_p.h:32
char Char

◆ INTEGRAL_CONVERTER

#define INTEGRAL_CONVERTER ( To)

◆ NS

#define NS ( x)    QT_PREPEND_NAMESPACE(x)

Definition at line 64 of file qmetatype.cpp.

Referenced by qMetaTypeTypeImpl().

◆ QMETATYPE_CONVERTER_ASSIGN_DOUBLE

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

◆ QMETATYPE_CONVERTER_ASSIGN_NUMBER

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

◆ QMETATYPE_CONVERTER_ASSIGN_QCHAR

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

◆ QT_ADD_STATIC_METATYPE

#define QT_ADD_STATIC_METATYPE ( MetaTypeName,
MetaTypeId,
RealName )    { #RealName, sizeof(#RealName) - 1, MetaTypeId },

Definition at line 951 of file qmetatype.cpp.

◆ QT_ADD_STATIC_METATYPE_ALIASES_ITER

#define QT_ADD_STATIC_METATYPE_ALIASES_ITER ( MetaTypeName,
MetaTypeId,
AliasingName,
RealNameStr )    { RealNameStr, sizeof(RealNameStr) - 1, QMetaType::MetaTypeName },

Definition at line 954 of file qmetatype.cpp.

◆ 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 3286 of file qmetatype.cpp.

Typedef Documentation

◆ QMetaTypeConverterRegistry

◆ QMetaTypeMutableViewRegistry

Function Documentation

◆ canConvertMetaObject()

static bool canConvertMetaObject ( QMetaType fromType,
QMetaType toType )
static

Definition at line 2255 of file qmetatype.cpp.

◆ canConvertToAssociativeIterable()

static bool canConvertToAssociativeIterable ( QMetaType fromType)
static

Definition at line 2268 of file qmetatype.cpp.

◆ canConvertToSequentialIterable()

static bool canConvertToSequentialIterable ( QMetaType fromType)
static

Definition at line 2167 of file qmetatype.cpp.

◆ canImplicitlyViewAsAssociativeIterable()

static bool canImplicitlyViewAsAssociativeIterable ( QMetaType fromType)
static

Definition at line 2279 of file qmetatype.cpp.

◆ canImplicitlyViewAsSequentialIterable()

static bool canImplicitlyViewAsSequentialIterable ( QMetaType fromType)
static

Definition at line 2181 of file qmetatype.cpp.

◆ convertFromEnum()

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

Definition at line 1935 of file qmetatype.cpp.

References QMetaType::convert(), QMetaType::flags(), QString::fromUtf8(), QMetaType::IsUnsignedEnumeration, keys, metaEnumFromType(), and QMetaType::sizeOf().

+ Here is the call graph for this function:

◆ convertIterableToVariantHash()

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

Definition at line 2087 of file qmetatype.cpp.

◆ convertIterableToVariantList()

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

Definition at line 2058 of file qmetatype.cpp.

References QList< T >::begin(), QList< T >::clear(), QMetaType::convert(), QList< T >::end(), it, list, QList< T >::reserve(), and QList< T >::size().

+ Here is the call graph for this function:

◆ convertIterableToVariantMap()

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

Definition at line 2073 of file qmetatype.cpp.

◆ convertIterableToVariantPair()

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

Definition at line 2102 of file qmetatype.cpp.

◆ convertMetaObject()

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

Definition at line 2316 of file qmetatype.cpp.

◆ convertToAssociativeIterable()

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

Definition at line 2231 of file qmetatype.cpp.

◆ convertToEnum()

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

Definition at line 2011 of file qmetatype.cpp.

◆ convertToSequentialIterable()

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

Definition at line 2132 of file qmetatype.cpp.

◆ interfaceForType()

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

Definition at line 3250 of file qmetatype.cpp.

◆ interfaceForTypeNoWarning()

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

Definition at line 2803 of file qmetatype.cpp.

References qModuleHelperForType(), and QMetaType::User.

+ Here is the call graph for this function:

◆ metaEnumFromType()

static QMetaEnum metaEnumFromType ( QMetaType t)
static

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

Definition at line 1915 of file qmetatype.cpp.

Referenced by convertFromEnum().

+ Here is the caller graph for this function:

◆ operator<<()

QDebug operator<< ( QDebug d,
QMetaType m )

Definition at line 1851 of file qmetatype.cpp.

◆ qMetaTypeCustomType_unlocked()

static int qMetaTypeCustomType_unlocked ( const char * typeName,
int length )
static

Definition at line 2767 of file qmetatype.cpp.

References QByteArray::fromRawData(), Q_ASSERT, typeName, and QMetaType::UnknownType.

Referenced by qMetaTypeTypeImpl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qMetaTypeStaticType()

static int qMetaTypeStaticType ( const char * typeName,
int length )
inlinestatic

Definition at line 2752 of file qmetatype.cpp.

References i, typeName, and typeNameLength.

Referenced by qMetaTypeTypeImpl().

+ Here is the caller graph for this function:

◆ qMetaTypeTypeImpl()

template<bool tryNormalizedType>
static int qMetaTypeTypeImpl ( const char * typeName,
int length )
inlinestatic

Definition at line 2828 of file qmetatype.cpp.

References lock, QMetaObject::normalizedType(), NS, qMetaTypeCustomType_unlocked(), qMetaTypeStaticType(), type, typeName, and QMetaType::UnknownType.

+ Here is the call graph for this function:

◆ qMetaTypeTypeInternal()

Q_CORE_EXPORT int qMetaTypeTypeInternal ( const char * typeName)

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).

Definition at line 2868 of file qmetatype.cpp.

Referenced by isBuiltinType(), and nameToBuiltinType().

+ Here is the caller graph for this function:

◆ qModuleHelperForType()

static const QMetaTypeModuleHelper * qModuleHelperForType ( int type)
static

Definition at line 1665 of file qmetatype.cpp.

References QMetaType::FirstGuiType, QMetaType::FirstWidgetsType, QMetaType::LastCoreType, QMetaType::LastGuiType, QMetaType::LastWidgetsType, metatypeHelper, qMetaTypeGuiHelper, and qMetaTypeWidgetsHelper.

Referenced by interfaceForTypeNoWarning().

+ Here is the caller graph for this function:

◆ threeWayCompare()

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

Definition at line 726 of file qmetatype.cpp.

References QPartialOrdering::Equivalent, QPartialOrdering::Greater, and QPartialOrdering::Less.

Referenced by QMetaType::compare().

+ Here is the caller graph for this function:

◆ viewAsAssociativeIterable()

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

Definition at line 2291 of file qmetatype.cpp.

◆ viewAsSequentialIterable()

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

Definition at line 2196 of file qmetatype.cpp.

Variable Documentation

◆ metatypeHelper

metatypeHelper = {}
static

Referenced by qModuleHelperForType().

◆ qMetaTypeGuiHelper

Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper* qMetaTypeGuiHelper = nullptr

Definition at line 1662 of file qmetatype.cpp.

Referenced by qModuleHelperForType(), and qRegisterGuiVariant().

◆ qMetaTypeWidgetsHelper

Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper* qMetaTypeWidgetsHelper = nullptr

Definition at line 1663 of file qmetatype.cpp.

Referenced by qModuleHelperForType(), and qRegisterWidgetsVariant().

◆ type

int type

Definition at line 959 of file qmetatype.cpp.

Referenced by qMetaTypeTypeImpl().

◆ typeName

const char* typeName

Definition at line 959 of file qmetatype.cpp.

Referenced by QQmlDirParser::Component::Component(), CustomType::CustomType(), QQmlApplicationEngine::QQmlApplicationEngine(), QQmlComponent::QQmlComponent(), QQuickView::QQuickView(), addFunction(), QSSGQmlUtilities::addResource(), ForbiddenChildrenPropertyValidatorPass::addWarning(), QSSGQmlUtilities::applyEdit(), buildMetaObject(), QQmlJSLiteralBindingCheck::check(), PolishLoopDetector::check(), QQmlDirParser::checkNonRelative(), checkRegistration(), QQmlComponentPrivate::completeLoadFromModule(), QQmlJSTypeResolver::containedTypeName(), QtObject::createComponent(), QtObject::createComponent(), QQuickDesignerSupportItems::createPrimitive(), createTypeForUrl(), QQmlTypeData::done(), QQuickViewPrivate::execute(), QQmlSA::PassManagerPrivate::findPropertyUsePasses(), findScopeOfSpecialItems(), generateInterfaceXml(), QSQLiteDriverPrivate::getTableInfo(), QQmlJSValueTypeFromStringCheck::hasError(), QSQLiteResultPrivate::initColumns(), QTest::Internal::QCborValueFormatter::innerFormat(), QMetaMethod::invokeOnGadget(), QQmlJS::Dom::PropertyDefinition::isAlias(), QQmlJSLinter::lintModule(), QQmlApplicationEngine::loadFromModule(), QQuickView::loadFromModule(), QQmlComponent::loadFromModule(), QQmlPropertyCacheCreator< ObjectContainer >::metaTypeForParameter(), QSSGQmlUtilities::nodeTypeFromName(), Compare::operator()(), Compare::operator()(), Moc::parseDeclareMetatype(), QQmlComponentPrivate::prepareLoadFromModule(), QQmlMetaType::prettyTypeName(), QQmlJSImportVisitor::processPropertyBindingObjects(), qDBusParametersForMethod(), qFindInlineComponents(), qGetColumnType(), qMetaTypeCustomType_unlocked(), qMetaTypeStaticType(), qMetaTypeTypeImpl(), qmlRegisterSingletonInstance(), qmlRegisterSingletonType(), QMetaType::qRegisterMetaType(), QMetaTypeIdQObject< T *, QMetaType::PointerToQObject >::qt_metatype_id(), QMetaTypeIdQObject< T *, QMetaType::PointerToGadget >::qt_metatype_id(), QMetaTypeIdQObject< T, QMetaType::IsEnumeration >::qt_metatype_id(), queuedConnectionTypes(), registerComplexDBusType(), QQmlMetaType::registerCompositeSingletonType(), QQmlMetaType::registerCompositeType(), QQmlSA::PassManager::registerPropertyPass(), QQmlSA::PassManagerPrivate::registerPropertyPass(), QQmlMetaType::registerSingletonType(), QQmlSA::GenericPass::resolveAttached(), QQmlSA::GenericPass::resolveAttachedInFileScope(), QQmlSA::GenericPass::resolveBuiltinType(), QQmlJSScope::resolveEnums(), LoadHelper::resolveType(), QQmlSA::GenericPass::resolveTypeInFileScope(), QQmlTableModel::rowsChanged(), QQmlJSMetaPropertyBinding::setInterceptor(), QQmlJSMetaPropertyBinding::setObject(), QQmlJSMetaMethod::setReturnTypeName(), QQmlJSMetaPropertyBinding::setValueSource(), QQmlData::signalEmitted(), QQmlEngine::singletonInstance(), QQmlEngine::singletonInstance(), QQmlBinding::slowWrite(), QQmlBinding::slowWrite(), QQmlApplicationEnginePrivate::startLoad(), QmlIR::Parameter::stringToBuiltinType(), typeNameToXml(), typeNameToXml(), QQmlJS::Dom::PropertyDefinition::typePath(), QQmlJS::Dom::MethodInfo::typePath(), QSGRhiShaderEffectMaterial::updateTextureProviders(), QQmlJS::Dom::QQmlDomAstCreator::visit(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), QQmlJSImportVisitor::visit(), SvgDebugVisitor::visitStructureNodeStart(), QDBusMetaObjectGenerator::write(), QmlTypeRegistrar::write(), and QSSGQmlUtilities::writeNodeProperties().

◆ typeNameLength

int typeNameLength

Definition at line 959 of file qmetatype.cpp.

Referenced by qMetaTypeStaticType().

◆ [struct]

const struct { ... } types[]
Initial value:
= {
{nullptr, 0, QMetaType::UnknownType}
}
#define QT_ADD_STATIC_METATYPE(MetaTypeName, MetaTypeId, RealName)
double qreal
Definition qtypes.h:187