Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QArrayDataPointer< T > Struct Template Reference

#include <qarraydatapointer.h>

Collaboration diagram for QArrayDataPointer< T >:

Public Types

enum  { pass_parameter_by_value }
typedef std::conditional< pass_parameter_by_value, T, constT & >::type parameter_type

Public Member Functions

Q_NODISCARD_CTOR constexpr QArrayDataPointer ()=default
Q_NODISCARD_CTOR Q_DECL_CONSTEXPR_DTOR QArrayDataPointer (const QArrayDataPointer &other) noexcept
Q_NODISCARD_CTOR constexpr QArrayDataPointer (Data *header, T *adata, qsizetype n=0) noexcept
Q_NODISCARD_CTOR QArrayDataPointer (QTypedArrayAllocationResult< T > adata, qsizetype n=0) noexcept
Q_NODISCARD_CTOR QArrayDataPointer (qsizetype alloc, qsizetype n=0, QArrayData::AllocationOption option=QArrayData::KeepSize)
Q_DECL_CONSTEXPR_DTOR QArrayDataPointeroperator= (const QArrayDataPointer &other) noexcept
Q_NODISCARD_CTOR constexpr QArrayDataPointer (QArrayDataPointer &&other) noexcept
Q_DECL_CONSTEXPR_DTOR DataOps operator* () noexcept
DataOps operator-> () noexcept
Q_DECL_CONSTEXPR_DTOR ~QArrayDataPointer ()
void destroyAndDeallocate ()
constexpr bool isNull () const noexcept
T * data () noexcept
constexpr const T * data () const noexcept
T * begin () noexcept
T * end () noexcept
constexpr const T * begin () const noexcept
constexpr const T * end () const noexcept
constexpr const T * constBegin () const noexcept
constexpr const T * constEnd () const noexcept
constexpr void swap (QArrayDataPointer &other) noexcept
void clear () noexcept(std::is_nothrow_destructible< T >::value)
void detach (QArrayDataPointer *old=nullptr)
template<typename X>
QArrayDataPointer< Xreinterpreted () &&
void detachAndGrow (QArrayData::GrowthPosition where, qsizetype n, const T **data, QArrayDataPointer *old)
Q_NEVER_INLINE void reallocateAndGrow (QArrayData::GrowthPosition where, qsizetype n, QArrayDataPointer *old=nullptr)
bool tryReadjustFreeSpace (QArrayData::GrowthPosition pos, qsizetype n, const T **data=nullptr)
void relocate (qsizetype offset, const T **data=nullptr)
QArrayDataPointer sliced (qsizetype pos, qsizetype n) const &
QArrayDataPointer sliced (qsizetype pos, qsizetype n) &&
void appendInitialize (qsizetype newSize)
constexpr qsizetype allocatedCapacity () noexcept
constexpr qsizetype constAllocatedCapacity () const noexcept
constexpr void ref () noexcept
constexpr bool deref () noexcept
constexpr bool isMutable () const noexcept
constexpr bool isShared () const noexcept
constexpr bool isSharedWith (const QArrayDataPointer &other) const noexcept
constexpr bool needsDetach () const noexcept
constexpr qsizetype detachCapacity (qsizetype newSize) const noexcept
constexpr const Data::ArrayOptions flags () const noexcept
void setFlag (typename Data::ArrayOptions f) noexcept
void clearFlag (typename Data::ArrayOptions f) noexcept
constexpr Datad_ptr () noexcept
constexpr void setBegin (T *begin) noexcept
constexpr qsizetype freeSpaceAtBegin () const noexcept
constexpr qsizetype freeSpaceAtEnd () const noexcept

Static Public Member Functions

static Q_NODISCARD_CTOR QArrayDataPointer fromRawData (const T *rawData, qsizetype length) noexcept
static QArrayDataPointer allocateGrow (const QArrayDataPointer &from, qsizetype n, QArrayData::GrowthPosition position)

Public Attributes

T * ptr = nullptr
qsizetype size = 0
Datad = nullptr

Friends

bool operator== (const QArrayDataPointer &lhs, const QArrayDataPointer &rhs) noexcept
bool operator!= (const QArrayDataPointer &lhs, const QArrayDataPointer &rhs) noexcept

Detailed Description

template<class T>
struct QArrayDataPointer< T >

Definition at line 16 of file qarraydatapointer.h.

Member Typedef Documentation

◆ parameter_type

template<class T>
typedef std::conditional<pass_parameter_by_value,T,constT&>::type QArrayDataPointer< T >::parameter_type

Definition at line 31 of file qarraydatapointer.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T>
anonymous enum
Enumerator
pass_parameter_by_value 

