File indexing completed on 2024-05-12 04:42:33

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_DEUTSCHEBAHNVEHICLELAYOUTPARSER_H
0008 #define KPUBLICTRANSPORT_DEUTSCHEBAHNVEHICLELAYOUTPARSER_H
0009 
0010 #include <KPublicTransport/Platform>
0011 #include <KPublicTransport/Vehicle>
0012 #include <KPublicTransport/Reply>
0013 #include <KPublicTransport/Stopover>
0014 
0015 class QByteArray;
0016 
0017 namespace KPublicTransport {
0018 
0019 /** Parser for vehicle layout responses from Deutsche Bahn. */
0020 class DeutscheBahnVehicleLayoutParser
0021 {
0022 public:
0023     bool parse(const QByteArray &data);
0024 
0025     Stopover stopover;
0026     Reply::Error error = Reply::NoError;
0027     QString errorMessage;
0028 
0029 private:
0030     void parseVehicleSection(Vehicle &vehicle, const QJsonObject &obj);
0031     void parsePlatformSection(Platform &platform, const QJsonObject &obj);
0032     void fillMissingPositions(Vehicle &vehicle, Platform &platform);
0033 };
0034 
0035 }
0036 
0037 #endif // KPUBLICTRANSPORT_DEUTSCHEBAHNVEHICLELAYOUTPARSER_H