File indexing completed on 2025-02-16 04:51:18

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QSet>
0010 #include <QUrl>
0011 
0012 #include <map>
0013 #include <vector>
0014 
0015 class QIODevice;
0016 class QJsonObject;
0017 
0018 namespace KItinerary {
0019 namespace Generator {
0020 
0021 /** Generate country data tables. */
0022 class CountryDbGenerator
0023 {
0024 public:
0025     bool generate(QIODevice *out);
0026 
0027     struct Country
0028     {
0029         QUrl uri;
0030         QString name;
0031         QString isoCode;
0032         QString drivingSide;
0033         QSet<QString> powerPlugTypes;
0034     };
0035 
0036 private:
0037     bool fetchCountryList();
0038     bool fetchDrivingDirections();
0039     bool fetchPowerPlugTypes();
0040     bool fetchUicCountryCodes();
0041     QUrl insertOrMerge(const QJsonObject &obj);
0042     void writeCountryTable(QIODevice *out);
0043     void writeUicCodeTable(QIODevice *out);
0044     void printSummary();
0045 
0046     std::vector<Country> m_countries;
0047     std::map<QString, QUrl> m_isoCodeMap;
0048     std::map<uint16_t, QString> m_uicCodeMap;
0049 
0050     int m_isoCodeConflicts = 0;
0051 };
0052 
0053 }}
0054