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
qndefrecord.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
5#include "qndefrecord.h"
6#include "qndefrecord_p.h"
7
8#include <QtCore/QHash>
9
11
117size_t qHash(const QNdefRecord &key)
118{
119 return qHash(key.type() + key.id() + key.payload());
120}
121
128
133{
134 d = other.d;
135}
136
145 const QByteArray &type)
146{
147 if (other.d->typeNameFormat == quint8(typeNameFormat) && other.d->type == type) {
148 d = other.d;
149 } else {
150 d = new QNdefRecordPrivate;
152 d->type = type;
153 }
154}
155
164{
165 if (other.d->typeNameFormat == quint8(typeNameFormat)) {
166 d = other.d;
167 } else {
168 d = new QNdefRecordPrivate;
170 }
171}
172
181{
183 d->type = type;
184}
185
192
197{
198 if (this != &other)
199 d = other.d;
200
201 return *this;
202}
203
208{
209 if (!d)
210 d = new QNdefRecordPrivate;
211
213}
214
219{
220 if (!d)
221 return Empty;
222
223 if (d->typeNameFormat > 0x05)
224 return Unknown;
225
227}
228
233{
234 if (!d)
235 d = new QNdefRecordPrivate;
236
237 d->type = type;
238}
239
244{
245 if (!d)
246 return QByteArray();
247
248 return d->type;
249}
250
255{
256 if (!d)
257 d = new QNdefRecordPrivate;
258
259 d->id = id;
260}
261
266{
267 if (!d)
268 return QByteArray();
269
270 return d->id;
271}
272
277{
278 if (!d)
279 d = new QNdefRecordPrivate;
280
281 d->payload = payload;
282}
283
288{
289 if (!d)
290 return QByteArray();
291
292 return d->payload;
293}
294
302{
303 if (!d)
304 return true;
305
306 return d->payload.isEmpty();
307}
308
314{
315 if (d == other.d)
316 return true;
317
318 if (!d || !other.d)
319 return false;
320
321 if (d->typeNameFormat != other.d->typeNameFormat)
322 return false;
323
324 if (d->type != other.d->type)
325 return false;
326
327 if (d->id != other.d->id)
328 return false;
329
330 if (d->payload != other.d->payload)
331 return false;
332
333 return true;
334}
335
345{
346 if (d) {
347 d->typeNameFormat = 0;
348 d->type.clear();
349 d->id.clear();
350 d->payload.clear();
351 }
352}
353
\inmodule QtCore
Definition qbytearray.h:57
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
Definition qbytearray.h:107
void clear()
Clears the contents of the byte array and makes it null.
unsigned int typeNameFormat
The QNdefRecord class provides an NFC NDEF record.
Definition qndefrecord.h:16
void setPayload(const QByteArray &payload)
Sets the payload of the NDEF record to payload.
TypeNameFormat typeNameFormat() const
Returns the type name format of the NDEF record.
void setId(const QByteArray &id)
Sets the id of the NDEF record to id.
~QNdefRecord()
Destroys the NDEF record.
QNdefRecord & operator=(const QNdefRecord &other)
Assigns this NDEF record to other.
TypeNameFormat
This enum describes the type name format of an NDEF record.
Definition qndefrecord.h:18
QByteArray id() const
Returns the id of the NDEF record.
QByteArray type() const
Returns the type of the NDEF record.
QNdefRecord()
Constructs a new empty NDEF record.
bool operator==(const QNdefRecord &other) const
Returns true if other and this NDEF record are the same.
QByteArray payload() const
Returns the payload of the NDEF record.
size_t qHash(const QNdefRecord &key)
\macro Q_DECLARE_NDEF_RECORD(className, typeNameFormat, type, initialPayload)
void setType(const QByteArray &type)
Sets the type of the NDEF record to type.
bool isEmpty() const
Returns true if the NDEF record contains an empty payload; otherwise returns false.
void setTypeNameFormat(TypeNameFormat typeNameFormat)
Sets the type name format of the NDEF record to typeNameFormat.
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
size_t qHash(const QFileSystemWatcherPathKey &key, size_t seed=0)
GLuint64 key
GLenum type
unsigned char quint8
Definition qtypes.h:46
QSharedPointer< T > other(t)
[5]