Definition at line 23 of file qarraydatapointer.h.

Constructor & Destructor Documentation

◆ QArrayDataPointer() [1/6]

template<class T>
Q_NODISCARD_CTOR constexpr QArrayDataPointer< T >::QArrayDataPointer ( )
constexprdefault

◆ QArrayDataPointer() [2/6]

template<class T>
Q_NODISCARD_CTOR Q_DECL_CONSTEXPR_DTOR QArrayDataPointer< T >::QArrayDataPointer ( const QArrayDataPointer< T > & other)
inlinenoexcept

Definition at line 38 of file qarraydatapointer.h.

◆ QArrayDataPointer() [3/6]

template<class T>
Q_NODISCARD_CTOR constexpr QArrayDataPointer< T >::QArrayDataPointer ( Data * header,
T * adata,
qsizetype n = 0 )
inlineconstexprnoexcept

Definition at line 45 of file qarraydatapointer.h.

◆ QArrayDataPointer() [4/6]

template<class T>
Q_NODISCARD_CTOR QArrayDataPointer< T >::QArrayDataPointer ( QTypedArrayAllocationResult< T > adata,
qsizetype n = 0 )
inlineexplicitnoexcept

Definition at line 55 of file qarraydatapointer.h.

◆ QArrayDataPointer() [5/6]

template<class T>
Q_NODISCARD_CTOR QArrayDataPointer< T >::QArrayDataPointer ( qsizetype alloc,
qsizetype n = 0,
QArrayData::AllocationOption option = QArrayData::KeepSize )
inlineexplicit

Definition at line 61 of file qarraydatapointer.h.

◆ QArrayDataPointer() [6/6]

template<class T>
Q_NODISCARD_CTOR constexpr QArrayDataPointer< T >::QArrayDataPointer ( QArrayDataPointer< T > && other)
inlineconstexprnoexcept

Definition at line 84 of file qarraydatapointer.h.

◆ ~QArrayDataPointer()

template<class T>
Q_DECL_CONSTEXPR_DTOR QArrayDataPointer< T >::~QArrayDataPointer ( )
inline

Definition at line 105 of file qarraydatapointer.h.

Member Function Documentation

◆ allocatedCapacity()

template<class T>
qsizetype QArrayDataPointer< T >::allocatedCapacity ( )
inlineconstexprnoexcept

Definition at line 365 of file qarraydatapointer.h.

◆ allocateGrow()

template<class T>
QArrayDataPointer QArrayDataPointer< T >::allocateGrow ( const QArrayDataPointer< T > & from,
qsizetype n,
QArrayData::GrowthPosition position )
inlinestatic

Definition at line 401 of file qarraydatapointer.h.

◆ appendInitialize()

template<class T>
void QArrayDataPointer< T >::appendInitialize ( qsizetype newSize)
inline

Definition at line 351 of file qarraydatapointer.h.

◆ begin() [1/2]

template<class T>
const T * QArrayDataPointer< T >::begin ( ) const
inlineconstexprnoexcept

Definition at line 129 of file qarraydatapointer.h.

◆ begin() [2/2]

template<class T>
T * QArrayDataPointer< T >::begin ( )
inlinenoexcept

Definition at line 126 of file qarraydatapointer.h.

◆ clear()

template<class T>
void QArrayDataPointer< T >::clear ( )
inlinenoexcept

Definition at line 144 of file qarraydatapointer.h.

◆ clearFlag()

template<class T>
void QArrayDataPointer< T >::clearFlag ( typename Data::ArrayOptions f)
inlinenoexcept

Definition at line 381 of file qarraydatapointer.h.

◆ constAllocatedCapacity()

template<class T>
qsizetype QArrayDataPointer< T >::constAllocatedCapacity ( ) const
inlineconstexprnoexcept

Definition at line 367 of file qarraydatapointer.h.

◆ constBegin()

template<class T>
const T * QArrayDataPointer< T >::constBegin ( ) const
inlineconstexprnoexcept

Definition at line 133 of file qarraydatapointer.h.

◆ constEnd()

template<class T>
const T * QArrayDataPointer< T >::constEnd ( ) const
inlineconstexprnoexcept

Definition at line 135 of file qarraydatapointer.h.

◆ d_ptr()

template<class T>
Data * QArrayDataPointer< T >::d_ptr ( )
inlineconstexprnoexcept

Definition at line 383 of file qarraydatapointer.h.

◆ data() [1/2]

template<class T>
const T * QArrayDataPointer< T >::data ( ) const
inlineconstexprnoexcept

