43 #include <QtCore/qatomic.h>
44 #include <QtCore/qbytearray.h>
45 #include <QtCore/qlist.h>
46 #include <QtCore/qmetatype.h>
47 #include <QtCore/qmap.h>
48 #include <QtCore/qhash.h>
49 #include <QtCore/qstring.h>
50 #include <QtCore/qstringlist.h>
51 #include <QtCore/qobject.h>
52 #ifndef QT_NO_DEBUG_STREAM
53 #include <QtCore/qdebug.h>
55 #ifndef QT_BOOTSTRAPPED
56 #include <QtCore/qbytearraylist.h>
59 #include <type_traits>
69 #if QT_CONFIG(easingcurve)
83 #if QT_CONFIG(regularexpression)
97 #if QT_DEPRECATED_SINCE(6, 0)
104 LongLong = QMetaType::LongLong,
105 ULongLong = QMetaType::ULongLong,
107 Char = QMetaType::QChar,
114 Date = QMetaType::QDate,
115 Time = QMetaType::QTime,
117 Url = QMetaType::QUrl,
118 Locale = QMetaType::QLocale,
119 Rect = QMetaType::QRect,
120 RectF = QMetaType::QRectF,
121 Size = QMetaType::QSize,
122 SizeF = QMetaType::QSizeF,
123 Line = QMetaType::QLine,
124 LineF = QMetaType::QLineF,
125 Point = QMetaType::QPoint,
126 PointF = QMetaType::QPointF,
127 #if QT_CONFIG(regularexpression)
131 #if QT_CONFIG(easingcurve)
132 EasingCurve = QMetaType::QEasingCurve,
134 Uuid = QMetaType::QUuid,
135 #if QT_CONFIG(itemmodel)
136 ModelIndex = QMetaType::QModelIndex,
137 PersistentModelIndex = QMetaType::QPersistentModelIndex,
141 Font = QMetaType::QFont,
142 Pixmap = QMetaType::QPixmap,
143 Brush = QMetaType::QBrush,
144 Color = QMetaType::QColor,
145 Palette = QMetaType::QPalette,
146 Image = QMetaType::QImage,
147 Polygon = QMetaType::QPolygon,
148 Region = QMetaType::QRegion,
149 Bitmap = QMetaType::QBitmap,
150 Cursor = QMetaType::QCursor,
151 #if QT_CONFIG(shortcut)
152 KeySequence = QMetaType::QKeySequence,
154 Pen = QMetaType::QPen,
155 TextLength = QMetaType::QTextLength,
157 Transform = QMetaType::QTransform,
158 Matrix4x4 = QMetaType::QMatrix4x4,
159 Vector2D = QMetaType::QVector2D,
160 Vector3D = QMetaType::QVector3D,
161 Vector4D = QMetaType::QVector4D,
162 Quaternion = QMetaType::QQuaternion,
163 PolygonF = QMetaType::QPolygonF,
164 Icon = QMetaType::QIcon,
167 SizePolicy = QMetaType::QSizePolicy,
170 LastType = 0xffffffff
185 #ifndef QT_NO_CAST_FROM_ASCII
203 #ifndef QT_NO_GEOM_VARIANT
214 #if QT_CONFIG(regularexpression)
217 #if QT_CONFIG(easingcurve)
221 #ifndef QT_BOOTSTRAPPED
228 #if QT_CONFIG(itemmodel)
241 int typeId()
const {
return metaType().id(); }
253 #if QT_DEPRECATED_SINCE(6, 0)
255 bool canConvert(
int targetTypeId)
const
262 inline bool isValid()
const;
268 inline bool isDetached()
const;
270 int toInt(
bool *
ok =
nullptr)
const;
271 uint toUInt(
bool *
ok =
nullptr)
const;
277 qreal toReal(
bool *
ok =
nullptr)
const;
282 QChar toChar()
const;
283 QDate toDate()
const;
284 QTime toTime()
const;
290 #ifndef QT_NO_GEOM_VARIANT
293 QRect toRect()
const;
294 QSize toSize()
const;
296 QLine toLine()
const;
301 #if QT_CONFIG(regularexpression)
304 #if QT_CONFIG(easingcurve)
307 QUuid toUuid()
const;
308 #ifndef QT_BOOTSTRAPPED
315 #if QT_CONFIG(itemmodel)
320 #ifndef QT_NO_DATASTREAM
324 #if QT_DEPRECATED_SINCE(6, 0)
334 int type =
d.typeId();
338 static const char *typeToName(
int typeId)
341 static Type nameToType(
const char *
name)
344 return metaType <= int(UserType) ?
QVariant::Type(metaType) : UserType;
351 {
return d.storage(); }
352 inline const void *
data()
const {
return constData(); }
354 template<
typename T,
typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, QVariant>>>
357 using VT = std::decay_t<T>;
358 QMetaType metaType = QMetaType::fromType<VT>();
360 if (isDetached() &&
d.type() == metaType) {
361 *
reinterpret_cast<VT *
>(
const_cast<void *
>(constData())) = std::forward<T>(avalue);
363 *
this = QVariant::fromValue<VT>(std::forward<T>(avalue));
374 *
this = std::move(avalue);
379 {
return qvariant_cast<T>(*
this); }
392 std::enable_if_t<std::is_copy_constructible_v<T>,
QVariant>
397 return QVariant(QMetaType::fromType<T>(), std::addressof(
value));
400 template<
typename... Types>
403 if (
value.valueless_by_exception())
405 return std::visit([](
const auto &
arg) {
return fromValue(
arg); },
value);
410 {
return canConvert(QMetaType::fromType<T>()); }
414 {
return canView(QMetaType::fromType<T>()); }
426 size_t align =
type->alignment;
451 {
return reinterpret_cast<const unsigned char *
>(
this) +
offset; }
453 {
return reinterpret_cast<unsigned char *
>(
this) +
offset; }
457 static constexpr
size_t MaxInternalSize = 3*
sizeof(
void *);
464 size_t(
type->size) <= MaxInternalSize && size_t(
type->alignment) <=
alignof(double);
482 packedType = mt >> 2;
487 {
return is_shared ?
data.shared->data() : &
data.data; }
495 {
return *
static_cast<const T *
>(CanUseInternalSpace<T> ? &
data.data :
data.shared->data()); }
498 { *
static_cast<T *
>(CanUseInternalSpace<T> ? &
data.data :
data.shared->data()) =
t; }
520 {
return a.equals(
b); }
522 {
return !
a.equals(
b); }
523 #ifndef QT_NO_DEBUG_STREAM
524 template <
typename T>
560 #ifdef QT_NO_CAST_FROM_ASCII
562 inline QVariant(
const char *) =
delete;
587 #ifndef QT_NO_DATASTREAM
591 #if QT_DEPRECATED_SINCE(6, 0)
622 QMetaType targetType = QMetaType::fromType<T>();
623 if (
v.d.type() == targetType)
625 if constexpr (std::is_same_v<
T,std::remove_const_t<std::remove_pointer_t<T>>
const *>) {
626 using nonConstT = std::remove_const_t<std::remove_pointer_t<T>> *;
627 QMetaType nonConstTargetType = QMetaType::fromType<nonConstT>();
628 if (
v.d.type() == nonConstTargetType)
629 return v.d.get<nonConstT>();
640 return *
reinterpret_cast<const QVariant *
>(
v.constData());
646 #ifndef QT_NO_DEBUG_STREAM
647 #if QT_DEPRECATED_SINCE(6, 0)
669 template<
typename Po
inter>
673 const Pointer *m_pointer =
nullptr;
706 template<
typename Po
inter>
710 const Pointer *m_pointer =
nullptr;
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
The QAtomicInt class provides platform-independent atomic operations on int.
The QBitArray class provides an array of bits.
The QByteArray class provides an array of bytes.
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.
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 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 QTextFormat class provides formatting information for a QTextDocument. \inmodule QtGui.
The QTextLength class encapsulates the different types of length used in a QTextDocument....
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).
Emulated const pointer to QVariant based on a pointer.
The QVariant class acts like a union for the most common Qt data types.
bool canView(QMetaType targetType) const
const void * data() const
static auto fromValue(const T &value) -> std::enable_if_t< std::is_copy_constructible_v< T >, QVariant >
QVariant(QVariant &&other) noexcept
friend bool operator==(const QVariant &a, const QVariant &b)
const DataPtr & data_ptr() const
static QVariant fromStdVariant(const std::variant< Types... > &value)
friend bool operator!=(const QVariant &a, const QVariant &b)
QT_ASCII_CAST_WARN QVariant(const char *str)
void setValue(const QVariant &avalue)
void setValue(QVariant &&avalue)
friend auto operator<<(const QDebug &debug, const T &variant) -> std::enable_if_t< std::is_same_v< T, QVariant >, QDebug >
bool canConvert(QMetaType targetType) const
void setValue(T &&avalue)
const void * constData() const
QVariantPointer is a template class that emulates a pointer to QVariant based on a pointer.
QVariantPointer(const Pointer *pointer)
Pointer operator->() const
QVariantRef< Pointer > operator*() const
The QVariantRef acts as a non-const reference to a QVariant.
QVariantRef(const Pointer *reference)
QVariantRef & operator=(const QVariantRef &value)
QVariantRef(const QVariantRef &)=default
QVariantRef & operator=(QVariantRef &&value)
QVariantRef(QVariantRef &&)=default
friend void swap(QVariantRef a, QVariantRef b)
QVariantRef & operator=(const QVariant &value)
QRhiGraphicsPipeline * ps
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
void toString(QString &appendTo, IPv4Address address)
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION ParsedNumber< float > toFloat(QByteArrayView a) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION ParsedNumber< double > toDouble(QByteArrayView a) noexcept
void swap(SimpleVector< T > &v1, SimpleVector< T > &v2)
#define QT_WARNING_DISABLE_DEPRECATED
QHash< QString, QVariant > QVariantHash
QMap< QString, QVariant > QVariantMap
QList< QString > QStringList
constexpr timespec operator*(const timespec &t1, int mul)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
QT_END_INCLUDE_NAMESPACE typedef double qreal
#define QT_DEPRECATED_VERSION_X_6_0(text)
#define QT_DEPRECATED_VERSION_6_0
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Class)
QList< QVariant > QVariantList
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLsizei const void * pointer
QT_BEGIN_NAMESPACE typedef char Char
#define Q_DECLARE_SHARED(TYPE)
QVariant qvariant_cast< QVariant >(const QVariant &v)
T qvariant_cast(const QVariant &)
QUrl url("http://www.example.com/List of holidays.xml")
[0]
value toMap().value(key)
[3]
const void * storage() const
Private(QMetaType type) noexcept
QtPrivate::QMetaTypeInterface * typeInterface() const
const void * internalStorage() const
static constexpr bool canUseInternalSpace(QtPrivate::QMetaTypeInterface *type)
Private(int type) noexcept
uchar data[MaxInternalSize]
const void * data() const
static PrivateShared * create(const QtPrivate::QMetaTypeInterface *type)
static void free(PrivateShared *p)
void compare(Input input, FnUnderTest fn_under_test, const QByteArray &output)