1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QNDEFFILTER_H |
5 | #define QNDEFFILTER_H |
6 | |
7 | #include <QtCore/QSharedDataPointer> |
8 | #include <QtNfc/qtnfcglobal.h> |
9 | #include <QtNfc/QNdefRecord> |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | class QNdefMessage; |
14 | |
15 | class QNdefFilterPrivate; |
16 | class Q_NFC_EXPORT QNdefFilter |
17 | { |
18 | public: |
19 | QNdefFilter(); |
20 | QNdefFilter(const QNdefFilter &other); |
21 | ~QNdefFilter(); |
22 | |
23 | void clear(); |
24 | |
25 | void setOrderMatch(bool on); |
26 | bool orderMatch() const; |
27 | |
28 | struct Record { |
29 | QNdefRecord::TypeNameFormat typeNameFormat; |
30 | QByteArray type; |
31 | unsigned int minimum; |
32 | unsigned int maximum; |
33 | }; |
34 | |
35 | template<typename T> |
36 | bool appendRecord(unsigned int min = 1, unsigned int max = 1); |
37 | bool appendRecord(QNdefRecord::TypeNameFormat typeNameFormat, const QByteArray &type, |
38 | unsigned int min = 1, unsigned int max = 1); |
39 | bool appendRecord(const Record &record); |
40 | |
41 | qsizetype recordCount() const; |
42 | Record recordAt(qsizetype i) const; |
43 | |
44 | QNdefFilter &operator=(const QNdefFilter &other); |
45 | |
46 | bool match(const QNdefMessage &message) const; |
47 | |
48 | private: |
49 | QSharedDataPointer<QNdefFilterPrivate> d; |
50 | }; |
51 | |
52 | template <typename T> |
53 | bool QNdefFilter::appendRecord(unsigned int min, unsigned int max) |
54 | { |
55 | T record; |
56 | |
57 | return appendRecord(record.typeNameFormat(), record.type(), min, max); |
58 | } |
59 | |
60 | QT_END_NAMESPACE |
61 | |
62 | #endif // QNDEFFILTER_H |
63 | |