8#include <QtCore/qbytearray.h>
15 Q_CORE_EXPORT
friend QBitArray operator&(
const QBitArray &a1,
const QBitArray &a2);
16 friend QBitArray operator&(QBitArray &&a1,
const QBitArray &a2)
18 friend QBitArray operator&(
const QBitArray &a1, QBitArray &&a2)
20 friend QBitArray operator&(QBitArray &&a1, QBitArray &&a2)
23 Q_CORE_EXPORT
friend QBitArray operator|(
const QBitArray &a1,
const QBitArray &a2);
24 friend QBitArray operator|(QBitArray &&a1,
const QBitArray &a2)
26 friend QBitArray operator|(
const QBitArray &a1, QBitArray &&a2)
28 friend QBitArray operator|(QBitArray &&a1, QBitArray &&a2)
31 Q_CORE_EXPORT
friend QBitArray operator^(
const QBitArray &a1,
const QBitArray &a2);
32 friend QBitArray operator^(QBitArray &&a1,
const QBitArray &a2)
34 friend QBitArray operator^(
const QBitArray &a1, QBitArray &&a2)
36 friend QBitArray operator^(QBitArray &&a1, QBitArray &&a2)
39#ifndef QT_NO_DATASTREAM
40 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &,
const QBitArray &);
41 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &);
43 friend Q_CORE_EXPORT size_t qHash(
const QBitArray &key, size_t seed)
noexcept;
44 friend QBitArray operator~(QBitArray a)
45 {
return std::move(a).inverted_inplace(); }
48 QBitArray(QByteArrayData &&dd) : d(std::move(dd)) {}
50 template <
typename BitArray>
static auto bitLocation(BitArray &ba, qsizetype i)
52 Q_ASSERT(size_t(i) < size_t(ba.size()));
54 decltype(ba.d[1]) byte;
57 qsizetype byteIdx = i >> 3;
58 qsizetype bitIdx = i & 7;
59 return R{ ba.d[1 + byteIdx], uchar(1U << bitIdx) };
62 QBitArray inverted_inplace() &&;
65 inline QBitArray()
noexcept {}
66 explicit QBitArray(qsizetype size,
bool val =
false);
68#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
69 QBitArray(
const QBitArray &other)
noexcept : d(other.d) {}
70 inline QBitArray &operator=(
const QBitArray &other)
noexcept { d = other.d;
return *
this; }
71 inline QBitArray(QBitArray &&other)
noexcept : d(std::move(other.d)) {}
72 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QBitArray)
75 void swap(QBitArray &other)
noexcept { d.swap(other.d); }
77 qsizetype size()
const {
return qsizetype((size_t(d.size()) << 3) - *d.constData()); }
78 qsizetype count()
const {
return size(); }
79 qsizetype count(
bool on)
const;
81 inline bool isEmpty()
const {
return d.isEmpty(); }
82 inline bool isNull()
const {
return d.isNull(); }
84 void resize(qsizetype size);
86 inline void detach() { d.detach(); }
87 inline bool isDetached()
const {
return d.isDetached(); }
88 inline void clear() { d.clear(); }
90 bool testBit(qsizetype i)
const
91 {
auto r = bitLocation(*
this, i);
return r.byte & r.bitMask; }
92 void setBit(qsizetype i)
93 {
auto r = bitLocation(*
this, i); r.byte |= r.bitMask; }
94 void setBit(qsizetype i,
bool val)
95 {
if (val) setBit(i);
else clearBit(i); }
96 void clearBit(qsizetype i)
97 {
auto r = bitLocation(*
this, i); r.byte &= ~r.bitMask; }
98 bool toggleBit(qsizetype i)
100 auto r = bitLocation(*
this, i);
101 bool cl = r.byte & r.bitMask;
106 bool at(qsizetype i)
const {
return testBit(i); }
107 inline QBitRef operator[](qsizetype i);
108 bool operator[](qsizetype i)
const {
return testBit(i); }
110 QBitArray &operator&=(QBitArray &&);
111 QBitArray &operator|=(QBitArray &&);
112 QBitArray &operator^=(QBitArray &&);
113 QBitArray &operator&=(
const QBitArray &);
114 QBitArray &operator|=(
const QBitArray &);
115 QBitArray &operator^=(
const QBitArray &);
116#if QT_CORE_REMOVED_SINCE(6
, 7
)
117 QBitArray operator~()
const;
120#if QT_CORE_REMOVED_SINCE(6
, 8
)
121 inline bool operator==(
const QBitArray &other)
const {
return comparesEqual(d, other.d); }
122 inline bool operator!=(
const QBitArray &other)
const {
return !operator==(other); }
125 bool fill(
bool aval, qsizetype asize = -1)
126 { *
this = QBitArray((asize < 0 ?
this->size() : asize), aval);
return true; }
127 void fill(
bool val, qsizetype first, qsizetype last);
129 inline void truncate(qsizetype pos) {
if (pos < size()) resize(pos); }
131 const char *bits()
const {
return isEmpty() ?
nullptr : d.constData() + 1; }
132 static QBitArray fromBits(
const char *data, qsizetype len);
134 quint32 toUInt32(QSysInfo::Endian endianness,
bool *ok =
nullptr)
const noexcept;
137 typedef QByteArray::DataPointer DataPtr;
138 inline DataPtr &data_ptr() {
return d.data_ptr(); }
139 inline const DataPtr &data_ptr()
const {
return d.data_ptr(); }
142 friend bool comparesEqual(
const QBitArray &lhs,
const QBitArray &rhs)
noexcept
144 return lhs.d == rhs.d;
146 Q_DECLARE_EQUALITY_COMPARABLE(QBitArray)
149class QT6_ONLY(Q_CORE_EXPORT) QBitRef
154 inline QBitRef(QBitArray &array, qsizetype idx) : a(array), i(idx) { }
155 friend class QBitArray;
158 inline operator
bool()
const {
return a.testBit(i); }
159 inline bool operator!()
const {
return !a.testBit(i); }
160 QBitRef &operator=(
const QBitRef &val) { a.setBit(i, val);
return *
this; }
161 QBitRef &operator=(
bool val) { a.setBit(i, val);
return *
this; }
164QBitRef QBitArray::operator[](qsizetype i)
165{ Q_ASSERT(i >= 0);
return QBitRef(*
this, i); }
167#ifndef QT_NO_DATASTREAM
168Q_CORE_EXPORT
QDataStream &operator<<(QDataStream &,
const QBitArray &);
172#ifndef QT_NO_DEBUG_STREAM
173Q_CORE_EXPORT
QDebug operator<<(QDebug,
const QBitArray &);
\inmodule QtCore\reentrant
QModelIndex siblingAtColumn(int column) const
Returns the sibling at column for the current row.
QVariant data(int role=Qt::DisplayRole) const
Returns the data for the given role for the item referred to by the index, or a default-constructed Q...
constexpr int row() const noexcept
Returns the row this model index refers to.
friend constexpr bool comparesEqual(const QModelIndex &lhs, const QModelIndex &rhs) noexcept
QModelIndex siblingAtRow(int row) const
Returns the sibling at row for the current column.
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
constexpr const QAbstractItemModel * model() const noexcept
Returns a pointer to the model containing the item that this index refers to.
Qt::ItemFlags flags() const
constexpr bool isValid() const noexcept
Returns {true} if this model index is valid; otherwise returns {false}.
void * internalPointer() const noexcept
Returns a {void} {*} pointer used by the model to associate the index with the internal data structur...
friend constexpr Qt::strong_ordering compareThreeWay(const QModelIndex &lhs, const QModelIndex &rhs) noexcept
void multiData(QModelRoleDataSpan roleDataSpan) const
constexpr QModelIndex() noexcept
Creates a new empty model index.
constexpr int column() const noexcept
Returns the column this model index refers to.
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
constexpr quintptr internalId() const noexcept
Returns a {quintptr} used by the model to associate the index with the internal data structure.
const void * constInternalPointer() const noexcept
Returns a {const void} {*} pointer used by the model to associate the index with the internal data st...
constexpr qsizetype size() const noexcept
Returns the length of the span represented by this object.
constexpr QModelRoleData * end() const noexcept
Returns a pointer to the imaginary element one past the end of the span represented by this object.
constexpr QModelRoleData * begin() const noexcept
Returns a pointer to the beginning of the span represented by this object.
constexpr QModelRoleDataSpan() noexcept
Constructs an empty QModelRoleDataSpan.
constexpr qsizetype length() const noexcept
Returns the length of the span represented by this object.
constexpr QModelRoleDataSpan(Container &c) noexcept(noexcept(std::data(c)) &&noexcept(std::size(c)))
Constructs an QModelRoleDataSpan spanning over the container c, which can be any contiguous container...
constexpr QModelRoleData & operator[](qsizetype index) const
Returns a modifiable reference to the QModelRoleData at position index in the span.
constexpr QModelRoleData * data() const noexcept
Returns a pointer to the beginning of the span represented by this object.
constexpr QModelRoleDataSpan(QModelRoleData *modelRoleData, qsizetype len)
Constructs an QModelRoleDataSpan spanning over the array beginning at modelRoleData and with length l...
constexpr QModelRoleDataSpan(QModelRoleData &modelRoleData) noexcept
Constructs an QModelRoleDataSpan spanning over modelRoleData, seen as a 1-element array.
constexpr QVariant * dataForRole(int role) const
Returns the data associated with the first QModelRoleData in the span that has its role equal to role...
Combined button and popup list for selecting options.
bool comparesEqual(const QPersistentModelIndex &lhs, const QModelIndex &rhs) noexcept
Qt::strong_ordering compareThreeWay(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs) noexcept
static uint typeOfVariant(const QVariant &value)
QDebug operator<<(QDebug dbg, const QModelIndex &idx)
Qt::strong_ordering compareThreeWay(const QPersistentModelIndex &lhs, const QModelIndex &rhs) noexcept
QDebug operator<<(QDebug dbg, const QPersistentModelIndex &idx)
bool comparesEqual(const QPersistentModelIndex &lhs, const QPersistentModelIndex &rhs) noexcept
Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames, { { Qt::DisplayRole, "display" }, { Qt::DecorationRole, "decoration" }, { Qt::EditRole, "edit" }, { Qt::ToolTipRole, "toolTip" }, { Qt::StatusTipRole, "statusTip" }, { Qt::WhatsThisRole, "whatsThis" }, }) const QHash< int
size_t qHash(const QModelIndex &index, size_t seed=0) noexcept
Q_DECLARE_TYPEINFO(QModelRoleDataSpan, Q_RELOCATABLE_TYPE)
QT_REQUIRE_CONFIG(itemmodel)
QList< QModelIndex > QModelIndexList
size_t qHash(const QPersistentModelIndex &index, size_t seed=0) noexcept
Q_DECLARE_TYPEINFO(QModelIndex, Q_RELOCATABLE_TYPE)
Q_DECLARE_TYPEINFO(QModelRoleData, Q_RELOCATABLE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)