KItinerary

iatabcbpsections.h
1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kitinerary_export.h"
10
11#include <QDateTime>
12#include <QMetaType>
13
14namespace KItinerary {
15
16/** @internal Base class for IATA BCBP sections. */
17class KITINERARY_EXPORT IataBcbpSectionBase
18{
19protected:
20 [[nodiscard]] QString readString(int offset, int length) const;
21 [[nodiscard]] int readNumericValue(int offset, int length, int base) const;
22
23 QStringView m_data;
24};
25
26#define IATA_STR_PROPERTY(Name, Start, Length) \
27public: \
28 [[nodiscard]] inline QString Name() const { return readString(Start, Length); } \
29 Q_PROPERTY(QString Name READ Name)
30#define IATA_NUM_PROPERTY(Name, Start, Length) \
31public: \
32 [[nodiscard]] inline int Name() const { return readNumericValue(Start, Length, 10); } \
33 Q_PROPERTY(int Name READ Name)
34#define IATA_HEX_PROPERTY(Name, Start, Length) \
35public: \
36 [[nodiscard]] inline int Name() const { return readNumericValue(Start, Length, 16); } \
37 Q_PROPERTY(int Name READ Name)
38
39
40/** Unique mandatory section of an IATA BCBP. */
41class KITINERARY_EXPORT IataBcbpUniqueMandatorySection : protected IataBcbpSectionBase
42{
43 Q_GADGET
44 IATA_STR_PROPERTY(formatCode, 0, 1)
45 IATA_NUM_PROPERTY(numberOfLegs, 1, 1)
46 IATA_STR_PROPERTY(passengerName, 2, 20)
47 IATA_STR_PROPERTY(electronicTicketIndicator, 22, 1)
48
49public:
52 [[nodiscard]] bool isValid() const;
53};
54
55/** Unique conditional (optional) section of an IATA BCBP. */
56class KITINERARY_EXPORT IataBcbpUniqueConditionalSection : protected IataBcbpSectionBase
57{
58 Q_GADGET
59 IATA_NUM_PROPERTY(version, 1, 1)
60 IATA_HEX_PROPERTY(fieldSize, 2, 2)
61 IATA_STR_PROPERTY(passengerDescription, 4, 1)
62 IATA_STR_PROPERTY(sourceOfCheckin, 5, 1)
63 IATA_STR_PROPERTY(sourceOfBoardingPassIssuance, 6, 1)
64 IATA_NUM_PROPERTY(yearOfIssue, 7, 1)
65 IATA_NUM_PROPERTY(dayOfIssue, 8, 3)
66 IATA_STR_PROPERTY(documentType, 11, 1)
67 IATA_STR_PROPERTY(airlineDesignatorOfBoardingPassIssuer, 12, 3)
68 IATA_STR_PROPERTY(baggageTagLicensePlateNumber1, 15, 13)
69 IATA_STR_PROPERTY(baggageTagLicensePlateNumber2, 28, 13)
70 IATA_STR_PROPERTY(baggageTagLicensePlateNumber3, 41, 13)
71
72public:
75 [[nodiscard]] bool isValid() const;
76
77 Q_INVOKABLE [[nodiscard]] QDate dateOfIssue(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
78};
79
80/** Repeated mandatory sections of an IATA BCBP, occurs once per leg. */
81class KITINERARY_EXPORT IataBcbpRepeatedMandatorySection : protected IataBcbpSectionBase
82{
83 Q_GADGET
84 IATA_STR_PROPERTY(operatingCarrierPNRCode, 0, 7)
85 IATA_STR_PROPERTY(fromCityAirportCode, 7, 3)
86 IATA_STR_PROPERTY(toCityAirportCode, 10, 3)
87 IATA_STR_PROPERTY(operatingCarrierDesignator, 13, 3)
88 IATA_STR_PROPERTY(flightNumber, 16, 5)
89 IATA_NUM_PROPERTY(dayOfFlight, 21, 3)
90 IATA_STR_PROPERTY(compartmentCode, 24, 1)
91 IATA_STR_PROPERTY(seatNumber, 25, 4)
92 IATA_STR_PROPERTY(checkinSequenceNumber, 29, 5)
93 IATA_STR_PROPERTY(passengerStatus, 34, 1)
94 IATA_HEX_PROPERTY(variableFieldSize, 35, 2)
95
96public:
99 [[nodiscard]] bool isValid() const;
100
101 /** Date of the flight.
102 * @param contextDate A date before the flight to determine
103 * the full year which is not specified in the pass itself.
104 */
105 Q_INVOKABLE [[nodiscard]] QDate dateOfFlight(const QDateTime &contextDate = QDateTime::currentDateTime()) const;
106};
107
108/** Conditional (optional) sections of an IATA BCBP, occurs once per leg. */
110{
111 Q_GADGET
112 IATA_HEX_PROPERTY(conditionalFieldSize, 0, 2)
113 IATA_STR_PROPERTY(airlineNumericCode, 2, 3)
114 IATA_STR_PROPERTY(documentNumber, 5, 10)
115 IATA_STR_PROPERTY(selecteeIndicator, 15, 1)
116 IATA_STR_PROPERTY(internationalDocumentVerification, 16, 1)
117 IATA_STR_PROPERTY(marketingCarrierDesignator, 17, 3)
118 IATA_STR_PROPERTY(frequentFlyerAirlineDesignator, 20, 3)
119 IATA_STR_PROPERTY(frequenFlyerNumber, 23, 16)
120 IATA_STR_PROPERTY(idAdIndicator, 39, 1)
121 IATA_STR_PROPERTY(freeBaggageAllowance, 40, 3)
122 IATA_STR_PROPERTY(fastTrack, 43, 1)
123
124public:
127};
128
129/** Security section of an IATA BCBP. */
130class KITINERARY_EXPORT IataBcbpSecuritySection : protected IataBcbpSectionBase
131{
132 Q_GADGET
133 IATA_STR_PROPERTY(type, 1, 1)
134 IATA_HEX_PROPERTY(size, 2, 2)
135 IATA_STR_PROPERTY(securityData, 4, size())
136
137public:
138 IataBcbpSecuritySection() = default;
140};
141
142#undef IATA_STR_PROPERTY
143#undef IATA_HEX_PROPERTY
144
145}
146
Conditional (optional) sections of an IATA BCBP, occurs once per leg.
Repeated mandatory sections of an IATA BCBP, occurs once per leg.
Security section of an IATA BCBP.
Unique conditional (optional) section of an IATA BCBP.
Unique mandatory section of an IATA BCBP.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
QDateTime currentDateTime()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.