Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qmetacontainer.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qmetacontainer.h"
5#include "qmetatype.h"
6
8
49{
50 if (!d_ptr)
51 return false;
53}
54
66{
67 if (!d_ptr)
68 return false;
70}
71
82{
83 if (!d_ptr)
84 return false;
86}
87
97{
98 if (!d_ptr)
99 return false;
101}
102
107{
108 if (auto iface = d())
110 return QMetaType();
111}
112
125{
126 if (auto iface = d()) {
132 }
133 return false;
134}
135
143{
144 if (auto iface = d()) {
145 return iface->addValueFn
147 }
148 return false;
149}
150
157void QMetaSequence::addValueAtBegin(void *container, const void *value) const
158{
159 if (canAddValueAtBegin())
161}
162
170{
171 if (auto iface = d()) {
172 return iface->removeValueFn
174 }
175 return false;
176}
177
184void QMetaSequence::removeValueAtBegin(void *container) const
185{
188}
189
197{
198 if (auto iface = d()) {
199 return iface->addValueFn
201 }
202 return false;
203}
204
211void QMetaSequence::addValueAtEnd(void *container, const void *value) const
212{
213 if (canAddValueAtEnd())
215}
216
224{
225 if (auto iface = d()) {
226 return iface->removeValueFn
228 }
229 return false;
230}
231
238void QMetaSequence::removeValueAtEnd(void *container) const
239{
242}
243
251{
252 return d_ptr && d_ptr->sizeFn;
253}
254
261qsizetype QMetaContainer::size(const void *container) const
262{
263 return hasSize() ? d_ptr->sizeFn(container) : -1;
264}
265
272{
273 return d_ptr && d_ptr->clearFn;
274}
275
281void QMetaContainer::clear(void *container) const
282{
283 if (canClear())
284 d_ptr->clearFn(container);
285}
286
294{
295 if (auto iface = d())
296 return iface->valueAtIndexFn;
297 return false;
298}
299
306void QMetaSequence::valueAtIndex(const void *container, qsizetype index, void *result) const
307{
308 if (canGetValueAtIndex())
309 d()->valueAtIndexFn(container, index, result);
310}
311
319{
320 if (auto iface = d())
321 return iface->setValueAtIndexFn;
322 return false;
323}
324
331void QMetaSequence::setValueAtIndex(void *container, qsizetype index, const void *value) const
332{
333 if (canSetValueAtIndex())
334 d()->setValueAtIndexFn(container, index, value);
335}
336
344{
345 if (auto iface = d())
346 return iface->addValueFn;
347 return false;
348}
349
363void QMetaSequence::addValue(void *container, const void *value) const
364{
365 if (canAddValue()) {
366 d()->addValueFn(container, value,
368 }
369}
370
378{
379 if (auto iface = d())
380 return iface->removeValueFn;
381 return false;
382}
383
395void QMetaSequence::removeValue(void *container) const
396{
397 if (canRemoveValue()) {
398 d()->removeValueFn(container,
400 }
401}
402
411{
412 if (!d_ptr || !d_ptr->createIteratorFn)
413 return false;
419 return true;
420}
421
431void *QMetaContainer::begin(void *container) const
432{
433 return hasIterator()
436 : nullptr;
437}
438
448void *QMetaContainer::end(void *container) const
449{
450 return hasIterator()
453 : nullptr;
454}
455
462void QMetaContainer::destroyIterator(const void *iterator) const
463{
464 if (hasIterator())
465 d_ptr->destroyIteratorFn(iterator);
466}
467
475bool QMetaContainer::compareIterator(const void *i, const void *j) const
476{
477 return hasIterator() ? d_ptr->compareIteratorFn(i, j) : false;
478}
479
486void QMetaContainer::copyIterator(void *target, const void *source) const
487{
488 if (hasIterator())
490}
491
500void QMetaContainer::advanceIterator(void *iterator, qsizetype step) const
501{
502 if (hasIterator())
503 d_ptr->advanceIteratorFn(iterator, step);
504}
505
514qsizetype QMetaContainer::diffIterator(const void *i, const void *j) const
515{
516 return hasIterator() ? d_ptr->diffIteratorFn(i, j) : 0;
517}
518
526{
527 if (auto iface = d())
528 return iface->valueAtIteratorFn;
529 return false;
530}
531
538void QMetaSequence::valueAtIterator(const void *iterator, void *result) const
539{
541 d()->valueAtIteratorFn(iterator, result);
542}
543
551{
552 if (auto iface = d())
554 return false;
555}
556
563void QMetaSequence::setValueAtIterator(const void *iterator, const void *value) const
564{
566 d()->setValueAtIteratorFn(iterator, value);
567}
568
576{
577 if (auto iface = d())
579 return false;
580}
581
594void QMetaSequence::insertValueAtIterator(void *container, const void *iterator,
595 const void *value) const
596{
598 d()->insertValueAtIteratorFn(container, iterator, value);
599}
600
608{
609 if (auto iface = d())
611 return false;
612}
613
620void QMetaSequence::eraseValueAtIterator(void *container, const void *iterator) const
621{
623 d()->eraseValueAtIteratorFn(container, iterator);
624}
625
631{
632 if (auto iface = d())
634 return false;
635}
636
643void QMetaSequence::eraseRangeAtIterator(void *container, const void *iterator1,
644 const void *iterator2) const
645{
647 d()->eraseRangeAtIteratorFn(container, iterator1, iterator2);
648}
649
659{
661 return false;
667 return true;
668}
669
679void *QMetaContainer::constBegin(const void *container) const
680{
681 return hasConstIterator()
684 : nullptr;
685}
686
696void *QMetaContainer::constEnd(const void *container) const
697{
698 return hasConstIterator()
701 : nullptr;
702}
703
710void QMetaContainer::destroyConstIterator(const void *iterator) const
711{
712 if (hasConstIterator())
713 d_ptr->destroyConstIteratorFn(iterator);
714}
715
723bool QMetaContainer::compareConstIterator(const void *i, const void *j) const
724{
725 return hasConstIterator() ? d_ptr->compareConstIteratorFn(i, j) : false;
726}
727
734void QMetaContainer::copyConstIterator(void *target, const void *source) const
735{
736 if (hasConstIterator())
738}
739
748void QMetaContainer::advanceConstIterator(void *iterator, qsizetype step) const
749{
750 if (hasConstIterator())
751 d_ptr->advanceConstIteratorFn(iterator, step);
752}
753
762qsizetype QMetaContainer::diffConstIterator(const void *i, const void *j) const
763{
764 return hasConstIterator() ? d_ptr->diffConstIteratorFn(i, j) : 0;
765}
766
774{
775 if (auto iface = d())
777 return false;
778}
779
786void QMetaSequence::valueAtConstIterator(const void *iterator, void *result) const
787{
789 d()->valueAtConstIteratorFn(iterator, result);
790}
791
815{
816 if (auto iface = d())
817 return QMetaType(iface->keyMetaType);
818 return QMetaType();
819}
820
825{
826 if (auto iface = d())
828 return QMetaType();
829}
830
QMetaType keyMetaType() const
Returns the meta type for keys in the container.
QMetaType mappedMetaType() const
Returns the meta type for mapped values in the container.
const QtMetaContainerPrivate::QMetaAssociationInterface * iface() const
void advanceConstIterator(void *iterator, qsizetype step) const
Advances the const iterator by step steps.
bool hasSize() const
Returns true if the container can be queried for its size, false otherwise.
void * constEnd(const void *container) const
Creates and returns a const iterator pointing to the end of container.
void clear(void *container) const
Clears the given container if it can be cleared.
bool compareIterator(const void *i, const void *j) const
Returns true if the non-const iterators i and j point to the same value in the container they are ite...
void copyConstIterator(void *target, const void *source) const
Copies the const iterator source into the const iterator target.
void copyIterator(void *target, const void *source) const
Copies the non-const iterator source into the non-const iterator target.
bool compareConstIterator(const void *i, const void *j) const
Returns true if the const iterators i and j point to the same value in the container they are iterati...
bool hasRandomAccessIterator() const
Returns true if the underlying container provides a random access iterator as defined by std::random_...
void destroyConstIterator(const void *iterator) const
Destroys a const iterator previously created using \l constBegin() or \l constEnd().
bool hasInputIterator() const
Returns true if the underlying container provides at least an input iterator as defined by std::input...
bool canClear() const
Returns true if the container can be cleared, false otherwise.
void advanceIterator(void *iterator, qsizetype step) const
Advances the non-const iterator by step steps.
void * constBegin(const void *container) const
Creates and returns a const iterator pointing to the beginning of container.
void * end(void *container) const
Creates and returns a non-const iterator pointing to the end of container.
void destroyIterator(const void *iterator) const
Destroys a non-const iterator previously created using \l begin() or \l end().
qsizetype diffConstIterator(const void *i, const void *j) const
Returns the distance between the const iterators i and j, the equivalent of i - j.
bool hasIterator() const
Returns true if the underlying container offers a non-const iterator, false otherwise.
void * begin(void *container) const
Creates and returns a non-const iterator pointing to the beginning of container.
bool hasBidirectionalIterator() const
Returns true if the underlying container provides a bi-directional iterator or a random access iterat...
bool hasForwardIterator() const
Returns true if the underlying container provides at least a forward iterator as defined by std::forw...
qsizetype diffIterator(const void *i, const void *j) const
Returns the distance between the non-const iterators i and j, the equivalent of i - j.
qsizetype size(const void *container) const
Returns the number of values in the given container if it can be queried for its size.
const QtMetaContainerPrivate::QMetaContainerInterface * d_ptr
bool hasConstIterator() const
Returns true if the underlying container offers a const iterator, false otherwise.
bool canSetValueAtIndex() const
Returns true if an value can be written to the container by index, otherwise false.
bool canAddValueAtEnd() const
Returns true if values added using \l addValue() can be placed at the end of the container,...
bool canRemoveValueAtBegin() const
Returns true if values can be removed from the beginning of the container using \l removeValue() can ...
void setValueAtIndex(void *container, qsizetype index, const void *value) const
Overwrites the value at index in the container using the value passed as parameter if that is possibl...
bool canGetValueAtIterator() const
Returns true if the underlying container can retrieve the value pointed to by a non-const iterator,...
void eraseValueAtIterator(void *container, const void *iterator) const
Erases the value pointed to by the non-const iterator from the container, if possible.
bool canEraseRangeAtIterator() const
Returns true if a range between two iterators can be erased from the container, false otherwise.
bool canGetValueAtIndex() const
Returns true if values can be retrieved from the container by index, otherwise false.
void removeValue(void *container) const
Removes an value from the container if possible.
void valueAtConstIterator(const void *iterator, void *result) const
Retrieves the value pointed to by the const iterator and stores it in the memory location pointed to ...
bool canEraseValueAtIterator() const
Returns true if the value pointed to by a non-const iterator can be erased, false otherwise.
bool canAddValueAtBegin() const
Returns true if values added using \l addValue() can be placed at the beginning of the container,...
bool canRemoveValueAtEnd() const
Returns true if values can be removed from the end of the container using \l removeValue() can be pla...
void addValueAtEnd(void *container, const void *value) const
Adds value to the end of container if possible.
void setValueAtIterator(const void *iterator, const void *value) const
Writes value to the value pointed to by the non-const iterator, if possible.
void addValue(void *container, const void *value) const
Adds value to the container if possible.
bool canRemoveValue() const
Returns true if values can be removed from the container, false otherwise.
void removeValueAtEnd(void *container) const
Removes a value from the end of container if possible.
bool canSetValueAtIterator() const
Returns true if the underlying container can write to the value pointed to by a non-const iterator,...
bool canGetValueAtConstIterator() const
Returns true if the underlying container can retrieve the value pointed to by a const iterator,...
void removeValueAtBegin(void *container) const
Removes a value from the beginning of container if possible.
const QtMetaContainerPrivate::QMetaSequenceInterface * iface() const
QMetaType valueMetaType() const
Returns the meta type for values stored in the container.
bool canAddValue() const
Returns true if values can be added to the container, false otherwise.
void eraseRangeAtIterator(void *container, const void *iterator1, const void *iterator2) const
Erases the range of values between the iterators iterator1 and iterator2 from the container,...
void valueAtIterator(const void *iterator, void *result) const
Retrieves the value pointed to by the non-const iterator and stores it in the memory location pointed...
void insertValueAtIterator(void *container, const void *iterator, const void *value) const
Inserts value into the container, if possible, taking the non-const iterator into account.
void valueAtIndex(const void *container, qsizetype index, void *result) const
Retrieves the value at index in the container and places it in the memory location pointed to by resu...
bool canInsertValueAtIterator() const
Returns true if the underlying container can insert a new value, taking the location pointed to by a ...
bool isSortable() const
Returns true if the underlying container is sortable, otherwise returns false.
void addValueAtBegin(void *container, const void *value) const
Adds value to the beginning of container if possible.
\inmodule QtCore
Definition qmetatype.h:320
const QtPrivate::QMetaTypeInterface * keyMetaType
const QtPrivate::QMetaTypeInterface * mappedMetaType
const QtPrivate::QMetaTypeInterface * valueMetaType
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint index
[2]
GLenum target
GLsizei GLsizei GLchar * source
GLuint64EXT * result
[6]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
ptrdiff_t qsizetype
Definition qtypes.h:70