QtBase  v6.3.1
qvariant.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2020 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QVARIANT_H
41 #define QVARIANT_H
42 
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>
54 #endif
55 #ifndef QT_BOOTSTRAPPED
56 #include <QtCore/qbytearraylist.h>
57 #endif
58 #include <memory>
59 #include <type_traits>
60 #include <variant>
61 
63 
64 
65 class QBitArray;
66 class QDataStream;
67 class QDate;
68 class QDateTime;
69 #if QT_CONFIG(easingcurve)
70 class QEasingCurve;
71 #endif
72 class QLine;
73 class QLineF;
74 class QLocale;
75 class QTransform;
76 class QTime;
77 class QPoint;
78 class QPointF;
79 class QSize;
80 class QSizeF;
81 class QRect;
82 class QRectF;
83 #if QT_CONFIG(regularexpression)
84 class QRegularExpression;
85 #endif // QT_CONFIG(regularexpression)
86 class QTextFormat;
87 class QTextLength;
88 class QUrl;
89 class QVariant;
90 
91 template<typename T>
92 inline T qvariant_cast(const QVariant &);
93 
94 class Q_CORE_EXPORT QVariant
95 {
96  public:
97 #if QT_DEPRECATED_SINCE(6, 0)
98  enum QT_DEPRECATED_VERSION_X_6_0("Use QMetaType::Type instead.") Type
99  {
104  LongLong = QMetaType::LongLong,
105  ULongLong = QMetaType::ULongLong,
107  Char = QMetaType::QChar,
110  String = QMetaType::QString,
111  StringList = QMetaType::QStringList,
112  ByteArray = QMetaType::QByteArray,
113  BitArray = QMetaType::QBitArray,
114  Date = QMetaType::QDate,
115  Time = QMetaType::QTime,
116  DateTime = QMetaType::QDateTime,
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)
128  RegularExpression = QMetaType::QRegularExpression,
129 #endif
131 #if QT_CONFIG(easingcurve)
132  EasingCurve = QMetaType::QEasingCurve,
133 #endif
134  Uuid = QMetaType::QUuid,
135 #if QT_CONFIG(itemmodel)
136  ModelIndex = QMetaType::QModelIndex,
137  PersistentModelIndex = QMetaType::QPersistentModelIndex,
138 #endif
139  LastCoreType = QMetaType::LastCoreType,
140 
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,
153 #endif
154  Pen = QMetaType::QPen,
155  TextLength = QMetaType::QTextLength,
156  TextFormat = QMetaType::QTextFormat,
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,
165  LastGuiType = QMetaType::LastGuiType,
166 
167  SizePolicy = QMetaType::QSizePolicy,
168 
169  UserType = QMetaType::User,
170  LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
171  };
172 #endif
173  QVariant() noexcept : d() {}
174  ~QVariant();
175  explicit QVariant(QMetaType type, const void *copy = nullptr);
176  QVariant(const QVariant &other);
177 
178  QVariant(int i);
179  QVariant(uint ui);
180  QVariant(qlonglong ll);
181  QVariant(qulonglong ull);
182  QVariant(bool b);
183  QVariant(double d);
184  QVariant(float f);
185 #ifndef QT_NO_CAST_FROM_ASCII
186  QT_ASCII_CAST_WARN QVariant(const char *str)
188  {}
189 #endif
190 
191  QVariant(const QByteArray &bytearray);
192  QVariant(const QBitArray &bitarray);
193  QVariant(const QString &string);
194  QVariant(QLatin1String string);
195  QVariant(const QStringList &stringlist);
196  QVariant(QChar qchar);
199  QVariant(const QDateTime &datetime);
200  QVariant(const QList<QVariant> &list);
203 #ifndef QT_NO_GEOM_VARIANT
204  QVariant(const QSize &size);
205  QVariant(const QSizeF &size);
206  QVariant(const QPoint &pt);
207  QVariant(const QPointF &pt);
208  QVariant(const QLine &line);
209  QVariant(const QLineF &line);
210  QVariant(const QRect &rect);
211  QVariant(const QRectF &rect);
212 #endif
213  QVariant(const QLocale &locale);
214 #if QT_CONFIG(regularexpression)
215  QVariant(const QRegularExpression &re);
216 #endif // QT_CONFIG(regularexpression)
217 #if QT_CONFIG(easingcurve)
218  QVariant(const QEasingCurve &easing);
219 #endif
220  QVariant(const QUuid &uuid);
221 #ifndef QT_BOOTSTRAPPED
222  QVariant(const QUrl &url);
223  QVariant(const QJsonValue &jsonValue);
224  QVariant(const QJsonObject &jsonObject);
225  QVariant(const QJsonArray &jsonArray);
226  QVariant(const QJsonDocument &jsonDocument);
227 #endif // QT_BOOTSTRAPPED
228 #if QT_CONFIG(itemmodel)
229  QVariant(const QModelIndex &modelIndex);
230  QVariant(const QPersistentModelIndex &modelIndex);
231 #endif
232 
233  QVariant& operator=(const QVariant &other);
234  inline QVariant(QVariant &&other) noexcept : d(other.d)
235  { other.d = Private(); }
237 
238  inline void swap(QVariant &other) noexcept { std::swap(d, other.d); }
239 
240  int userType() const { return typeId(); }
241  int typeId() const { return metaType().id(); }
242 
243  const char *typeName() const;
244  QMetaType metaType() const;
245 
246  bool canConvert(QMetaType targetType) const
247  { return QMetaType::canConvert(d.type(), targetType); }
248  bool convert(QMetaType type);
249 
250  bool canView(QMetaType targetType) const
251  { return QMetaType::canView(d.type(), targetType); }
252 
253 #if QT_DEPRECATED_SINCE(6, 0)
255  bool canConvert(int targetTypeId) const
256  { return QMetaType::canConvert(d.type(), QMetaType(targetTypeId)); }
258  bool convert(int targetTypeId)
259  { return convert(QMetaType(targetTypeId)); }
260 #endif
261 
262  inline bool isValid() const;
263  bool isNull() const;
264 
265  void clear();
266 
267  void detach();
268  inline bool isDetached() const;
269 
270  int toInt(bool *ok = nullptr) const;
271  uint toUInt(bool *ok = nullptr) const;
272  qlonglong toLongLong(bool *ok = nullptr) const;
273  qulonglong toULongLong(bool *ok = nullptr) const;
274  bool toBool() const;
275  double toDouble(bool *ok = nullptr) const;
276  float toFloat(bool *ok = nullptr) const;
277  qreal toReal(bool *ok = nullptr) const;
278  QByteArray toByteArray() const;
279  QBitArray toBitArray() const;
280  QString toString() const;
281  QStringList toStringList() const;
282  QChar toChar() const;
283  QDate toDate() const;
284  QTime toTime() const;
285  QDateTime toDateTime() const;
286  QList<QVariant> toList() const;
288  QHash<QString, QVariant> toHash() const;
289 
290 #ifndef QT_NO_GEOM_VARIANT
291  QPoint toPoint() const;
292  QPointF toPointF() const;
293  QRect toRect() const;
294  QSize toSize() const;
295  QSizeF toSizeF() const;
296  QLine toLine() const;
297  QLineF toLineF() const;
298  QRectF toRectF() const;
299 #endif
300  QLocale toLocale() const;
301 #if QT_CONFIG(regularexpression)
302  QRegularExpression toRegularExpression() const;
303 #endif // QT_CONFIG(regularexpression)
304 #if QT_CONFIG(easingcurve)
305  QEasingCurve toEasingCurve() const;
306 #endif
307  QUuid toUuid() const;
308 #ifndef QT_BOOTSTRAPPED
309  QUrl toUrl() const;
310  QJsonValue toJsonValue() const;
311  QJsonObject toJsonObject() const;
312  QJsonArray toJsonArray() const;
313  QJsonDocument toJsonDocument() const;
314 #endif // QT_BOOTSTRAPPED
315 #if QT_CONFIG(itemmodel)
316  QModelIndex toModelIndex() const;
317  QPersistentModelIndex toPersistentModelIndex() const;
318 #endif
319 
320 #ifndef QT_NO_DATASTREAM
321  void load(QDataStream &ds);
322  void save(QDataStream &ds) const;
323 #endif
324 #if QT_DEPRECATED_SINCE(6, 0)
327  QT_DEPRECATED_VERSION_X_6_0("Use the constructor taking a QMetaType instead.")
329  : QVariant(QMetaType(int(type)))
330  {}
331  QT_DEPRECATED_VERSION_X_6_0("Use typeId() or metaType().")
332  Type type() const
333  {
334  int type = d.typeId();
335  return type >= QMetaType::User ? UserType : static_cast<Type>(type);
336  }
338  static const char *typeToName(int typeId)
339  { return QMetaType(typeId).name(); }
341  static Type nameToType(const char *name)
342  {
343  int metaType = QMetaType::fromName(name).id();
344  return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
345  }
347 #endif
348 
349  void *data();
350  const void *constData() const
351  { return d.storage(); }
352  inline const void *data() const { return constData(); }
353 
354  template<typename T, typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, QVariant>>>
355  void setValue(T &&avalue)
356  {
357  using VT = std::decay_t<T>;
358  QMetaType metaType = QMetaType::fromType<VT>();
359  // If possible we reuse the current QVariant private.
360  if (isDetached() && d.type() == metaType) {
361  *reinterpret_cast<VT *>(const_cast<void *>(constData())) = std::forward<T>(avalue);
362  } else {
363  *this = QVariant::fromValue<VT>(std::forward<T>(avalue));
364  }
365  }
366 
367  void setValue(const QVariant &avalue)
368  {
369  *this = avalue;
370  }
371 
372  void setValue(QVariant &&avalue)
373  {
374  *this = std::move(avalue);
375  }
376 
377  template<typename T>
378  inline T value() const
379  { return qvariant_cast<T>(*this); }
380 
381  template<typename T>
382  inline T view()
383  {
384  T t{};
385  QMetaType::view(metaType(), data(), QMetaType::fromType<T>(), &t);
386  return t;
387  }
388 
389  template<typename T>
390 #ifndef Q_CLANG_QDOC
391  static inline auto fromValue(const T &value) ->
392  std::enable_if_t<std::is_copy_constructible_v<T>, QVariant>
393 #else
394  static inline QVariant fromValue(const T &value)
395 #endif
396  {
397  return QVariant(QMetaType::fromType<T>(), std::addressof(value));
398  }
399 
400  template<typename... Types>
401  static inline QVariant fromStdVariant(const std::variant<Types...> &value)
402  {
403  if (value.valueless_by_exception())
404  return QVariant();
405  return std::visit([](const auto &arg) { return fromValue(arg); }, value);
406  }
407 
408  template<typename T>
409  bool canConvert() const
410  { return canConvert(QMetaType::fromType<T>()); }
411 
412  template<typename T>
413  bool canView() const
414  { return canView(QMetaType::fromType<T>()); }
415 
416 public:
418  {
419  private:
420  inline PrivateShared() : ref(1) { }
421  public:
423  {
424  Q_ASSERT(type);
425  size_t size = type->size;
426  size_t align = type->alignment;
427 
428  size += sizeof(PrivateShared);
429  if (align > sizeof(PrivateShared)) {
430  // The alignment is larger than the alignment we can guarantee for the pointer
431  // directly following PrivateShared, so we need to allocate some additional
432  // memory to be able to fit the object into the available memory with suitable
433  // alignment.
434  size += align - sizeof(PrivateShared);
435  }
436  void *data = operator new(size);
437  auto *ps = new (data) QVariant::PrivateShared();
438  ps->offset = int(((quintptr(ps) + sizeof(PrivateShared) + align - 1) & ~(align - 1)) - quintptr(ps));
439  return ps;
440  }
441  static void free(PrivateShared *p)
442  {
443  p->~PrivateShared();
444  operator delete(p);
445  }
446 
447  alignas(8) QAtomicInt ref;
448  int offset;
449 
450  const void *data() const
451  { return reinterpret_cast<const unsigned char *>(this) + offset; }
452  void *data()
453  { return reinterpret_cast<unsigned char *>(this) + offset; }
454  };
455  struct Private
456  {
457  static constexpr size_t MaxInternalSize = 3*sizeof(void *);
458  template<typename T>
459  static constexpr bool CanUseInternalSpace = (QTypeInfo<T>::isRelocatable && sizeof(T) <= MaxInternalSize && alignof(T) <= alignof(double));
461  {
462  Q_ASSERT(type);
463  return QMetaType::TypeFlags(type->flags) & QMetaType::RelocatableType &&
464  size_t(type->size) <= MaxInternalSize && size_t(type->alignment) <= alignof(double);
465  }
466 
467  union
468  {
469  uchar data[MaxInternalSize] = {};
471  double _forAlignment; // we want an 8byte alignment on 32bit systems as well
472  } data;
475  quintptr packedType : sizeof(QMetaType) * 8 - 2;
476 
477  Private() noexcept : is_shared(false), is_null(true), packedType(0) {}
478  explicit Private(QMetaType type) noexcept : is_shared(false), is_null(false)
479  {
480  quintptr mt = quintptr(type.d_ptr);
481  Q_ASSERT((mt & 0x3) == 0);
482  packedType = mt >> 2;
483  }
484  explicit Private(int type) noexcept : Private(QMetaType(type)) {}
485 
486  const void *storage() const
487  { return is_shared ? data.shared->data() : &data.data; }
488 
489  const void *internalStorage() const
490  { Q_ASSERT(is_shared); return &data.data; }
491 
492  // determine internal storage at compile time
493  template<typename T>
494  const T &get() const
495  { return *static_cast<const T *>(CanUseInternalSpace<T> ? &data.data : data.shared->data()); }
496  template<typename T>
497  void set(const T &t)
498  { *static_cast<T *>(CanUseInternalSpace<T> ? &data.data : data.shared->data()) = t; }
499 
500  inline QMetaType type() const
501  {
502  return QMetaType(reinterpret_cast<QtPrivate::QMetaTypeInterface *>(packedType << 2));
503  }
504 
506  {
507  return reinterpret_cast<QtPrivate::QMetaTypeInterface *>(packedType << 2);
508  }
509 
510  inline int typeId() const
511  {
512  return type().id();
513  }
514  };
515  public:
516  static QPartialOrdering compare(const QVariant &lhs, const QVariant &rhs);
517 
518 private:
519  friend inline bool operator==(const QVariant &a, const QVariant &b)
520  { return a.equals(b); }
521  friend inline bool operator!=(const QVariant &a, const QVariant &b)
522  { return !a.equals(b); }
523 #ifndef QT_NO_DEBUG_STREAM
524  template <typename T>
525  friend auto operator<<(const QDebug &debug, const T &variant) -> std::enable_if_t<std::is_same_v<T, QVariant>, QDebug> {
526  return variant.qdebugHelper(debug);
527  }
528  QDebug qdebugHelper(QDebug) const;
529 #endif
530  template<typename T>
531  friend inline T qvariant_cast(const QVariant &);
532 protected:
534  void create(int type, const void *copy);
535  void create(QMetaType type, const void *copy);
536  bool equals(const QVariant &other) const;
537  bool convert(int type, void *ptr) const;
538  bool view(int type, void *ptr);
539 
540 private:
541  // force compile error, prevent QVariant(bool) to be called
542  inline QVariant(void *) = delete;
543  // QVariant::Type is marked as \obsolete, but we don't want to
544  // provide a constructor from its intended replacement,
545  // QMetaType::Type, instead, because the idea behind these
546  // constructors is flawed in the first place. But we also don't
547  // want QVariant(QMetaType::String) to compile and falsely be an
548  // int variant, so delete this constructor:
549  QVariant(QMetaType::Type) = delete;
550 
551  // These constructors don't create QVariants of the type associated
552  // with the enum, as expected, but they would create a QVariant of
553  // type int with the value of the enum value.
554  // Use QVariant v = QColor(Qt::red) instead of QVariant v = Qt::red for
555  // example.
556  QVariant(Qt::GlobalColor) = delete;
557  QVariant(Qt::BrushStyle) = delete;
558  QVariant(Qt::PenStyle) = delete;
559  QVariant(Qt::CursorShape) = delete;
560 #ifdef QT_NO_CAST_FROM_ASCII
561  // force compile error when implicit conversion is not wanted
562  inline QVariant(const char *) = delete;
563 #endif
564 public:
565  typedef Private DataPtr;
566  inline DataPtr &data_ptr() { return d; }
567  inline const DataPtr &data_ptr() const { return d; }
568 };
569 
570 template<>
572 {
573  return value;
574 }
575 
576 template<>
577 inline QVariant QVariant::fromValue(const std::monostate &)
578 {
579  return QVariant();
580 }
581 
582 inline bool QVariant::isValid() const
583 {
584  return d.type().isValid();
585 }
586 
587 #ifndef QT_NO_DATASTREAM
588 Q_CORE_EXPORT QDataStream &operator>>(QDataStream &s, QVariant &p);
589 Q_CORE_EXPORT QDataStream &operator<<(QDataStream &s, const QVariant &p);
590 
591 #if QT_DEPRECATED_SINCE(6, 0)
596 {
597  quint32 u;
598  s >> u;
599  p = static_cast<QVariant::Type>(u);
600  return s;
601 }
604 {
606  return s;
607 }
609 #endif
610 
611 #endif
612 
613 inline bool QVariant::isDetached() const
614 { return !d.is_shared || d.data.shared->ref.loadRelaxed() == 1; }
615 
617 
618 #ifndef QT_MOC
619 
620 template<typename T> inline T qvariant_cast(const QVariant &v)
621 {
622  QMetaType targetType = QMetaType::fromType<T>();
623  if (v.d.type() == targetType)
624  return v.d.get<T>();
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>();
630  }
631 
632  T t{};
633  QMetaType::convert(v.metaType(), v.constData(), targetType, &t);
634  return t;
635 }
636 
637 template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
638 {
639  if (v.metaType().id() == QMetaType::QVariant)
640  return *reinterpret_cast<const QVariant *>(v.constData());
641  return v;
642 }
643 
644 #endif
645 
646 #ifndef QT_NO_DEBUG_STREAM
647 #if QT_DEPRECATED_SINCE(6, 0)
651 Q_CORE_EXPORT QDebug operator<<(QDebug, const QVariant::Type);
653 #endif
654 #endif
655 
656 namespace QtPrivate {
657 class Q_CORE_EXPORT QVariantTypeCoercer
658 {
659 public:
660  // ### Qt7: Pass QMetaType as value rather than const ref.
661  const void *convert(const QVariant &value, const QMetaType &type);
662  const void *coerce(const QVariant &value, const QMetaType &type);
663 
664 private:
665  QVariant converted;
666 };
667 }
668 
669 template<typename Pointer>
671 {
672 private:
673  const Pointer *m_pointer = nullptr;
674 
675 public:
676  explicit QVariantRef(const Pointer *reference) : m_pointer(reference) {}
677  QVariantRef(const QVariantRef &) = default;
678  QVariantRef(QVariantRef &&) = default;
679  ~QVariantRef() = default;
680 
681  operator QVariant() const;
685 
687  {
688  QVariant tmp = a;
689  a = b;
690  b = std::move(tmp);
691  }
692 };
693 
694 class Q_CORE_EXPORT QVariantConstPointer
695 {
696 private:
697  QVariant m_variant;
698 
699 public:
701 
702  QVariant operator*() const;
703  const QVariant *operator->() const;
704 };
705 
706 template<typename Pointer>
708 {
709 private:
710  const Pointer *m_pointer = nullptr;
711 
712 public:
713  explicit QVariantPointer(const Pointer *pointer) : m_pointer(pointer) {}
714  QVariantRef<Pointer> operator*() const { return QVariantRef<Pointer>(m_pointer); }
715  Pointer operator->() const { return *m_pointer; }
716 };
717 
719 
720 #endif // QVARIANT_H
small capitals from c petite p scientific f u
Definition: afcover.h:88
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
#define value
[5]
@ Double
The QAtomicInt class provides platform-independent atomic operations on int.
Definition: qatomic.h:158
The QBitArray class provides an array of bits.
Definition: qbitarray.h:49
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:85
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:84
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
The QDate class provides date functions.
Definition: qdatetime.h:64
The QDateTime class provides date and time functions.
Definition: qdatetime.h:238
The QDebug class provides an output stream for debugging information.
Definition: qdebug.h:65
The QEasingCurve class provides easing curves for controlling animation.
Definition: qeasingcurve.h:55
The QJsonArray class encapsulates a JSON array.
Definition: qjsonarray.h:54
The QJsonDocument class provides a way to read and write JSON documents.
Definition: qjsondocument.h:83
The QJsonObject class encapsulates a JSON object.
Definition: qjsonobject.h:56
The QJsonValue class encapsulates a value in JSON.
Definition: qjsonvalue.h:60
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
Definition: qstring.h:84
The QLineF class provides a two-dimensional vector using floating point precision.
Definition: qline.h:215
The QLine class provides a two-dimensional vector using integer precision.
Definition: qline.h:53
The QMetaType class manages named types in the meta-object system.
Definition: qmetatype.h:328
static bool canConvert(QMetaType fromType, QMetaType toType)
Definition: qmetatype.cpp:2434
static bool canView(QMetaType fromType, QMetaType toType)
Definition: qmetatype.cpp:2336
static bool view(QMetaType fromType, void *from, QMetaType toType, void *to)
Definition: qmetatype.cpp:2293
static QMetaType fromName(QByteArrayView name)
Definition: qmetatype.cpp:2789
bool isValid() const
Definition: qmetatype.cpp:509
int id(int=0) const
Definition: qmetatype.h:453
@ RelocatableType
Definition: qmetatype.h:388
@ LastCoreType
Definition: qmetatype.h:337
@ UnknownType
Definition: qmetatype.h:346
@ LastGuiType
Definition: qmetatype.h:339
constexpr const char * name() const
Definition: qmetatype.h:2531
static bool convert(QMetaType fromType, const void *from, QMetaType toType, void *to)
Definition: qmetatype.cpp:2226
friend class QVariant
Definition: qmetatype.h:744
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.
Definition: qpoint.h:242
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRectF class defines a finite rectangle in the plane using floating point precision.
Definition: qrect.h:511
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
The QRegularExpression class provides pattern matching using regular expressions.
The QSizeF class defines the size of a two-dimensional object using floating point precision.
Definition: qsize.h:235
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QStringList class provides a list of strings.
The QTextFormat class provides formatting information for a QTextDocument. \inmodule QtGui.
Definition: qtextformat.h:126
The QTextLength class encapsulates the different types of length used in a QTextDocument....
Definition: qtextformat.h:81
The QTime class provides clock time functions.
Definition: qdatetime.h:166
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:56
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:130
The QUuid class stores a Universally Unique Identifier (UUID).
Definition: quuid.h:67
Emulated const pointer to QVariant based on a pointer.
Definition: qvariant.h:695
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:95
bool canView(QMetaType targetType) const
Definition: qvariant.h:250
DataPtr & data_ptr()
Definition: qvariant.h:566
const void * data() const
Definition: qvariant.h:352
bool canConvert() const
Definition: qvariant.h:409
QVariant() noexcept
Definition: qvariant.h:173
static auto fromValue(const T &value) -> std::enable_if_t< std::is_copy_constructible_v< T >, QVariant >
Definition: qvariant.h:391
T view()
Definition: qvariant.h:382
bool isDetached() const
Definition: qvariant.h:613
QVariant(QVariant &&other) noexcept
Definition: qvariant.h:234
bool isValid() const
Definition: qvariant.h:582
friend bool operator==(const QVariant &a, const QVariant &b)
Definition: qvariant.h:519
bool canView() const
Definition: qvariant.h:413
const DataPtr & data_ptr() const
Definition: qvariant.h:567
static QVariant fromStdVariant(const std::variant< Types... > &value)
Definition: qvariant.h:401
friend bool operator!=(const QVariant &a, const QVariant &b)
Definition: qvariant.h:521
int userType() const
Definition: qvariant.h:240
QT_ASCII_CAST_WARN QVariant(const char *str)
Definition: qvariant.h:186
void setValue(const QVariant &avalue)
Definition: qvariant.h:367
void setValue(QVariant &&avalue)
Definition: qvariant.h:372
friend auto operator<<(const QDebug &debug, const T &variant) -> std::enable_if_t< std::is_same_v< T, QVariant >, QDebug >
Definition: qvariant.h:525
int typeId() const
Definition: qvariant.h:241
T value() const
Definition: qvariant.h:378
bool canConvert(QMetaType targetType) const
Definition: qvariant.h:246
Private DataPtr
Definition: qvariant.h:565
Private d
Definition: qvariant.h:533
void setValue(T &&avalue)
Definition: qvariant.h:355
const void * constData() const
Definition: qvariant.h:350
QVariantPointer is a template class that emulates a pointer to QVariant based on a pointer.
Definition: qvariant.h:708
QVariantPointer(const Pointer *pointer)
Definition: qvariant.h:713
Pointer operator->() const
Definition: qvariant.h:715
QVariantRef< Pointer > operator*() const
Definition: qvariant.h:714
The QVariantRef acts as a non-const reference to a QVariant.
Definition: qvariant.h:671
QVariantRef(const Pointer *reference)
Definition: qvariant.h:676
~QVariantRef()=default
QVariantRef & operator=(const QVariantRef &value)
Definition: qvariant.h:683
QVariantRef(const QVariantRef &)=default
QVariantRef & operator=(QVariantRef &&value)
Definition: qvariant.h:684
QVariantRef(QVariantRef &&)=default
friend void swap(QVariantRef a, QVariantRef b)
Definition: qvariant.h:686
QVariantRef & operator=(const QVariant &value)
QRhiGraphicsPipeline * ps
#define T(x)
Definition: main.cpp:42
QHash< int, QWidget * > hash
[35multi]
b clear()
QMap< QString, QString > map
[6]
QString str
[2]
p1 load("image.bmp")
QDate date
[1]
rect
[4]
#define true
Definition: ftrandom.c:51
char Bool
Definition: ftraster.c:315
int Int
Definition: ftraster.c:307
unsigned int UInt
Definition: ftraster.c:308
#define inline
Definition: md4c.c:45
@ Font
Definition: qcssparser_p.h:98
@ Color
Definition: qcssparser_p.h:96
void toString(QString &appendTo, IPv4Address address)
Definition: qipaddress.cpp:131
qsizetype fromUtf8(uchar b, OutputPtr &dst, InputPtr &src, InputPtr end)
TextFormat
Definition: qnamespace.h:1204
CursorShape
Definition: qnamespace.h:1176
GlobalColor
Definition: qnamespace.h:58
PenStyle
Definition: qnamespace.h:1111
BrushStyle
Definition: qnamespace.h:1139
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)
Definition: simplevector.h:331
#define QString()
Definition: parse-defines.h:51
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_DEPRECATED
#define QT_WARNING_PUSH
QHash< QString, QVariant > QVariantHash
Definition: qcontainerfwd.h:76
QMap< QString, QVariant > QVariantMap
Definition: qcontainerfwd.h:75
QList< QString > QStringList
Definition: qcontainerfwd.h:64
constexpr timespec operator*(const timespec &t1, int mul)
Definition: qcore_unix_p.h:146
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
unsigned int quint32
Definition: qglobal.h:288
QT_BEGIN_INCLUDE_NAMESPACE typedef unsigned char uchar
Definition: qglobal.h:332
size_t quintptr
Definition: qglobal.h:310
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
quint64 qulonglong
Definition: qglobal.h:302
unsigned int uint
Definition: qglobal.h:334
#define QT_DEPRECATED_VERSION_X_6_0(text)
Definition: qglobal.h:444
#define QT_DEPRECATED_VERSION_6_0
Definition: qglobal.h:445
qint64 qlonglong
Definition: qglobal.h:301
#define QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(Class)
Definition: qglobal.h:556
QList< QVariant > QVariantList
Definition: qjsonarray.h:50
@ Invalid
Definition: qmetaobject_p.h:68
const char * typeName
Definition: qmetatype.cpp:869
GLenum type
Definition: qopengl.h:270
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat f
GLint reference
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint ref
GLuint name
GLdouble GLdouble t
[9]
Definition: qopenglext.h:243
GLsizei const void * pointer
Definition: qopenglext.h:384
GLdouble s
[6]
Definition: qopenglext.h:235
GLfloat GLfloat p
[1]
Definition: qopenglext.h:12698
XID Pixmap
Definition: qpixmap_x11_p.h:52
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
SSL_CTX int(*) void arg)
QT_BEGIN_NAMESPACE typedef char Char
#define Q_DECLARE_SHARED(TYPE)
Definition: qtypeinfo.h:197
QVariant qvariant_cast< QVariant >(const QVariant &v)
Definition: qvariant.h:637
T qvariant_cast(const QVariant &)
Definition: qvariant.h:620
#define explicit
@ Time
Definition: sctpchannels.h:56
#define VT(vt)
QT_BEGIN_NAMESPACE bool toBool(const QString &str)
Definition: utils.h:39
QByteArray bytearray
[3]
QUrl url("http://www.example.com/List of holidays.xml")
[0]
QVariant variant
[1]
value toMap().value(key)
[3]
QTime time
[5]
QBitArray().isNull()
[3]
Definition: qbitarray.h:149
QEasingCurve easing(QEasingCurve::InOutQuad)
[typedef]
QSharedPointer< T > other(t)
[5]
this swap(other)
QQuickView * view
[0]
view create()
QDBusVariant Type
QStringList list
[0]
Definition: main.cpp:253
const void * storage() const
Definition: qvariant.h:486
int typeId() const
Definition: qvariant.h:510
PrivateShared * shared
Definition: qvariant.h:470
Private(QMetaType type) noexcept
Definition: qvariant.h:478
QtPrivate::QMetaTypeInterface * typeInterface() const
Definition: qvariant.h:505
Private() noexcept
Definition: qvariant.h:477
const void * internalStorage() const
Definition: qvariant.h:489
quintptr is_shared
Definition: qvariant.h:473
static constexpr bool canUseInternalSpace(QtPrivate::QMetaTypeInterface *type)
Definition: qvariant.h:460
Private(int type) noexcept
Definition: qvariant.h:484
quintptr packedType
Definition: qvariant.h:475
quintptr is_null
Definition: qvariant.h:474
uchar data[MaxInternalSize]
Definition: qvariant.h:469
const T & get() const
Definition: qvariant.h:494
void set(const T &t)
Definition: qvariant.h:497
double _forAlignment
Definition: qvariant.h:471
QMetaType type() const
Definition: qvariant.h:500
const void * data() const
Definition: qvariant.h:450
static PrivateShared * create(const QtPrivate::QMetaTypeInterface *type)
Definition: qvariant.h:422
static void free(PrivateShared *p)
Definition: qvariant.h:441
Definition: main.cpp:38
Definition: moc.h:48
void compare(Input input, FnUnderTest fn_under_test, const QByteArray &output)
U convert(const T &t)
#define rhs