File indexing completed on 2024-05-19 05:57:13
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef MECARDPARSER_H 0007 #define MECARDPARSER_H 0008 0009 #include <QString> 0010 #include <QStringList> 0011 #include <vector> 0012 0013 /** Parser for the MeCard format. 0014 * This was originally used for a more compact vCard representation, but today 0015 * is mostly relevant for Wifi configuration QR codes. 0016 * @see https://en.wikipedia.org/wiki/MeCard_(QR_code) 0017 * @see https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11 0018 */ 0019 class MeCardParser 0020 { 0021 public: 0022 explicit MeCardParser(); 0023 ~MeCardParser(); 0024 0025 bool parse(const QString &data); 0026 0027 QStringView header() const; 0028 QString value(QStringView key) const; 0029 QStringList values(QStringView key) const; 0030 0031 private: 0032 QString m_data; 0033 QStringView m_header; 0034 struct Element { 0035 QStringView key; 0036 QStringList values; 0037 bool operator<(QStringView other) const; 0038 }; 0039 std::vector<Element> m_elements; 0040 }; 0041 0042 #endif // MECARDPARSER_H