7#include <QtCore/qbytearray.h>
14 Q_CORE_EXPORT
friend QBitArray operator&(
const QBitArray &a1,
const QBitArray &a2);
15 friend QBitArray operator&(QBitArray &&a1,
const QBitArray &a2)
17 friend QBitArray operator&(
const QBitArray &a1, QBitArray &&a2)
19 friend QBitArray operator&(QBitArray &&a1, QBitArray &&a2)
22 Q_CORE_EXPORT
friend QBitArray operator|(
const QBitArray &a1,
const QBitArray &a2);
23 friend QBitArray operator|(QBitArray &&a1,
const QBitArray &a2)
25 friend QBitArray operator|(
const QBitArray &a1, QBitArray &&a2)
27 friend QBitArray operator|(QBitArray &&a1, QBitArray &&a2)
30 Q_CORE_EXPORT
friend QBitArray operator^(
const QBitArray &a1,
const QBitArray &a2);
31 friend QBitArray operator^(QBitArray &&a1,
const QBitArray &a2)
33 friend QBitArray operator^(
const QBitArray &a1, QBitArray &&a2)
35 friend QBitArray operator^(QBitArray &&a1, QBitArray &&a2)
38#ifndef QT_NO_DATASTREAM
39 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &,
const QBitArray &);
40 friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QBitArray &);
42 friend Q_CORE_EXPORT size_t qHash(
const QBitArray &key, size_t seed)
noexcept;
43 friend QBitArray operator~(QBitArray a)
44 {
return std::move(a).inverted_inplace(); }
47 QBitArray(QByteArrayData &&dd) : d(std::move(dd)) {}
49 template <
typename BitArray>
static auto bitLocation(BitArray &ba, qsizetype i)
51 Q_ASSERT(size_t(i) < size_t(ba.size()));
53 decltype(ba.d[1]) byte;
56 qsizetype byteIdx = i >> 3;
57 qsizetype bitIdx = i & 7;
58 return R{ ba.d[1 + byteIdx], uchar(1U << bitIdx) };
61 QBitArray inverted_inplace() &&;
64 inline QBitArray()
noexcept {}
65 explicit QBitArray(qsizetype size,
bool val =
false);
67#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
68 QBitArray(
const QBitArray &other)
noexcept : d(other.d) {}
69 inline QBitArray &operator=(
const QBitArray &other)
noexcept { d = other.d;
return *
this; }
70 inline QBitArray(QBitArray &&other)
noexcept : d(std::move(other.d)) {}
71 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QBitArray)
74 void swap(QBitArray &other)
noexcept { d.swap(other.d); }
76 qsizetype size()
const {
return qsizetype((size_t(d.size()) << 3) - *d.constData()); }
77 qsizetype count()
const {
return size(); }
78 qsizetype count(
bool on)
const;
80 inline bool isEmpty()
const {
return d.isEmpty(); }
81 inline bool isNull()
const {
return d.isNull(); }
83 void resize(qsizetype size);
85 inline void detach() { d.detach(); }
86 inline bool isDetached()
const {
return d.isDetached(); }
87 inline void clear() { d.clear(); }
89 bool testBit(qsizetype i)
const
90 {
auto r = bitLocation(*
this, i);
return r.byte & r.bitMask; }
91 void setBit(qsizetype i)
92 {
auto r = bitLocation(*
this, i); r.byte |= r.bitMask; }
93 void setBit(qsizetype i,
bool val)
94 {
if (val) setBit(i);
else clearBit(i); }
95 void clearBit(qsizetype i)
96 {
auto r = bitLocation(*
this, i); r.byte &= ~r.bitMask; }
97 bool toggleBit(qsizetype i)
99 auto r = bitLocation(*
this, i);
100 bool cl = r.byte & r.bitMask;
105 bool at(qsizetype i)
const {
return testBit(i); }
106 inline QBitRef operator[](qsizetype i);
107 bool operator[](qsizetype i)
const {
return testBit(i); }
109 QBitArray &operator&=(QBitArray &&);
110 QBitArray &operator|=(QBitArray &&);
111 QBitArray &operator^=(QBitArray &&);
112 QBitArray &operator&=(
const QBitArray &);
113 QBitArray &operator|=(
const QBitArray &);
114 QBitArray &operator^=(
const QBitArray &);
115#if QT_CORE_REMOVED_SINCE(6
, 7
)
116 QBitArray operator~()
const;
119#if QT_CORE_REMOVED_SINCE(6
, 8
)
120 inline bool operator==(
const QBitArray &other)
const {
return comparesEqual(d, other.d); }
121 inline bool operator!=(
const QBitArray &other)
const {
return !operator==(other); }
124 bool fill(
bool aval, qsizetype asize = -1)
125 { *
this = QBitArray((asize < 0 ?
this->size() : asize), aval);
return true; }
126 void fill(
bool val, qsizetype first, qsizetype last);
128 inline void truncate(qsizetype pos) {
if (pos < size()) resize(pos); }
130 const char *bits()
const {
return isEmpty() ?
nullptr : d.constData() + 1; }
131 static QBitArray fromBits(
const char *data, qsizetype len);
133 quint32 toUInt32(QSysInfo::Endian endianness,
bool *ok =
nullptr)
const noexcept;
136 typedef QByteArray::DataPointer DataPtr;
137 inline DataPtr &data_ptr() {
return d.data_ptr(); }
138 inline const DataPtr &data_ptr()
const {
return d.data_ptr(); }
141 friend bool comparesEqual(
const QBitArray &lhs,
const QBitArray &rhs)
noexcept
143 return lhs.d == rhs.d;
145 Q_DECLARE_EQUALITY_COMPARABLE(QBitArray)
148class QT6_ONLY(Q_CORE_EXPORT) QBitRef
153 inline QBitRef(QBitArray &array, qsizetype idx) : a(array), i(idx) { }
154 friend class QBitArray;
157 inline operator
bool()
const {
return a.testBit(i); }
158 inline bool operator!()
const {
return !a.testBit(i); }
159 QBitRef &operator=(
const QBitRef &val) { a.setBit(i, val);
return *
this; }
160 QBitRef &operator=(
bool val) { a.setBit(i, val);
return *
this; }
163QBitRef QBitArray::operator[](qsizetype i)
164{ Q_ASSERT(i >= 0);
return QBitRef(*
this, i); }
166#ifndef QT_NO_DATASTREAM
167Q_CORE_EXPORT
QDataStream &operator<<(QDataStream &,
const QBitArray &);
171#ifndef QT_NO_DEBUG_STREAM
172Q_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,...)