49 #if QT_CONFIG(easingcurve)
53 #if QT_CONFIG(regularexpression)
61 #if QT_CONFIG(itemmodel)
64 #ifndef QT_BOOTSTRAPPED
74 #include "private/qvariant_p.h"
75 #include "private/qlocale_p.h"
79 #ifndef QT_NO_GEOM_VARIANT
99 switch (
d->typeId()) {
101 return d->get<
int>();
102 case QMetaType::LongLong:
106 case QMetaType::SChar:
116 #ifndef QT_BOOTSTRAPPED
117 case QMetaType::QJsonValue:
129 switch (
d->typeId()) {
131 return d->get<
unsigned int>();
132 case QMetaType::ULongLong:
134 case QMetaType::UChar:
135 return d->get<
unsigned char>();
137 return d->get<
unsigned short>();
139 return d->get<
unsigned long>();
149 switch (
uint(
d->typeId())) {
155 if (allowStringToBool) {
167 case QMetaType::QChar:
168 return d->get<
QChar>().unicode();
173 #ifndef QT_BOOTSTRAPPED
177 return qMetaTypeNumber(
d);
178 case QMetaType::QJsonValue:
186 case QMetaType::SChar:
190 case QMetaType::LongLong:
191 return qMetaTypeNumber(
d);
192 case QMetaType::ULongLong:
194 case QMetaType::UChar:
204 switch (typeInfo.
sizeOf()) {
206 return d->get<
signed char>();
208 return d->get<
short>();
210 return d->get<
int>();
223 switch (
uint(
d->typeId())) {
227 return qreal(
d->get<
double>());
229 return qreal(
d->get<
float>());
230 case QMetaType::ULongLong:
232 case QMetaType::UChar:
235 return qreal(qMetaTypeUNumber(
d));
236 #ifndef QT_BOOTSTRAPPED
239 case QMetaType::QJsonValue:
244 return qreal(qConvertToNumber(
d,
ok));
252 if (!(iface && iface->
size)) {
262 iface->
copyCtr(iface, &
d->data, copy);
265 d->is_shared =
false;
269 iface->
copyCtr(iface,
d->data.shared->data(), copy);
276 d->is_null = !copy ||
QMetaType(iface) == QMetaType::fromType<std::nullptr_t>();
286 iface->
dtor(iface, &
d->data);
289 iface->
dtor(iface,
d->data.shared->data());
498 customConstruct(&
d, copy);
529 d.
data.shared->ref.ref();
533 auto other =
p.constData();
821 customConstruct(&
d, copy);
848 { v_construct<QByteArray>(&
d,
val); }
851 { v_construct<QBitArray>(&
d,
val); }
854 { v_construct<QString>(&
d,
val); }
857 { v_construct<QChar>(&
d,
val); }
860 { v_construct<QString>(&
d,
val); }
863 { v_construct<QStringList>(&
d,
val); }
867 { v_construct<QDate>(&
d,
val); }
870 { v_construct<QTime>(&
d,
val); }
873 { v_construct<QDateTime>(&
d,
val); }
874 #if QT_CONFIG(easingcurve)
877 { v_construct<QEasingCurve>(&
d,
val); }
881 { v_construct<QVariantList>(&
d,
list); }
884 { v_construct<QVariantMap>(&
d,
map); }
887 { v_construct<QVariantHash>(&
d,
hash); }
888 #ifndef QT_NO_GEOM_VARIANT
891 { v_construct<QPoint>(&
d, pt); }
894 { v_construct<QPointF>(&
d, pt); }
897 { v_construct<QRectF>(&
d,
r); }
900 { v_construct<QLineF>(&
d,
l); }
903 { v_construct<QLine>(&
d,
l); }
906 { v_construct<QRect>(&
d,
r); }
909 { v_construct<QSize>(&
d,
s); }
912 { v_construct<QSizeF>(&
d,
s); }
914 #ifndef QT_BOOTSTRAPPED
917 { v_construct<QUrl>(&
d,
u); }
921 { v_construct<QLocale>(&
d,
l); }
922 #if QT_CONFIG(regularexpression)
925 { v_construct<QRegularExpression>(&
d, re); }
929 { v_construct<QUuid>(&
d, uuid); }
930 #ifndef QT_BOOTSTRAPPED
933 { v_construct<QJsonValue>(&
d, jsonValue); }
936 { v_construct<QJsonObject>(&
d, jsonObject); }
939 { v_construct<QJsonArray>(&
d, jsonArray); }
942 { v_construct<QJsonDocument>(&
d, jsonDocument); }
944 #if QT_CONFIG(itemmodel)
947 { v_construct<QModelIndex>(&
d, modelIndex); }
950 { v_construct<QPersistentModelIndex>(&
d, modelIndex); }
1056 if (!
d.
data.shared->ref.deref())
1110 #ifndef QT_NO_DATASTREAM
1125 QMetaType::QPalette,
1135 QMetaType::QPolygon,
1139 QMetaType::QSizePolicy,
1142 QMetaType::QDateTime,
1145 #if QT_CONFIG(shortcut)
1146 QMetaType::QKeySequence,
1151 QMetaType::LongLong,
1152 QMetaType::ULongLong,
1153 #if QT_CONFIG(easingcurve)
1154 QMetaType::QEasingCurve
1195 }
else if (
typeId == 75 ) {
1210 typeId = QMetaType::QSizePolicy;
1216 qint8 is_null =
false;
1225 qWarning(
"QVariant::load: unknown user type with name %s.",
name.constData());
1259 bool saveAsUserType =
false;
1262 saveAsUserType =
true;
1274 saveAsUserType =
true;
1279 saveAsUserType =
true;
1281 }
else if (
typeId == QMetaType::QSizePolicy) {
1288 if (mapIdFromQt3ToCurrent[
i] ==
typeId) {
1300 saveAsUserType =
true;
1313 saveAsUserType =
true;
1317 if (saveAsUserType) {
1336 qWarning(
"QVariant::save: unable to save type '%s' (type id: %d).\n",
1338 Q_ASSERT_X(
false,
"QVariant::save",
"Invalid type to save");
1398 return qvariant_cast<QStringList>(*
this);
1418 return qvariant_cast<QString>(*
this);
1429 return qvariant_cast<QVariantMap>(*
this);
1440 return qvariant_cast<QVariantHash>(*
this);
1457 return qvariant_cast<QDate>(*
this);
1474 return qvariant_cast<QTime>(*
this);
1491 return qvariant_cast<QDateTime>(*
this);
1503 #if QT_CONFIG(easingcurve)
1506 return qvariant_cast<QEasingCurve>(*
this);
1521 return qvariant_cast<QByteArray>(*
this);
1524 #ifndef QT_NO_GEOM_VARIANT
1536 return qvariant_cast<QPoint>(*
this);
1549 return qvariant_cast<QRect>(*
this);
1562 return qvariant_cast<QSize>(*
this);
1575 return qvariant_cast<QSizeF>(*
this);
1589 return qvariant_cast<QRectF>(*
this);
1602 return qvariant_cast<QLineF>(*
this);
1615 return qvariant_cast<QLine>(*
this);
1629 return qvariant_cast<QPointF>(*
this);
1634 #ifndef QT_BOOTSTRAPPED
1645 return qvariant_cast<QUrl>(*
this);
1659 return qvariant_cast<QLocale>(*
this);
1662 #if QT_CONFIG(regularexpression)
1674 return qvariant_cast<QRegularExpression>(*
this);
1678 #if QT_CONFIG(itemmodel)
1689 return qvariant_cast<QModelIndex>(*
this);
1702 return qvariant_cast<QPersistentModelIndex>(*
this);
1717 return qvariant_cast<QUuid>(*
this);
1720 #ifndef QT_BOOTSTRAPPED
1731 return qvariant_cast<QJsonValue>(*
this);
1744 return qvariant_cast<QJsonObject>(*
this);
1757 return qvariant_cast<QJsonArray>(*
this);
1770 return qvariant_cast<QJsonDocument>(*
this);
1785 return qvariant_cast<QChar>(*
this);
1796 return qvariant_cast<QBitArray>(*
this);
1799 template <
typename T>
1835 return qNumVariantToHelper<int>(
d,
ok,
d.
get<
int>());
1857 return qNumVariantToHelper<uint>(
d,
ok,
d.
get<
unsigned int>());
1908 auto boolType = QMetaType::fromType<bool>();
1909 if (
d.
type() == boolType)
1910 return d.
get<
bool>();
1931 return qNumVariantToHelper<double>(
d,
ok,
d.
get<
double>());
1950 return qNumVariantToHelper<float>(
d,
ok,
d.
get<
float>());
1969 return qNumVariantToHelper<qreal>(
d,
ok,
d.
get<
qreal>());
1981 return qvariant_cast<QVariantList>(*
this);
2051 if (
d.
type() == targetType)
2057 create(targetType,
nullptr);
2136 static bool qIsNumericType(
uint tp)
2154 return tp < (CHAR_BIT *
sizeof numericTypeBits) ? numericTypeBits & (
Q_UINT64_C(1) << tp) :
false;
2157 static bool qIsFloatingPoint(
uint tp)
2162 static int normalizeLowerRanks(
uint tp)
2174 static int normalizeLong(
uint tp)
2176 const uint IntType =
sizeof(long) ==
sizeof(
int) ?
QMetaType::Int : QMetaType::LongLong;
2206 if (qIsFloatingPoint(
t1) || qIsFloatingPoint(
t2))
2211 t1 = normalizeLowerRanks(
t1);
2212 t2 = normalizeLowerRanks(
t2);
2215 t1 = normalizeLong(
t1);
2216 t2 = normalizeLong(
t2);
2223 if (
t1 == QMetaType::ULongLong ||
t2 == QMetaType::ULongLong)
2224 return QMetaType::ULongLong;
2225 if (
t1 == QMetaType::LongLong ||
t2 == QMetaType::LongLong)
2226 return QMetaType::LongLong;
2245 return bool(l1) == bool(l2);
2247 return int(l1) == int(l2);
2250 if (promotedType == QMetaType::LongLong)
2252 if (promotedType == QMetaType::ULongLong)
2260 template<
typename Numeric>
2261 int spaceShip(Numeric lhs, Numeric
rhs)
2264 if constexpr (std::is_same_v<Numeric, QObject *>)
2270 else if (lhs ==
rhs)
2283 return std::nullopt;
2287 return std::nullopt;
2290 return spaceShip<bool>(l1, l2);
2292 return spaceShip<int>(l1, l2);
2294 return spaceShip<uint>(l1, l2);
2295 if (promotedType == QMetaType::LongLong)
2296 return spaceShip<qlonglong>(l1, l2);
2297 if (promotedType == QMetaType::ULongLong)
2298 return spaceShip<qulonglong>(l1, l2);
2306 uint promotedType = numericTypePromotion(
d1->typeId(),
d2->typeId());
2308 return integralCompare(promotedType,
d1,
d2);
2313 return std::nullopt;
2316 return std::nullopt;
2320 if (std::isnan(r1) || std::isnan(r2))
2321 return std::nullopt;
2322 return spaceShip<qreal>(r1, r2);
2327 uint promotedType = numericTypePromotion(
d1->typeId(),
d2->typeId());
2329 return integralEquals(promotedType,
d1,
d2);
2345 #ifndef QT_BOOTSTRAPPED
2352 return f &&
t && (
f->inherits(
t) ||
t->inherits(
f));
2374 auto metatype =
d.
type();
2376 if (metatype !=
v.metaType()) {
2378 if (qIsNumericType(metatype.id()) && qIsNumericType(
v.d.typeId()))
2379 return numericEquals(&
d, &
v.d);
2380 #ifndef QT_BOOTSTRAPPED
2382 if (canConvertMetaObject(metatype,
v.metaType()))
2383 return pointerEquals(&
d, &
v.d);
2389 if (!metatype.isValid())
2392 return metatype.equals(
d.
storage(),
v.d.storage());
2432 if (
t !=
rhs.d.type()) {
2434 if (qIsNumericType(lhs.
d.
typeId()) && qIsNumericType(
rhs.d.typeId()))
2435 return convertOptionalToPartialOrdering(numericCompare(&lhs.
d, &
rhs.d));
2436 #ifndef QT_BOOTSTRAPPED
2437 if (canConvertMetaObject(lhs.
metaType(),
rhs.metaType()))
2438 return convertOptionalToPartialOrdering(pointerCompare(&lhs.
d, &
rhs.d));
2488 return d.
get<
void *>() ==
nullptr;
2492 #ifndef QT_NO_DEBUG_STREAM
2510 #if QT_DEPRECATED_SINCE(6, 0)
2766 if (
type == QMetaType::fromType<QVariant>())
2770 return value.constData();
2790 return converted.constData();
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
The QBitArray class provides an array of bits.
The QByteArray class provides an array of bytes.
The QCborValue class encapsulates a value in CBOR.
The QChar class provides a 16-bit Unicode character.
The QDataStream class provides serialization of binary data to a QIODevice.
operator>>(QDataStream &ds, qfloat16 &f)
operator<<(QDataStream &ds, qfloat16 f)
The QDate class provides date functions.
The QDateTime class provides date and time functions.
The QDebug class provides an output stream for debugging information.
Convenience class for custom QDebug operators.
The QEasingCurve class provides easing curves for controlling animation.
The QJsonArray class encapsulates a JSON array.
The QJsonDocument class provides a way to read and write JSON documents.
The QJsonObject class encapsulates a JSON object.
The QJsonValue class encapsulates a value in JSON.
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QLineF class provides a two-dimensional vector using floating point precision.
The QLine class provides a two-dimensional vector using integer precision.
The QModelIndex class is used to locate data in a data model.
The QObject class is the base class of all Qt objects.
static const QPartialOrdering Less
static const QPartialOrdering Greater
static const QPartialOrdering Equivalent
static const QPartialOrdering Unordered
The QPersistentModelIndex class is used to locate data in a data model.
The QPointF class defines a point in the plane using floating point precision.
The QPoint class defines a point in the plane using integer precision.
The QRectF class defines a finite rectangle in the plane using floating point precision.
The QRect class defines a rectangle in the plane using integer precision.
The QRegularExpression class provides pattern matching using regular expressions.
The QSizeF class defines the size of a two-dimensional object using floating point precision.
The QSize class defines the size of a two-dimensional object using integer point precision.
The QString class provides a Unicode character string.
The QStringList class provides a list of strings.
The QTime class provides clock time functions.
The QUrl class provides a convenient interface for working with URLs.
The QUuid class stores a Universally Unique Identifier (UUID).
QVariantConstPointer(QVariant variant)
const QVariant * operator->() const
QVariant operator*() const
The QVariant class acts like a union for the most common Qt data types.
bool convert(QMetaType type)
static QPartialOrdering compare(const QVariant &lhs, const QVariant &rhs)
qreal toReal(bool *ok=nullptr) const
QDateTime toDateTime() const
QJsonValue toJsonValue() const
double toDouble(bool *ok=nullptr) const
QList< QVariant > toList() const
QMap< QString, QVariant > toMap() const
qlonglong toLongLong(bool *ok=nullptr) const
int toInt(bool *ok=nullptr) const
void save(QDataStream &ds) const
float toFloat(bool *ok=nullptr) const
uint toUInt(bool *ok=nullptr) const
void load(QDataStream &ds)
QBitArray toBitArray() const
QJsonArray toJsonArray() const
QHash< QString, QVariant > toHash() const
const char * typeName() const
QJsonDocument toJsonDocument() const
QVariant & operator=(const QVariant &other)
QJsonObject toJsonObject() const
bool canConvert(QMetaType targetType) const
QByteArray toByteArray() const
void create(int type, const void *copy)
QMetaType metaType() const
qulonglong toULongLong(bool *ok=nullptr) const
const void * constData() const
QStringList toStringList() const
bool equals(const QVariant &other) const
const void * coerce(const QVariant &value, const QMetaType &type)
const void * convert(const QVariant &value, const QMetaType &type)
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION ParsedNumber< double > toDouble(QByteArrayView a) noexcept
int PRIV() strcmp(PCRE2_SPTR str1, PCRE2_SPTR str2)
#define QT_WARNING_DISABLE_DEPRECATED
QMap< QString, QVariant > QVariantMap
QList< QString > QStringList
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
qint64 qRound64(qfloat16 d) noexcept
QT_END_INCLUDE_NAMESPACE typedef double qreal
QT_BEGIN_NAMESPACE typedef signed char qint8
QList< QVariant > QVariantList
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
[4]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define Q_ASSERT_X(cond, x, msg)
QT_BEGIN_NAMESPACE typedef char Char
constexpr int Qt6ToQt5GuiTypeDelta
constexpr int Qt5QQuaternion
constexpr int Qt5KeySequence
constexpr int Qt5LastCoreType
constexpr int Qt5FirstGuiType
constexpr int Qt5LastGuiType
constexpr int Qt5SizePolicy
constexpr int Qt5UserType
T qNumVariantToHelper(const QVariant::Private &d, bool *ok, const T &val)
v canConvert< QString >()
QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9))
[0]
const void * storage() const
QtPrivate::QMetaTypeInterface * typeInterface() const
static constexpr bool canUseInternalSpace(QtPrivate::QMetaTypeInterface *type)
uchar data[MaxInternalSize]
static PrivateShared * create(const QtPrivate::QMetaTypeInterface *type)
static void free(PrivateShared *p)
#define smaller(tree, n, m, depth)