7#include <QtCore/qglobal.h>
8#include <QtCore/qatomic.h>
9#include <QtCore/qcompare.h>
10#include <QtCore/qhashfunctions.h>
17template <
class T>
class QSharedDataPointer;
41 void detach() {
if (d && d->ref.loadRelaxed() != 1) detach_helper(); }
43 const T &
operator*()
const {
return *(d.get()); }
45 const T *
operator->()
const noexcept {
return d.get(); }
47 operator const T *()
const noexcept {
return d.get(); }
50 const T *
data()
const noexcept {
return d.get(); }
51 const T *
get()
const noexcept {
return d.get(); }
52 const T *
constData()
const noexcept {
return d.get(); }
53 T *
take()
noexcept {
return std::exchange(d,
nullptr).get(); }
69 void reset(T *ptr =
nullptr)
noexcept
74 T *old = std::exchange(d, Qt::totally_ordered_wrapper(ptr)).get();
75 if (old && !old->ref.deref())
94 operator bool ()
const noexcept {
return d !=
nullptr; }
95 bool operator!()
const noexcept {
return d ==
nullptr; }
105 {
return lhs.d == rhs.d; }
108 {
return Qt::compareThreeWay(lhs.d, rhs.d); }
119 {
return lhs.
d ==
nullptr; }
127 Qt::totally_ordered_wrapper<T *> d;
141 explicit operator const T *()
const noexcept {
return d.get(); }
142 T *
data()
const noexcept {
return d.get(); }
143 T *
get()
const noexcept {
return d.get(); }
145 T *
take()
noexcept {
return std::exchange(d,
nullptr).get(); }
147 void detach() {
if (d && d->ref.loadRelaxed() != 1) detach_helper(); }
166#ifdef QT_ENABLE_QEXPLICITLYSHAREDDATAPOINTER_STATICCAST
167#error This macro has been removed in Qt 6.9.
172 void reset(T *ptr =
nullptr)
noexcept
177 T *old = std::exchange(d, Qt::totally_ordered_wrapper(ptr)).get();
178 if (old && !old->ref.deref())
197 operator bool ()
const noexcept {
return d !=
nullptr; }
198 bool operator!()
const noexcept {
return d ==
nullptr; }
209 {
return lhs.d == rhs.d; }
213 {
return Qt::compareThreeWay(lhs.d, rhs.d); }
224 {
return lhs.
d ==
nullptr; }
232 Qt::totally_ordered_wrapper<T *> d;
237Q_INLINE_TEMPLATE T *QSharedDataPointer<T>::clone()
247 if (!d.get()->ref.deref())
253Q_INLINE_TEMPLATE T *QExplicitlySharedDataPointer<T>::clone()
255 return new T(*d.get());
279 return qHash(ptr.data(), seed);
284 return qHash(ptr.data(), seed);
290#define QT_DECLARE_QSDP_SPECIALIZATION_DTOR(Class)
291 template<> QSharedDataPointer<Class>::~QSharedDataPointer();
293#define QT_DECLARE_QSDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
294 template<> ExportMacro QSharedDataPointer<Class>::~QSharedDataPointer();
296#define QT_DEFINE_QSDP_SPECIALIZATION_DTOR(Class)
297 template<> QSharedDataPointer<Class>::~QSharedDataPointer()
299 if (d && !d->ref.deref())
303#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR(Class)
304 template<> QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer();
306#define QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(Class, ExportMacro)
307 template<> ExportMacro QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer();
309#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
310 template<> QExplicitlySharedDataPointer<Class>::~QExplicitlySharedDataPointer()
312 if (d && !d->ref.deref())
constexpr QAtomicInt(int value=0) noexcept
Constructs a QAtomicInt with the given value.
\macro Q_ATOMIC_INTnn_IS_SUPPORTED
QAtomicPointer(const QAtomicPointer< T > &other) noexcept
Constructs a copy of other.
QAtomicPointer< T > & operator=(const QAtomicPointer< T > &other) noexcept
Assigns other to this QAtomicPointer and returns a reference to this QAtomicPointer.
constexpr QAtomicPointer(T *value=nullptr) noexcept
Constructs a QAtomicPointer with the given value.
const T * constData() const noexcept
Returns a const pointer to the shared data object.
~QExplicitlySharedDataPointer()
Decrements the reference count of the shared data object.
T Type
This is the type of the shared data object.
void reset(T *ptr=nullptr) noexcept
operator const T *() const noexcept
T * operator->() noexcept
Provides access to the shared data object's members.
T * operator->() const noexcept
Provides const access to the shared data object's members.
QExplicitlySharedDataPointer & operator=(const QExplicitlySharedDataPointer &o) noexcept
Sets the {d pointer} of this to the {d pointer} of o and increments the reference count of the shared...
T * data() const noexcept
Returns a pointer to the shared data object.
friend Qt::strong_ordering compareThreeWay(const QExplicitlySharedDataPointer &lhs, const QExplicitlySharedDataPointer &rhs) noexcept
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
T & operator*() const
Provides access to the shared data object's members.
friend bool comparesEqual(const QExplicitlySharedDataPointer &lhs, const QExplicitlySharedDataPointer &rhs) noexcept
QExplicitlySharedDataPointer & operator=(T *o) noexcept
Sets the {d pointer} of this to o and increments {o}'s reference count.
QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data, std::unique_ptr< QAbstractFileEngine > engine)
bool const isDefaultConstructed
QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data)
Ret checkAttribute(QFileSystemMetaData::MetaDataFlags fsFlags, FSLambda fsLambda, EngineLambda engineLambda) const
QFileSystemMetaData metaData
QDateTime & getFileTime(QFile::FileTime) const
std::unique_ptr< QAbstractFileEngine > const fileEngine
uint getFileFlags(QAbstractFileEngine::FileFlags) const
void setCachedFlag(uint c) const
QString getFileOwner(QAbstractFileEngine::FileOwner own) const
bool getCachedFlag(uint c) const
QFileInfoPrivate(const QFileInfoPrivate ©)
QFileSystemEntry fileEntry
static QFileInfoPrivate * get(QFileInfo *fi)
QString getFileName(QAbstractFileEngine::FileName) const
QString fileNames[QAbstractFileEngine::NFileNames]
QFileInfoPrivate(const QString &file)
Ret checkAttribute(Ret defaultValue, QFileSystemMetaData::MetaDataFlags fsFlags, FSLambda fsLambda, EngineLambda engineLambda) const
T & operator*()
Provides access to the shared data object's members.
const T * get() const noexcept
T * data()
Returns a pointer to the shared data object.
Q_NODISCARD_CTOR QSharedDataPointer() noexcept
Constructs a QSharedDataPointer initialized with \nullptr as {d pointer}.
~QSharedDataPointer()
Decrements the reference count of the shared data object.
QSharedDataPointer & operator=(const QSharedDataPointer &o) noexcept
Sets the {d pointer} of this to the {d pointer} of o and increments the reference count of the shared...
T Type
This is the type of the shared data object.
void reset(T *ptr=nullptr) noexcept
operator const T *() const noexcept
Returns a pointer to the shared data object.
friend Qt::strong_ordering compareThreeWay(const QSharedDataPointer &lhs, const QSharedDataPointer &rhs) noexcept
friend bool comparesEqual(const QSharedDataPointer &lhs, const QSharedDataPointer &rhs) noexcept
const T * data() const noexcept
Returns a pointer to the shared data object.
operator T*()
Returns a pointer to the shared data object.
const T * operator->() const noexcept
Provides const access to the shared data object's members.
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
const T & operator*() const
Provides const access to the shared data object's members.
const T * constData() const noexcept
Returns a const pointer to the shared data object.
QSharedDataPointer & operator=(T *o) noexcept
Sets the {d pointer} og this to o and increments {o}'s reference count.
T * operator->()
Provides access to the shared data object's members.
QSharedData() noexcept
Constructs a QSharedData object with a reference count of 0.
QSharedData & operator=(const QSharedData &)=delete
QSharedData(const QSharedData &) noexcept
Constructs a QSharedData object with reference count 0.
Combined button and popup list for selecting options.
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
Q_DECLARE_TYPEINFO_BODY(QExplicitlySharedDataPointer< T >, Q_RELOCATABLE_TYPE)
void swap(QExplicitlySharedDataPointer< T > &p1, QExplicitlySharedDataPointer< T > &p2) noexcept
void swap(QSharedDataPointer< T > &p1, QSharedDataPointer< T > &p2) noexcept
Q_DECLARE_TYPEINFO_BODY(QSharedDataPointer< T >, Q_RELOCATABLE_TYPE)
size_t qHash(const QSharedDataPointer< T > &ptr, size_t seed=0) noexcept
size_t qHash(const QExplicitlySharedDataPointer< T > &ptr, size_t seed=0) noexcept
\inmodule QtCore \threadsafe