Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QNdefFilter Class Reference

The QNdefFilter class provides a filter for matching NDEF messages. More...

#include <qndeffilter.h>

Collaboration diagram for QNdefFilter:

Classes

class  Record
 The QNdefFilter::Record struct contains the information about a filter record. More...

Public Member Functions

 QNdefFilter ()
 Constructs a new NDEF filter.
 QNdefFilter (const QNdefFilter &other)
 Constructs a new NDEF filter that is a copy of other.
 ~QNdefFilter ()
 Destroys the NDEF filter.
void clear ()
 Clears the filter.
void setOrderMatch (bool on)
 Sets the ordering requirements of the filter.
bool orderMatch () const
 Returns true if the filter takes NDEF record order into account when matching.
template<typename T>
bool appendRecord (unsigned int min=1, unsigned int max=1)
 Appends a record matching the template parameter to the NDEF filter.
bool appendRecord (QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type, unsigned int min=1, unsigned int max=1)
 Appends a record with type name format typeNameFormat and type type to the NDEF filter.
bool appendRecord (const Record &record)
 Verifies the record and appends it to the NDEF filter.
qsizetype recordCount () const
 Returns the number of NDEF records in the filter.
Record recordAt (qsizetype i) const
 Returns the NDEF record at index i.
QNdefFilteroperator= (const QNdefFilter &other)
 Assigns other to this filter and returns a reference to this filter.
bool match (const QNdefMessage &message) const

Detailed Description

The QNdefFilter class provides a filter for matching NDEF messages.

\inmodule QtNfc

Since
5.2

The QNdefFilter encapsulates the structure of an NDEF message and is used for matching messages that have a particular structure.

The following filter matches NDEF messages that contain a single smart poster record:

QNdefFilter()
Constructs a new NDEF filter.
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter

The following filter matches NDEF messages that contain a URI, a localized piece of text and an optional JPEG image. The order of the records must be in the order specified:

filter.setOrderMatch(true);
filter.appendRecord(QNdefRecord::NfcRtd, "U");
filter.appendRecord<QNdefNfcTextRecord>();
filter.appendRecord(QNdefRecord::Mime, "image/jpeg", 0, 1);
The QNdefNfcTextRecord class provides an NFC RTD-Text.

The \l match() method can be used to check if a message matches the filter.

Definition at line 16 of file qndeffilter.h.

Constructor & Destructor Documentation

◆ QNdefFilter() [1/2]

QNdefFilter::QNdefFilter ( )

Constructs a new NDEF filter.

Definition at line 239 of file qndeffilter.cpp.

◆ QNdefFilter() [2/2]

QNdefFilter::QNdefFilter ( const QNdefFilter & other)

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

Definition at line 247 of file qndeffilter.cpp.

◆ ~QNdefFilter()

QNdefFilter::~QNdefFilter ( )

Destroys the NDEF filter.

Definition at line 255 of file qndeffilter.cpp.

Member Function Documentation

◆ appendRecord() [1/3]

bool QNdefFilter::appendRecord ( const Record & record)

Verifies the record and appends it to the NDEF filter.

Returns true if the record was appended successfully. Otherwise returns false.

Definition at line 459 of file qndeffilter.cpp.

◆ appendRecord() [2/3]

bool QNdefFilter::appendRecord ( QNdefRecord::TypeNameFormat typeNameFormat,
const QByteArray & type,
unsigned int min = 1,
unsigned int max = 1 )

Appends a record with type name format typeNameFormat and type type to the NDEF filter.

The record must occur between min and max times in the NDEF message.

Returns true if the record was appended successfully. Otherwise returns false.

Definition at line 435 of file qndeffilter.cpp.

◆ appendRecord() [3/3]

template<typename T>
bool QNdefFilter::appendRecord ( unsigned int min = 1,
unsigned int max = 1 )

Appends a record matching the template parameter to the NDEF filter.

The record must occur between min and max times in the NDEF message.

Returns true if the record was appended successfully. Otherwise returns false.

Definition at line 53 of file qndeffilter.h.

◆ clear()

void QNdefFilter::clear ( )

Clears the filter.

Definition at line 399 of file qndeffilter.cpp.

◆ match()

bool QNdefFilter::match ( const QNdefMessage & message) const
Since
6.2

Returns true if the message matches the given filter. Otherwise returns false.

See \l {Matching Algorithms} for more detailed explanation of matching.

Definition at line 278 of file qndeffilter.cpp.

◆ operator=()

QNdefFilter & QNdefFilter::operator= ( const QNdefFilter & other)

Assigns other to this filter and returns a reference to this filter.

Definition at line 262 of file qndeffilter.cpp.

◆ orderMatch()

bool QNdefFilter::orderMatch ( ) const

Returns true if the filter takes NDEF record order into account when matching.

Otherwise returns false.

Definition at line 422 of file qndeffilter.cpp.

◆ recordAt()

QNdefFilter::Record QNdefFilter::recordAt ( qsizetype i) const

Returns the NDEF record at index i.

i must be a valid index (i.e. 0 <= i < \l recordCount()).

See also
recordCount()

Definition at line 475 of file qndeffilter.cpp.

◆ recordCount()

qsizetype QNdefFilter::recordCount ( ) const

Returns the number of NDEF records in the filter.

Definition at line 483 of file qndeffilter.cpp.

◆ setOrderMatch()

void QNdefFilter::setOrderMatch ( bool on)

Sets the ordering requirements of the filter.

If on is {true}, the filter will only match if the order of records in the filter matches the order of the records in the NDEF message. If on is {false}, the order of the records is not taken into account when matching.

By default record order is not taken into account.

Definition at line 413 of file qndeffilter.cpp.


The documentation for this class was generated from the following files: