KItinerary

fcbutil.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KITINERARY_FCBUTIL_H
7#define KITINERARY_FCBUTIL_H
8
9#include "fcbticket.h"
10#include "logging.h"
11
12#include <QString>
13
14namespace KItinerary {
15
16/** Higher-level decoding utilities for ERA FCB ticket data. */
18{
19public:
20 /** Departure station identifier for a travel document,
21 * in the format needed for output with our JSON-LD format.
22 */
23 template <typename T>
24 [[nodiscard]] static QString fromStationIdentifier(Fcb::CodeTableType stationCodeTable, const T &doc)
25 {
26 switch (stationCodeTable) {
27 case Fcb::stationUIC:
28 case Fcb::stationUICReservation:
29 return stringifyUicStationIdentifier(doc.fromStationNum, doc.fromStationIA5);
30 default:
31 qCWarning(Log) << "Unhandled station code table:" << stationCodeTable;
32 }
33 return stringifyStationIdentifier(doc.fromStationNumIsSet(), doc.fromStationNum, doc.fromStationIA5);
34 }
35 template <typename T>
36 [[nodiscard]] static QString fromStationIdentifier(const T &doc) { return fromStationIdentifier(doc.stationCodeTable, doc); }
37 /** Arrival station identifier for a travel document,
38 * in the format needed for output with our JSON-LD format.
39 */
40 template <typename T>
41 [[nodiscard]] static QString toStationIdentifier(Fcb::CodeTableType stationCodeTable, const T &doc)
42 {
43 switch (stationCodeTable) {
44 case Fcb::stationUIC:
45 case Fcb::stationUICReservation:
46 return stringifyUicStationIdentifier(doc.toStationNum, doc.toStationIA5);
47 default:
48 qCWarning(Log) << "Unhandled station code table:" << stationCodeTable;
49 }
50 return stringifyStationIdentifier(doc.toStationNumIsSet(), doc.toStationNum, doc.toStationIA5);
51 }
52 template <typename T>
53 [[nodiscard]] static QString toStationIdentifier(const T &doc) { return toStationIdentifier(doc.stationCodeTable, doc); }
54
55 /** Convert a class code enum value to a string for human representation. */
56 [[nodiscard]] static QString classCodeToString(Fcb::TravelClassType classCode);
57
58private:
59 [[nodiscard]] static QString stringifyUicStationIdentifier(int num, const QByteArray &ia5);
60 [[nodiscard]] static QString stringifyStationIdentifier(bool numIsSet, int num, const QByteArray &ia5);
61};
62
63}
64
65#endif // KITINERARY_FCBUTIL_H
Higher-level decoding utilities for ERA FCB ticket data.
Definition fcbutil.h:18
static QString fromStationIdentifier(Fcb::CodeTableType stationCodeTable, const T &doc)
Departure station identifier for a travel document, in the format needed for output with our JSON-LD ...
Definition fcbutil.h:24
static QString classCodeToString(Fcb::TravelClassType classCode)
Convert a class code enum value to a string for human representation.
Definition fcbutil.cpp:30
static QString toStationIdentifier(Fcb::CodeTableType stationCodeTable, const T &doc)
Arrival station identifier for a travel document, in the format needed for output with our JSON-LD fo...
Definition fcbutil.h:41
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:58 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.