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

(3ee98d6adfec037b0220fbfbb1cd80614f9e2135)

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

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<NormalizeTypeMode 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; \
result = source.toBool(); \
} 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; \
result = source.toBool(); \
} 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
\inmodule QtCore\reentrant
Definition qjsonvalue.h:25
#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.
double toDouble(bool *ok=nullptr) const
Returns the string converted to a double value.
Definition qstring.cpp:7953
#define QMETATYPE_CONVERTER_ASSIGN(To, From)
Definition qmetatype_p.h:32
char Char

◆ INTEGRAL_CONVERTER

#define INTEGRAL_CONVERTER ( To)

◆ NS

#define NS ( x)
Value:
GLint GLint GLint GLint GLint x
[0]
QT_END_NAMESPACE typedef QT_PREPEND_NAMESPACE(quintptr) WId

Definition at line 64 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

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

Definition at line 943 of file qmetatype.cpp.

◆ QT_ADD_STATIC_METATYPE_ALIASES_ITER

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

Definition at line 946 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 3289 of file qmetatype.cpp.

Typedef Documentation

◆ QMetaTypeConverterRegistry

◆ QMetaTypeMutableViewRegistry

Function Documentation

◆ canConvertMetaObject()

static bool canConvertMetaObject ( QMetaType fromType,
QMetaType toType )
static

Definition at line 2254 of file qmetatype.cpp.

◆ canConvertToAssociativeIterable()

static bool canConvertToAssociativeIterable ( QMetaType fromType)
static

Definition at line 2267 of file qmetatype.cpp.

◆ canConvertToSequentialIterable()

static bool canConvertToSequentialIterable ( QMetaType fromType)
static

Definition at line 2166 of file qmetatype.cpp.

◆ canImplicitlyViewAsAssociativeIterable()

static bool canImplicitlyViewAsAssociativeIterable ( QMetaType fromType)
static

Definition at line 2278 of file qmetatype.cpp.

◆ canImplicitlyViewAsSequentialIterable()

static bool canImplicitlyViewAsSequentialIterable ( QMetaType fromType)
static

Definition at line 2180 of file qmetatype.cpp.

◆ convertFromEnum()

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

Definition at line 1931 of file qmetatype.cpp.

◆ convertIterableToVariantHash()

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

Definition at line 2086 of file qmetatype.cpp.

◆ convertIterableToVariantList()

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

Definition at line 2057 of file qmetatype.cpp.

◆ convertIterableToVariantMap()

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

Definition at line 2072 of file qmetatype.cpp.

◆ convertIterableToVariantPair()

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

Definition at line 2101 of file qmetatype.cpp.

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

+ Here is the call graph for this function:

◆ convertMetaObject()

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

Definition at line 2315 of file qmetatype.cpp.

◆ convertToAssociativeIterable()

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

Definition at line 2230 of file qmetatype.cpp.

◆ convertToEnum()

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

Definition at line 2007 of file qmetatype.cpp.

◆ convertToSequentialIterable()

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

Definition at line 2131 of file qmetatype.cpp.

◆ interfaceForType()

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

Definition at line 3253 of file qmetatype.cpp.

◆ interfaceForTypeNoWarning()

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

Definition at line 2802 of file qmetatype.cpp.

◆ metaEnumFromType()

static QMetaEnum metaEnumFromType ( QMetaType t)
static

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

Definition at line 1911 of file qmetatype.cpp.

◆ operator<<()

QDebug operator<< ( QDebug d,
QMetaType m )

Definition at line 1847 of file qmetatype.cpp.

◆ qMetaTypeCustomType_unlocked()

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

Definition at line 2766 of file qmetatype.cpp.

◆ qMetaTypeStaticType()

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

Definition at line 2751 of file qmetatype.cpp.

◆ qMetaTypeTypeImpl()

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

Definition at line 2833 of file qmetatype.cpp.

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

◆ qModuleHelperForType()

static const QMetaTypeModuleHelper * qModuleHelperForType ( int type)
static

Definition at line 1661 of file qmetatype.cpp.

◆ threeWayCompare()

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

Definition at line 718 of file qmetatype.cpp.

◆ viewAsAssociativeIterable()

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

Definition at line 2290 of file qmetatype.cpp.

◆ viewAsSequentialIterable()

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

Definition at line 2195 of file qmetatype.cpp.

Variable Documentation

◆ metatypeHelper

metatypeHelper = {}
static

◆ qMetaTypeGuiHelper

Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper* qMetaTypeGuiHelper = nullptr

Definition at line 1658 of file qmetatype.cpp.

◆ qMetaTypeWidgetsHelper

Q_CONSTINIT Q_CORE_EXPORT const QMetaTypeModuleHelper* qMetaTypeWidgetsHelper = nullptr

Definition at line 1659 of file qmetatype.cpp.

◆ type

int type

Definition at line 951 of file qmetatype.cpp.

◆ typeName

static const char * typeName

Definition at line 951 of file qmetatype.cpp.

◆ typeNameLength

int typeNameLength

Definition at line 951 of file qmetatype.cpp.

◆ [struct]

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