Definition at line 124 of file qarraydatapointer.h.

◆ data() [2/2]

template<class T>
T * QArrayDataPointer< T >::data ( )
inlinenoexcept

Definition at line 123 of file qarraydatapointer.h.

◆ deref()

template<class T>
bool QArrayDataPointer< T >::deref ( )
inlineconstexprnoexcept

Definition at line 369 of file qarraydatapointer.h.

◆ destroyAndDeallocate()

template<class T>
void QArrayDataPointer< T >::destroyAndDeallocate ( )
inline

Definition at line 112 of file qarraydatapointer.h.

◆ detach()

template<class T>
void QArrayDataPointer< T >::detach ( QArrayDataPointer< T > * old = nullptr)
inline

Definition at line 150 of file qarraydatapointer.h.

◆ detachAndGrow()

template<class T>
void QArrayDataPointer< T >::detachAndGrow ( QArrayData::GrowthPosition where,
qsizetype n,
const T ** data,
QArrayDataPointer< T > * old )
inline

Detaches this (optionally) and grows to accommodate the free space for n elements at the required side. The side is determined from pos.

data pointer can be provided when the caller knows that data points into range [this->begin(), this->end()). In case it is, *data would be updated so that it continues to point to the element it was pointing to before the data move. if data does not point into range, one can/should pass nullptr.

Similarly to data, old, pointer to a default-constructed QADP, can be provided when the caller expects to e.g. copy the data from this to itself:

qsizetype pos = getArbitraryPos();
list.insert(pos, list.begin(), list.end());
Definition qlist.h:82
ptrdiff_t qsizetype
Definition qtypes.h:184
QList< int > list
[14]

The default rule would be: data and old must either both be valid pointers, or both equal to nullptr.

Definition at line 201 of file qarraydatapointer.h.

◆ detachCapacity()

template<class T>
qsizetype QArrayDataPointer< T >::detachCapacity ( qsizetype newSize) const
inlineconstexprnoexcept

Definition at line 377 of file qarraydatapointer.h.

◆ end() [1/2]

template<class T>
const T * QArrayDataPointer< T >::end ( ) const
inlineconstexprnoexcept

Definition at line 131 of file qarraydatapointer.h.

◆ end() [2/2]

template<class T>
T * QArrayDataPointer< T >::end ( )
inlinenoexcept

Definition at line 127 of file qarraydatapointer.h.

◆ flags()

template<class T>
const Data::ArrayOptions QArrayDataPointer< T >::flags ( ) const
inlineconstexprnoexcept

Definition at line 379 of file qarraydatapointer.h.

◆ freeSpaceAtBegin()

template<class T>
qsizetype QArrayDataPointer< T >::freeSpaceAtBegin ( ) const
inlineconstexprnoexcept

Definition at line 386 of file qarraydatapointer.h.

◆ freeSpaceAtEnd()

template<class T>
qsizetype QArrayDataPointer< T >::freeSpaceAtEnd ( ) const
inlineconstexprnoexcept

Definition at line 393 of file qarraydatapointer.h.

◆ fromRawData()

template<class T>
Q_NODISCARD_CTOR QArrayDataPointer QArrayDataPointer< T >::fromRawData ( const T * rawData,
qsizetype length )
inlinestaticnoexcept

Definition at line 68 of file qarraydatapointer.h.

◆ isMutable()

template<class T>
bool QArrayDataPointer< T >::isMutable ( ) const
inlineconstexprnoexcept

Definition at line 371 of file qarraydatapointer.h.

◆ isNull()

template<class T>
bool QArrayDataPointer< T >::isNull ( ) const
inlineconstexprnoexcept

Definition at line 118 of file qarraydatapointer.h.

◆ isShared()

template<class T>
bool QArrayDataPointer< T >::isShared ( ) const
inlineconstexprnoexcept

Definition at line 372 of file qarraydatapointer.h.

◆ isSharedWith()

template<class T>
bool QArrayDataPointer< T >::isSharedWith ( const QArrayDataPointer< T > & other) const
inlineconstexprnoexcept

Definition at line 374 of file qarraydatapointer.h.

◆ needsDetach()

template<class T>
bool QArrayDataPointer< T >::needsDetach ( ) const
inlineconstexprnoexcept

Definition at line 375 of file qarraydatapointer.h.

◆ operator*()

template<class T>
Q_DECL_CONSTEXPR_DTOR DataOps QArrayDataPointer< T >::operator* ( )
inlinenoexcept

Definition at line 94 of file qarraydatapointer.h.

◆ operator->()

template<class T>
DataOps QArrayDataPointer< T >::operator-> ( )
inlinenoexcept

