![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QNdefRecord class provides an NFC NDEF record. More...
#include <qndefrecord.h>
Public Types | |
enum | TypeNameFormat { Empty = 0x00 , NfcRtd = 0x01 , Mime = 0x02 , Uri = 0x03 , ExternalRtd = 0x04 , Unknown = 0x05 } |
This enum describes the type name format of an NDEF record. More... | |
Public Member Functions | |
QNdefRecord () | |
Constructs a new empty NDEF record. | |
~QNdefRecord () | |
Destroys the NDEF record. | |
QNdefRecord (const QNdefRecord &other) | |
Constructs a new NDEF record that is a copy of other. | |
QNdefRecord & | operator= (const QNdefRecord &other) |
Assigns this NDEF record to other. | |
void | setTypeNameFormat (TypeNameFormat typeNameFormat) |
Sets the type name format of the NDEF record to typeNameFormat. | |
TypeNameFormat | typeNameFormat () const |
Returns the type name format of the NDEF record. | |
void | setType (const QByteArray &type) |
Sets the type of the NDEF record to type. | |
QByteArray | type () const |
Returns the type of the NDEF record. | |
void | setId (const QByteArray &id) |
Sets the id of the NDEF record to id. | |
QByteArray | id () const |
Returns the id of the NDEF record. | |
void | setPayload (const QByteArray &payload) |
Sets the payload of the NDEF record to payload. | |
QByteArray | payload () const |
Returns the payload of the NDEF record. | |
bool | isEmpty () const |
Returns true if the NDEF record contains an empty payload; otherwise returns false . | |
template<typename T> | |
bool | isRecordType () const |
Returns true if the NDEF record is of the specified record type; otherwise returns false . | |
bool | operator== (const QNdefRecord &other) const |
Returns true if other and this NDEF record are the same. | |
bool | operator!= (const QNdefRecord &other) const |
Returns true if this NDEF record does not equal other; otherwise return false . | |
void | clear () |
Protected Member Functions | |
QNdefRecord (const QNdefRecord &other, TypeNameFormat typeNameFormat, const QByteArray &type) | |
QNdefRecord (const QNdefRecord &other, TypeNameFormat typeNameFormat) | |
QNdefRecord (TypeNameFormat typeNameFormat, const QByteArray &type) | |
Related Symbols | |
(Note that these are not member symbols.) | |
size_t | qHash (const QNdefRecord &key) |
\macro Q_DECLARE_NDEF_RECORD(className, typeNameFormat, type, initialPayload) | |
The QNdefRecord class provides an NFC NDEF record.
\inmodule QtNfc
QNdefRecord and derived classes are used to parse the contents of \l {QNdefMessage}{NDEF messages} and create new NDEF messages.
Use typeNameFormat() and setTypeNameFormat() to get and set the type name format of the NDEF record.
Use type() and setType() to get and set the type of the NDEF record.
Use id() and setId() to get and set the id of the NDEF record.
Use payload() and setPayload() to get and set the NDEF record payload. isEmpty() can be used to test if the payload is empty.
QNdefRecord is an implicitly shared class. This means you can efficiently convert between QNdefRecord and specialized record classes. The isRecordType() template function can be used to test if a conversion is possible. The following example shows how to test if a QNdefRecord is an NFC RTD Text record and extract the text information from it.
Definition at line 15 of file qndefrecord.h.
This enum describes the type name format of an NDEF record.
\value Empty An empty NDEF record, the record does not contain a payload \value NfcRtd The NDEF record type is defined by an NFC RTD Specification \value Mime The NDEF record type follows the construct described in RFC 2046 \value Uri The NDEF record type follows the construct described in RFC 3986 \value ExternalRtd The NDEF record type follows the construct for external type names described the NFC RTD Specification \value Unknown The type of the record is unknown and should be treated similar to content with MIME type 'application/octet-stream' without further context
Enumerator | |
---|---|
Empty | |
NfcRtd | |
Mime | |
Uri | |
ExternalRtd | |
Unknown |
Definition at line 18 of file qndefrecord.h.
QNdefRecord::QNdefRecord | ( | ) |
Constructs a new empty NDEF record.
Definition at line 125 of file qndefrecord.cpp.
QNdefRecord::~QNdefRecord | ( | ) |
Destroys the NDEF record.
Definition at line 189 of file qndefrecord.cpp.
QNdefRecord::QNdefRecord | ( | const QNdefRecord & | other | ) |
Constructs a new NDEF record that is a copy of other.
Definition at line 132 of file qndefrecord.cpp.
|
protected |
Constructs an NDEF record that is a copy of other if other is of the expected type name format identified by typeNameFormat and type as identified by type; otherwise an empty NDEF record of the expected type name format and type is created.
Definition at line 144 of file qndefrecord.cpp.
|
protected |
Constructs an NDEF record that is a copy of other if other is of the expected type name format identified by typeNameFormat; otherwise an empty NDEF record of the expected type name format and type is created.
Definition at line 163 of file qndefrecord.cpp.
|
protected |
Constructs an NDEF record with a type name format identified by typeNameFormat and type as identified by type.
Definition at line 179 of file qndefrecord.cpp.
void QNdefRecord::clear | ( | ) |
Clear the NDEF record.
An \l isEmpty() call returns true
for a cleared record. The record \l type() is set to \l {QNdefRecord::}{Empty}.
Definition at line 344 of file qndefrecord.cpp.
QByteArray QNdefRecord::id | ( | ) | const |
Returns the id of the NDEF record.
Definition at line 265 of file qndefrecord.cpp.
bool QNdefRecord::isEmpty | ( | ) | const |
Returns true
if the NDEF record contains an empty payload; otherwise returns false
.
This is equivalent to calling {payload()
.isEmpty()}.
Definition at line 301 of file qndefrecord.cpp.
|
inline |
Returns true
if the NDEF record is of the specified record type; otherwise returns false
.
Definition at line 48 of file qndefrecord.h.
|
inline |
Returns true
if this NDEF record does not equal other; otherwise return false
.
Definition at line 55 of file qndefrecord.h.
QNdefRecord & QNdefRecord::operator= | ( | const QNdefRecord & | other | ) |
Assigns this NDEF record to other.
Definition at line 196 of file qndefrecord.cpp.
bool QNdefRecord::operator== | ( | const QNdefRecord & | other | ) | const |
Returns true
if other and this NDEF record are the same.
Otherwise returns false
.
Definition at line 313 of file qndefrecord.cpp.
QByteArray QNdefRecord::payload | ( | ) | const |
Returns the payload of the NDEF record.
Definition at line 287 of file qndefrecord.cpp.
void QNdefRecord::setId | ( | const QByteArray & | id | ) |
Sets the id of the NDEF record to id.
Definition at line 254 of file qndefrecord.cpp.
void QNdefRecord::setPayload | ( | const QByteArray & | payload | ) |
Sets the payload of the NDEF record to payload.
Definition at line 276 of file qndefrecord.cpp.
void QNdefRecord::setType | ( | const QByteArray & | type | ) |
Sets the type of the NDEF record to type.
Definition at line 232 of file qndefrecord.cpp.
void QNdefRecord::setTypeNameFormat | ( | TypeNameFormat | typeNameFormat | ) |
Sets the type name format of the NDEF record to typeNameFormat.
Definition at line 207 of file qndefrecord.cpp.
QByteArray QNdefRecord::type | ( | ) | const |
Returns the type of the NDEF record.
Definition at line 243 of file qndefrecord.cpp.
QNdefRecord::TypeNameFormat QNdefRecord::typeNameFormat | ( | ) | const |
Returns the type name format of the NDEF record.
Definition at line 218 of file qndefrecord.cpp.
|
\macro Q_DECLARE_NDEF_RECORD(className, typeNameFormat, type, initialPayload)
This macro declares default and copy constructors for specialized NDEF record classes.
className is the name of the specialized class, typeNameFormat is the appropriate QNdefRecord::TypeNameFormat for the custom type and type is the type without the NID or NSS prefixes. That is {example.com:f} not {urn:nfc:ext:example.com:f}. initialPayload is the initial payload of an empty record, it must be a QByteArray or a type that can be implicitly converted into a QByteArray.
See the section on \l {Creating specialized NDEF record classes} for details.
\macro Q_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD(className, typeNameFormat, type)
This macro declares a template specialization for the QNdefRecord::isRecordType() function.
This macro should be used in the header file directly after the definition of a specialized NDEF record class.
className is the name of the specialized class, typeNameFormat is the appropriate QNdefRecord::TypeNameFormat for the custom type and type is the type without the NID or NSS prefixes. That is {example.com:f} not {urn:nfc:ext:example.com:f}.
See the section on \l {Creating specialized NDEF record classes} for details.
Definition at line 117 of file qndefrecord.cpp.