File indexing completed on 2024-11-24 04:44:40

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003  * SPDX-License-Identifier: LGPL-2.0-or-later
0004  */
0005 
0006 #ifndef EUDGCPARSER_P_H
0007 #define EUDGCPARSER_P_H
0008 
0009 #include "krecoverycertificate.h"
0010 #include "ktestcertificate.h"
0011 #include "kvaccinationcertificate.h"
0012 
0013 #include <QString>
0014 
0015 #include <variant>
0016 
0017 class QByteArray;
0018 class QCborStreamReader;
0019 class QVariant;
0020 
0021 /** Parser for EU DGC certificates. */
0022 class EuDgcParser
0023 {
0024 public:
0025     EuDgcParser();
0026     ~EuDgcParser();
0027     QVariant parse(const QByteArray &data) const;
0028 
0029     static void init();
0030 
0031 private:
0032     void parseCertificate(QCborStreamReader &reader) const;
0033     void parseCertificateV1(QCborStreamReader &reader) const;
0034     void parseCertificateArray(QCborStreamReader &reader, void (EuDgcParser::* func)(QCborStreamReader&) const) const;
0035     void parseVaccinationCertificate(QCborStreamReader &reader) const;
0036     void parseTestCertificate(QCborStreamReader &reader) const;
0037     void parseRecoveryCertificate(QCborStreamReader &reader) const;
0038     QString parseName(QCborStreamReader &reader) const;
0039 
0040     mutable std::variant<std::monostate, KVaccinationCertificate, KTestCertificate, KRecoveryCertificate> m_cert;
0041 };
0042 
0043 #endif // EUDGCPARSER_P_H