Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qglist_helper_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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#ifndef QGLIST_HELPER_P_H
5#define QGLIST_HELPER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qtconfigmacros.h>
19
20#include <glib.h>
21#include <iterator>
22
24
25namespace QGstUtils {
26
27template <typename ListType>
29{
30 explicit GListIterator(const GList *element = nullptr) : element(element) { }
31
32 const ListType &operator*() const noexcept { return *operator->(); }
33 const ListType *operator->() const noexcept
34 {
35 return reinterpret_cast<const ListType *>(&element->data);
36 }
37
39 {
40 if (element)
41 element = element->next;
42
43 return *this;
44 }
46 {
47 for (int i = 0; i != n; ++i)
48 operator++();
49
50 return *this;
51 }
52
53 bool operator==(const GListIterator &r) const noexcept { return element == r.element; }
54 bool operator!=(const GListIterator &r) const noexcept { return element != r.element; }
55
56 using difference_type = std::ptrdiff_t;
57 using value_type = ListType;
60 using iterator_category = std::input_iterator_tag;
61
62 const GList *element = nullptr;
63};
64
65template <typename ListType>
67{
68 static_assert(std::is_pointer_v<ListType>);
69
70 explicit GListRangeAdaptor(const GList *list) : head(list) { }
71
72 auto begin() { return GListIterator<ListType>(head); }
73 auto end() { return GListIterator<ListType>(nullptr); }
74
75 const GList *head;
76};
77
78} // namespace QGstUtils
79
81
82#endif
Combined button and popup list for selecting options.
GLboolean r
[2]
GLfloat n
QList< int > list
[14]
const ListType & operator*() const noexcept
const ListType * operator->() const noexcept
GListIterator & operator++() noexcept
std::ptrdiff_t difference_type
GListIterator operator++(int n) noexcept
std::input_iterator_tag iterator_category
GListIterator(const GList *element=nullptr)
bool operator!=(const GListIterator &r) const noexcept
bool operator==(const GListIterator &r) const noexcept
GListRangeAdaptor(const GList *list)