![]() |
Qt 6.x
The Qt SDK
|
The QNdefFilter class provides a filter for matching NDEF messages. More...
#include <qndeffilter.h>
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. | |
QNdefFilter & | operator= (const QNdefFilter &other) |
Assigns other to this filter and returns a reference to this filter. | |
bool | match (const QNdefMessage &message) const |
The QNdefFilter class provides a filter for matching NDEF messages.
\inmodule QtNfc
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 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:
The \l match() method can be used to check if a message matches the filter.
Definition at line 16 of file qndeffilter.h.
QNdefFilter::QNdefFilter | ( | ) |
Constructs a new NDEF filter.
Definition at line 238 of file qndeffilter.cpp.
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 | ( | ) |
Destroys the NDEF filter.
Definition at line 254 of file qndeffilter.cpp.
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().
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().
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().
void QNdefFilter::clear | ( | ) |
Clears the filter.
Definition at line 398 of file qndeffilter.cpp.
References QList< T >::clear(), QNdefFilterPrivate::filterRecords, and QNdefFilterPrivate::orderMatching.
bool QNdefFilter::match | ( | const QNdefMessage & | message | ) | const |
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(), QMap< Key, T >::cbegin(), QMap< Key, T >::cend(), QMap< Key, T >::contains(), QNdefFilterPrivate::filterRecords, QList< T >::first(), i, QMap< Key, T >::insert(), QList< T >::isEmpty(), it, QNdefFilter::Record::maximum, QNdefFilter::Record::minimum, QNdefFilterPrivate::orderMatching, QList< T >::push_back(), qMakePair(), record(), QList< T >::size(), QNdefFilter::Record::type, QNdefFilter::Record::typeNameFormat, and QMap< Key, T >::value().
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().
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.
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()).
Definition at line 474 of file qndeffilter.cpp.
References QList< T >::at(), QNdefFilterPrivate::filterRecords, and i.
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().
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.