QNdefRecord

Since: 1.2

#include <QtNfcSubset/QNdefRecord>

The QNdefRecord class provides an NFC NDEF record.

QNdefRecord and derived classes are used to parse the contents of QNdefMessage NDEF messages and create new NDEF messages.

Use typeNameFormat(), userTypeNameFormat(), setTypeNameFormat() and setUserTypeNameFormat() 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.

Specialized NDEF record classes can be easily created with the Q_DECLARE_NDEF_RECORD() and Q_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD() macros. The following example shows the class declaration of the hypothetical {example.com:f} record type that encapsulates a single int property foo.

The developer only needs to provide implementations for the {foo()} and {setFoo()} functions that parse and set the contents of the NDEF record's payload.


Overview

Public Types Index

enum TypeNameFormat

Empty 0x00, NfcRtd 0x01, Mime 0x02, Uri 0x03, ExternalRtd 0x04, Unknown 0x05

Public Functions Index

QNdefRecord ()
QNdefRecord (const QNdefRecord &other)
~QNdefRecord ()
QByteArrayid () const
boolisEmpty () const
boolisRecordType () const
booloperator!= (const QNdefRecord &other) const
QNdefRecord &operator= (const QNdefRecord &other)
booloperator== (const QNdefRecord &other) const
QByteArraypayload () const
voidsetId (const QByteArray &id)
voidsetPayload (const QByteArray &payload)
voidsetType (const QByteArray &type)
voidsetTypeNameFormat (TypeNameFormat typeNameFormat)
QByteArraytype () const
TypeNameFormattypeNameFormat () const

Protected Functions Index

QNdefRecord (const QNdefRecord &other, TypeNameFormat typeNameFormat, const QByteArray &type, bool ignoreType=false)
QNdefRecord (TypeNameFormat typeNameFormat, const QByteArray &type)

Public Types

TypeNameFormat

This enum describes the type name format of an NDEF record.

Empty 0x00

An empty NDEF record, the record does not contain a payload.

NfcRtd 0x01

The NDEF record type is defined by an NFC RTD Specification.

Mime 0x02

The NDEF record type follows the construct described in RFC 2046.

Uri 0x03

The NDEF record type follows the construct described in RFC 3986.

ExternalRtd 0x04

The NDEF record type follows the construct for external type names described the NFC RTD Specification.

Unknown 0x05

The type of the record is unknown and should be treated similar to content with MIME type 'application/octet-stream' without further context.

Public Functions

QNdefRecord ()

Constructs a new empty NDEF record.

QNdefRecord (

Constructs a new NDEF record that is a copy of other.

~QNdefRecord ()

Destructor.

QByteArray id ()

Returns the id of the NDEF record.

bool isEmpty ()

Return:

Returns true if the NDEF record contains an empty payload; otherwise return false.

This is equivalent to calling {payload().isEmpty()}.

bool isRecordType (
  • typename T)

Returns true if the NDEF record is of the specified record type; otherwise returns false.

bool operator!= (

Returns true if this NDEF record does not equal other; otherwise return false.

QNdefRecord & operator= (

Assigns this NDEF record to other.

bool operator== (

Returns true if other and this NDEF record are the same.

QByteArray payload ()

Returns the payload of the NDEF record.

void setId (

Sets the id of the NDEF record to id.

void setPayload (

Sets the payload of the NDEF record to payload.

void setType (

Sets the type of the NDEF record to type.

void setTypeNameFormat (

Sets the type name format of the NDEF record to typeNameFormat.

QByteArray type ()

Returns the type of the NDEF record.

TypeNameFormat typeNameFormat ()

Returns the type name format of the NDEF record.

Protected Functions

QNdefRecord (

QNdefRecord (

Last modified: 2015-01-22



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus