File indexing completed on 2024-04-28 04:42:41

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
0003  * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <kweathercore/kweathercore_export.h>
0010 
0011 #include <QXmlStreamReader>
0012 
0013 namespace KWeatherCore
0014 {
0015 class CAPAlertInfo;
0016 class CAPAlertMessage;
0017 class CAPArea;
0018 class CAPNamedValue;
0019 class CAPReference;
0020 
0021 /**
0022  * Parser for CAP Alert Messages
0023  *
0024  * @see https://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2.html
0025  */
0026 class KWEATHERCORE_EXPORT CAPParser
0027 {
0028 public:
0029     explicit CAPParser(const QByteArray &data);
0030     CAPAlertMessage parse();
0031 
0032 private:
0033     CAPAlertInfo parseInfo();
0034     CAPArea parseArea();
0035     CAPNamedValue parseNamedValue();
0036     std::vector<CAPReference> parseReferences(const QString &refsString);
0037     QXmlStreamReader m_xml;
0038 };
0039 }