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.h
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#ifndef QNDEFRECORD_H
5#define QNDEFRECORD_H
6
7#include <QtCore/QSharedDataPointer>
8#include <QtCore/QByteArray>
9#include <QtNfc/qtnfcglobal.h>
10
12
14
15class Q_NFC_EXPORT QNdefRecord
16{
17public:
19 Empty = 0x00,
20 NfcRtd = 0x01,
21 Mime = 0x02,
22 Uri = 0x03,
23 ExternalRtd = 0x04,
24 Unknown = 0x05
25 };
26
29
31 QNdefRecord &operator=(const QNdefRecord &other);
32
33 void setTypeNameFormat(TypeNameFormat typeNameFormat);
34 TypeNameFormat typeNameFormat() const;
35
36 void setType(const QByteArray &type);
37 QByteArray type() const;
38
39 void setId(const QByteArray &id);
40 QByteArray id() const;
41
42 void setPayload(const QByteArray &payload);
43 QByteArray payload() const;
44
45 bool isEmpty() const;
46
47 template <typename T>
48 inline bool isRecordType() const
49 {
50 T dummy;
51 return (typeNameFormat() == dummy.typeNameFormat() && type() == dummy.type());
52 }
53
54 bool operator==(const QNdefRecord &other) const;
55 inline bool operator!=(const QNdefRecord &other) const { return !operator==(other); }
56
57 void clear();
58
59protected:
60 QNdefRecord(const QNdefRecord &other, TypeNameFormat typeNameFormat, const QByteArray &type);
61 QNdefRecord(const QNdefRecord &other, TypeNameFormat typeNameFormat);
62 QNdefRecord(TypeNameFormat typeNameFormat, const QByteArray &type);
63
64private:
65 QSharedDataPointer<QNdefRecordPrivate> d;
66};
67
68#define Q_DECLARE_NDEF_RECORD(className, typeNameFormat, type, initialPayload) \
69 className() : QNdefRecord(typeNameFormat, type) { setPayload(initialPayload); } \
70 className(const QNdefRecord &other) : QNdefRecord(other, typeNameFormat, type) { }
71
72#define Q_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD(className, typeNameFormat_, type_) \
73 QT_BEGIN_NAMESPACE \
74 template<> inline bool QNdefRecord::isRecordType<className>() const\
75 { \
76 return (typeNameFormat() == typeNameFormat_ && type() == type_); \
77 } \
78 QT_END_NAMESPACE
79
80Q_NFC_EXPORT size_t qHash(const QNdefRecord &key);
81
83
84#endif // QNDEFRECORD_H
\inmodule QtCore
Definition qbytearray.h:57
The QNdefRecord class provides an NFC NDEF record.
Definition qndefrecord.h:16
bool operator!=(const QNdefRecord &other) const
Returns true if this NDEF record does not equal other; otherwise return false.
Definition qndefrecord.h:55
TypeNameFormat
This enum describes the type name format of an NDEF record.
Definition qndefrecord.h:18
bool isRecordType() const
Returns true if the NDEF record is of the specified record type; otherwise returns false.
Definition qndefrecord.h:48
b clear()
employee setId(37)
Combined button and popup list for selecting options.
Q_NFC_EXPORT size_t qHash(const QNdefRecord &key)
GLuint64 key
GLenum GLuint id
[7]
GLenum type
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
QSharedPointer< T > other(t)
[5]
proxy setType(QNetworkProxy::Socks5Proxy)