Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qssgdataref_p.h
Go to the documentation of this file.
1
// Copyright (C) 2008-2012 NVIDIA Corporation.
2
// Copyright (C) 2019 The Qt Company Ltd.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
7
#
ifndef
QSSGDATAREF_H
8
#
define
QSSGDATAREF_H
9
10
//
11
// W A R N I N G
12
// -------------
13
//
14
// This file is not part of the Qt API. It exists purely as an
15
// implementation detail. This header file may change from version to
16
// version without notice, or even be removed.
17
//
18
// We mean it.
19
//
20
21
#
include
<
QtQuick3DUtils
/
private
/
qtquick3dutilsglobal_p
.
h
>
22
23
#
include
<
QtCore
/
qlist
.
h
>
24
#
include
<
QtCore
/
qbytearray
.
h
>
25
26
QT_BEGIN_NAMESPACE
27
28
template
<
typename
T>
29
struct
QSSGDataView
30
{
31
const
T *mData;
32
qsizetype mSize;
33
34
explicit
QSSGDataView(
const
QList<T> &data) : mData(data.constData()), mSize(data.size()) { Q_ASSERT(mSize >= 0); }
35
template
<qsizetype N>
36
explicit
QSSGDataView(
const
QVarLengthArray<T, N> &data) : mData(data.constData()), mSize(data.size()) { Q_ASSERT(mSize >= 0); }
37
QSSGDataView(
const
T *inData, qsizetype inSize) : mData(inData), mSize(inSize) { Q_ASSERT(mSize >= 0); }
38
constexpr
QSSGDataView() : mData(
nullptr
), mSize(0) {}
39
40
qsizetype size()
const
{
return
mSize; }
41
42
const
T *begin()
const
{
return
mData; }
43
const
T *end()
const
{
return
mData + mSize; }
44
45
const
T& first()
const
{ Q_ASSERT(!isEmpty());
return
*begin(); }
46
const
T& last()
const
{ Q_ASSERT(!isEmpty());
return
*(end()-1); }
47
48
const
T &operator[](
int
index)
const
49
{
50
Q_ASSERT(index > -1);
51
Q_ASSERT(index < mSize);
52
return
mData[index];
53
}
54
55
bool
isEmpty()
const
{
return
(mSize == 0); }
56
57
void
clear()
58
{
59
mData =
nullptr
;
60
mSize = 0;
61
}
62
63
operator
const
void
*() {
return
reinterpret_cast
<
const
void
*>(mData); }
64
};
65
66
template
<>
67
struct
QSSGDataView
<
quint8
>
68
{
69
const
quint8
*
mData
;
70
qsizetype
mSize
;
71
72
explicit
QSSGDataView
(
const
QByteArray &data)
73
:
mData
(
reinterpret_cast
<
const
quint8
*>(
data
.
constBegin
())),
mSize
(
data
.
size
())
74
{ Q_ASSERT(mSize >= 0); }
75
template
<
typename
T>
76
explicit
QSSGDataView
(
const
QList<T> &data)
77
:
mData
(
reinterpret_cast
<
const
quint8
*>(
data
.
constData
())),
mSize
(
data
.
size
()*
sizeof
(
T
))
78
{ Q_ASSERT(mSize >= 0); }
79
QSSGDataView
(
const
quint8 *inData, qsizetype inSize) :
mData
(
inData
),
mSize
(
inSize
) { Q_ASSERT(mSize >= 0); }
80
template
<
typename
T>
81
QSSGDataView
(
const
T *inData, qsizetype inSize)
82
:
mData
(
reinterpret_cast
<
const
quint8
*>(
inData
)),
mSize
(
inSize
*
sizeof
(
T
))
83
{ Q_ASSERT(mSize >= 0); }
84
constexpr
QSSGDataView
() :
mData
(
nullptr
),
mSize
(0) {}
85
86
qsizetype
size
()
const
{
return
mSize; }
87
bool
isEmpty
()
const
{
return
(mSize == 0); }
88
89
const
quint8
*
begin
()
const
{
return
mData; }
90
const
quint8
*
end
()
const
{
return
mData + mSize; }
91
92
const
quint8
&
operator
[](
int
index)
const
93
{
94
Q_ASSERT(index > -1);
95
Q_ASSERT(index < mSize);
96
return
mData[index];
97
}
98
99
void
clear
()
100
{
101
mData =
nullptr
;
102
mSize = 0;
103
}
104
105
operator
const
void
*() {
return
reinterpret_cast
<
const
void
*>(mData); }
106
};
107
108
using
QSSGByteView
=
QSSGDataView
<quint8>;
109
110
template
<
typename
T>
111
inline
QSSGDataView<T> toDataView(
const
T &type)
112
{
113
return
QSSGDataView<T>(&type, 1);
114
}
115
116
template
<
typename
T>
117
inline
QSSGDataView<T> toDataView(
const
QList<T> &type)
118
{
119
return
QSSGDataView<T>(type);
120
}
121
122
template
<
typename
T>
123
inline
QSSGByteView
toByteView
(
const
T &type)
124
{
125
return
QSSGByteView
(&type, 1);
126
}
127
128
template
<
typename
T>
129
inline
QSSGByteView
toByteView
(
const
QList<T> &type)
130
{
131
return
QSSGByteView
(type);
132
}
133
134
template
<>
135
inline
QSSGByteView
toByteView
(
const
QByteArray &type)
136
{
137
return
QSSGByteView
(type);
138
}
139
140
inline
QSSGByteView
toByteView
(
const
char
*str)
141
{
142
return
QSSGByteView
(str, qstrlen(str));
143
}
144
145
template
<
typename
T>
146
inline
QSSGDataView<T> toDataView(
const
T *type, qsizetype count)
147
{
148
return
QSSGDataView<T>(type, count);
149
}
150
151
template
<
typename
T>
152
inline
QSSGByteView
toByteView
(
const
T *type, qsizetype count)
153
{
154
return
QSSGByteView
(type, count);
155
}
156
157
template
<
typename
T>
158
struct
QSSGDataRef
159
{
160
T *
mData
;
161
qsizetype
mSize
;
162
163
QSSGDataRef
(T *inData, qsizetype inSize) :
mData
(inData),
mSize
(
inSize
) { Q_ASSERT(inSize >= 0); }
164
QSSGDataRef
() :
mData
(
nullptr
),
mSize
(0) {}
165
qsizetype
size
()
const
{
return
mSize; }
166
167
T *
begin
() {
return
mData
; }
168
T *
end
() {
return
mData
+ mSize; }
169
170
T *
begin
()
const
{
return
mData
; }
171
T *
end
()
const
{
return
mData
+ mSize; }
172
173
T&
first
() { Q_ASSERT(!
isEmpty
(
)
);
return
*begin(); }
174
T&
last
() { Q_ASSERT(!
isEmpty
(
)
);
return
*(end()-1); }
175
176
const
T &
first
()
const
{ Q_ASSERT(!
isEmpty
(
)
);
return
*begin(); }
177
const
T &
last
()
const
{ Q_ASSERT(!
isEmpty
(
)
);
return
*(end()-1); }
178
179
bool
isEmpty
()
const
{
return
(mSize == 0); }
180
181
T &
operator
[](qsizetype index)
182
{
183
Q_ASSERT(index >= 0);
184
Q_ASSERT(index < mSize);
185
return
mData
[index];
186
}
187
188
const
T &
operator
[](qsizetype index)
const
189
{
190
Q_ASSERT(index >= 0);
191
Q_ASSERT(index < mSize);
192
return
mData
[index];
193
}
194
195
void
clear
()
196
{
197
mData
=
nullptr
;
198
mSize = 0;
199
}
200
201
operator
QSSGDataView
<
T
>()
const
{
return
QSSGDataView
<
T
>(
mData
,
mSize
); }
202
operator
void
*() {
return
reinterpret_cast
<
void
*>(
mData
); }
203
};
204
205
using
QSSGByteRef = QSSGDataRef<quint8>;
206
207
template
<
typename
T>
208
inline
QSSGDataRef
<T>
toDataRef
(T &type)
209
{
210
return
QSSGDataRef
<T>(&type, 1);
211
}
212
213
template
<
typename
T>
214
inline
QSSGByteRef
toByteRef
(T &type)
215
{
216
return
QSSGByteRef(
reinterpret_cast
<quint8 *>(&type),
sizeof
(T));
217
}
218
219
template
<
typename
T>
220
inline
QSSGDataRef
<T>
toDataRef
(T *type, qsizetype count)
221
{
222
return
QSSGDataRef
<T>(type, count);
223
}
224
225
template
<
typename
T>
226
inline
QSSGByteRef
toByteRef
(T *type, qsizetype count)
227
{
228
return
QSSGByteRef(
reinterpret_cast
<quint8 *>(type),
sizeof
(T) * count);
229
}
230
231
QT_END_NAMESPACE
232
233
#
endif
// QSSGDATAREF_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
toByteRef
QSSGByteRef toByteRef(T &type)
Definition
qssgdataref_p.h:214
toByteView
QSSGByteView toByteView(const QList< T > &type)
Definition
qssgdataref_p.h:129
toByteView
QSSGByteView toByteView(const QByteArray &type)
Definition
qssgdataref_p.h:135
toByteView
QSSGByteView toByteView(const T &type)
Definition
qssgdataref_p.h:123
toByteView
QSSGByteView toByteView(const char *str)
Definition
qssgdataref_p.h:140
toDataRef
QSSGDataRef< T > toDataRef(T *type, qsizetype count)
Definition
qssgdataref_p.h:220
QSSGByteView
QSSGDataView< quint8 > QSSGByteView
Definition
qssgdataref_p.h:108
toByteRef
QSSGByteRef toByteRef(T *type, qsizetype count)
Definition
qssgdataref_p.h:226
toByteView
QSSGByteView toByteView(const T *type, qsizetype count)
Definition
qssgdataref_p.h:152
toDataRef
QSSGDataRef< T > toDataRef(T &type)
Definition
qssgdataref_p.h:208
QSSGDataRef
Definition
qssgdataref_p.h:159
QSSGDataRef::begin
T * begin() const
Definition
qssgdataref_p.h:170
QSSGDataRef::clear
void clear()
Definition
qssgdataref_p.h:195
QSSGDataRef::end
T * end()
Definition
qssgdataref_p.h:168
QSSGDataRef::end
T * end() const
Definition
qssgdataref_p.h:171
QSSGDataRef::mSize
qsizetype mSize
Definition
qssgdataref_p.h:161
QSSGDataRef::first
const T & first() const
Definition
qssgdataref_p.h:176
QSSGDataRef::begin
T * begin()
Definition
qssgdataref_p.h:167
QSSGDataRef::size
qsizetype size() const
Definition
qssgdataref_p.h:165
QSSGDataRef::last
const T & last() const
Definition
qssgdataref_p.h:177
QSSGDataRef::first
T & first()
Definition
qssgdataref_p.h:173
QSSGDataRef::mData
T * mData
Definition
qssgdataref_p.h:160
QSSGDataRef::isEmpty
bool isEmpty() const
Definition
qssgdataref_p.h:179
QSSGDataRef::operator[]
const T & operator[](qsizetype index) const
Definition
qssgdataref_p.h:188
QSSGDataRef::QSSGDataRef
QSSGDataRef()
Definition
qssgdataref_p.h:164
QSSGDataRef::operator[]
T & operator[](qsizetype index)
Definition
qssgdataref_p.h:181
QSSGDataRef::last
T & last()
Definition
qssgdataref_p.h:174
QSSGDataRef::QSSGDataRef
QSSGDataRef(T *inData, qsizetype inSize)
Definition
qssgdataref_p.h:163
QSSGDataView< quint8 >
Definition
qssgdataref_p.h:68
QSSGDataView< quint8 >::operator[]
const quint8 & operator[](int index) const
Definition
qssgdataref_p.h:92
QSSGDataView< quint8 >::QSSGDataView
QSSGDataView(const QByteArray &data)
Definition
qssgdataref_p.h:72
QSSGDataView< quint8 >::QSSGDataView
QSSGDataView(const T *inData, qsizetype inSize)
Definition
qssgdataref_p.h:81
QSSGDataView< quint8 >::size
qsizetype size() const
Definition
qssgdataref_p.h:86
QSSGDataView< quint8 >::mData
const quint8 * mData
Definition
qssgdataref_p.h:69
QSSGDataView< quint8 >::isEmpty
bool isEmpty() const
Definition
qssgdataref_p.h:87
QSSGDataView< quint8 >::QSSGDataView
QSSGDataView(const QList< T > &data)
Definition
qssgdataref_p.h:76
QSSGDataView< quint8 >::QSSGDataView
QSSGDataView(const quint8 *inData, qsizetype inSize)
Definition
qssgdataref_p.h:79
QSSGDataView< quint8 >::clear
void clear()
Definition
qssgdataref_p.h:99
QSSGDataView< quint8 >::end
const quint8 * end() const
Definition
qssgdataref_p.h:90
QSSGDataView< quint8 >::begin
const quint8 * begin() const
Definition
qssgdataref_p.h:89
QSSGDataView< quint8 >::mSize
qsizetype mSize
Definition
qssgdataref_p.h:70
QSSGDataView< quint8 >::operator const void *
operator const void *()
Definition
qssgdataref_p.h:105
QSSGDataView< quint8 >::QSSGDataView
constexpr QSSGDataView()
Definition
qssgdataref_p.h:84
qtquick3d
src
utils
qssgdataref_p.h
Generated on
for Qt by
1.18.0