Definition at line 99 of file qarraydatapointer.h.

◆ operator=()

template<class T>
Q_DECL_CONSTEXPR_DTOR QArrayDataPointer & QArrayDataPointer< T >::operator= ( const QArrayDataPointer< T > & other)
inlinenoexcept

Definition at line 75 of file qarraydatapointer.h.

◆ reallocateAndGrow()

template<class T>
Q_NEVER_INLINE void QArrayDataPointer< T >::reallocateAndGrow ( QArrayData::GrowthPosition where,
qsizetype n,
QArrayDataPointer< T > * old = nullptr )
inline

Reallocates to accommodate the free space for n elements at the required side. The side is determined from pos. Might also shrink when n < 0.

Definition at line 226 of file qarraydatapointer.h.

◆ ref()

template<class T>
void QArrayDataPointer< T >::ref ( )
inlineconstexprnoexcept

Definition at line 368 of file qarraydatapointer.h.

◆ reinterpreted()

template<class T>
template<typename X>
QArrayDataPointer< X > QArrayDataPointer< T >::reinterpreted ( ) &&
inline

Reinterprets the data of this QArrayDataPointer to type X. It's the caller's responsibility to ensure that the data contents are valid and properly aligned, particularly if T and X are not trivial types (i.e, don't do that). The current size is kept and the allocated capacity is updated to account for the difference in the element type's size.

This is used in QString::fromLatin1 to perform in-place conversion of QString to QByteArray.

Definition at line 167 of file qarraydatapointer.h.

◆ relocate()

template<class T>
void QArrayDataPointer< T >::relocate ( qsizetype offset,
const T ** data = nullptr )
inline

Relocates [begin(), end()) by offset and updates data if it is not nullptr and points into [begin(), end()).

Definition at line 321 of file qarraydatapointer.h.

◆ setBegin()

template<class T>
void QArrayDataPointer< T >::setBegin ( T * begin)
inlineconstexprnoexcept

Definition at line 384 of file qarraydatapointer.h.

◆ setFlag()

template<class T>
void QArrayDataPointer< T >::setFlag ( typename Data::ArrayOptions f)
inlinenoexcept

Definition at line 380 of file qarraydatapointer.h.

◆ sliced() [1/2]

template<class T>
QArrayDataPointer QArrayDataPointer< T >::sliced ( qsizetype pos,
qsizetype n ) &&
inline

Definition at line 339 of file qarraydatapointer.h.

◆ sliced() [2/2]

template<class T>
QArrayDataPointer QArrayDataPointer< T >::sliced ( qsizetype pos,
qsizetype n ) const &
inline

Definition at line 331 of file qarraydatapointer.h.

◆ swap()

template<class T>
void QArrayDataPointer< T >::swap ( QArrayDataPointer< T > & other)
inlineconstexprnoexcept

Definition at line 137 of file qarraydatapointer.h.

◆ tryReadjustFreeSpace()

template<class T>
bool QArrayDataPointer< T >::tryReadjustFreeSpace ( QArrayData::GrowthPosition pos,
qsizetype n,
const T ** data = nullptr )
inline

Attempts to relocate [begin(), end()) to accommodate the free space for n elements at the required side. The side is determined from pos.

Returns true if the internal data is moved. Returns false when there is no point in moving the data or the move is impossible. If false is returned, it is the responsibility of the caller to figure out how to accommodate the free space for n elements at pos.

This function expects that certain preconditions are met, e.g. the detach is not needed, n > 0 and so on. This is intentional to reduce the number of if-statements when the caller knows that preconditions would be satisfied.

See also
reallocateAndGrow

Definition at line 277 of file qarraydatapointer.h.

◆ operator!=

template<class T>
bool operator!= ( const QArrayDataPointer< T > & lhs,
const QArrayDataPointer< T > & rhs )
friend

Definition at line 432 of file qarraydatapointer.h.

◆ operator==

template<class T>
bool operator== ( const QArrayDataPointer< T > & lhs,
const QArrayDataPointer< T > & rhs )
friend

Definition at line 427 of file qarraydatapointer.h.

Member Data Documentation

◆ d

template<class T>
Data* QArrayDataPointer< T >::d = nullptr

Definition at line 443 of file qarraydatapointer.h.

◆ ptr

template<class T>
T* QArrayDataPointer< T >::ptr = nullptr

Definition at line 440 of file qarraydatapointer.h.

◆ size

template<class T>
qsizetype QArrayDataPointer< T >::size = 0

Definition at line 441 of file qarraydatapointer.h.


The documentation for this struct was generated from the following files: