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
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:

The QNdefFilter class provides a filter for matching NDEF messages.
Definition qndeffilter.h:17
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.appendRecord(QNdefRecord::NfcRtd, "U");
filter.appendRecord<QNdefNfcTextRecord>();
filter.appendRecord(QNdefRecord::Mime, "image/jpeg", 0, 1);
void setOrderMatch(bool on)
Sets the ordering requirements of the filter.
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 238 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 246 of file qndeffilter.cpp.

◆ ~QNdefFilter()

QNdefFilter::~QNdefFilter ( )

Destroys the NDEF filter.

Definition at line 254 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 458 of file qndeffilter.cpp.

References QList< T >::append(), QNdefFilterPrivate::filterRecords, record(), and verifyRecord().

+ Here is the call graph for this function:

◆ 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 434 of file qndeffilter.cpp.

References appendRecord(), and record().

+ Here is the call graph for this function:

◆ 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.

References appendRecord(), and record().

Referenced by appendRecord(), and appendRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void QNdefFilter::clear ( )

Clears the filter.

Definition at line 398 of file qndeffilter.cpp.

References QList< T >::clear(), QNdefFilterPrivate::filterRecords, and QNdefFilterPrivate::orderMatching.

+ Here is the call graph for this function:

◆ 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 277 of file qndeffilter.cpp.

References QList< T >::at(), QSet< T >::cbegin(), QSet< T >::cend(), QNdefFilterPrivate::filterRecords, QList< T >::first(), i, QList< T >::isEmpty(), it, QNdefFilter::Record::minimum, QNdefFilterPrivate::orderMatching, qMakePair(), record(), and QList< T >::size().

+ Here is the call graph for this function:

◆ operator=()

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

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

Definition at line 261 of file qndeffilter.cpp.

References other().

+ Here is the call graph for this function:

◆ orderMatch()

bool QNdefFilter::orderMatch ( ) const

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

Otherwise returns false.

Definition at line 421 of file qndeffilter.cpp.

References QNdefFilterPrivate::orderMatching.

◆ 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 474 of file qndeffilter.cpp.

References QList< T >::at(), QNdefFilterPrivate::filterRecords, and i.

+ Here is the call graph for this function:

◆ recordCount()

qsizetype QNdefFilter::recordCount ( ) const

Returns the number of NDEF records in the filter.

Definition at line 482 of file qndeffilter.cpp.

References QNdefFilterPrivate::filterRecords, and QList< T >::size().

+ Here is the call graph for this function:

◆ 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 412 of file qndeffilter.cpp.

References QNdefFilterPrivate::orderMatching.


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