Commit 565c6c0d authored by Volker Krause's avatar Volker Krause
Browse files

Implement decoding uPER IA5String sequences

parent 673d3451
Pipeline #250208 passed with stage
in 10 minutes and 18 seconds
......@@ -109,3 +109,14 @@ QList<int> UPERDecoder::readSequenceOfConstrainedWholeNumber(int64_t minimum, in
}
return result;
}
QList<QByteArray> UPERDecoder::readSequenceOfIA5String()
{
const auto size = readLengthDeterminant();
QList<QByteArray> result;
result.reserve(size);
for (size_type i = 0; i < size; ++i) {
result.push_back(readIA5String());
}
return result;
}
......@@ -81,6 +81,7 @@ public:
return result;
}
QList<int> readSequenceOfConstrainedWholeNumber(int64_t minimum, int64_t maximum);
QList<QByteArray> readSequenceOfIA5String();
/** Read enumerated value.
* @see X.691 §14
......
......@@ -42,6 +42,10 @@
if (Name ## IsSet()) \
Name = decoder.readSequenceOfConstrainedWholeNumber(Min, Max)
#define FCB_READ_SEQUENCE_OF_IA5STRING(Name) \
if (Name ## IsSet()) \
Name = decoder.readSequenceOfIA5String()
#define FCB_READ_SEQUENCE_OF_CUSTOM(Name) \
if (Name ## IsSet()) \
Name = decoder.readSequenceOf<decltype(Name)::value_type>();
......@@ -212,6 +216,36 @@ void Fcb::CardReferenceType::decode(UPERDecoder &decoder)
FCB_READ_INT_IA5_PAIR_UNCONSTRAINED(trailingCardId);
}
void Fcb::PlacesType::decode(KItinerary::UPERDecoder &decoder)
{
decodeSequence(decoder);
FCB_READ_IA5STRING(coach);
FCB_READ_IA5STRING(placeString);
FCB_READ_UTF8STRING(placeDescription);
FCB_READ_SEQUENCE_OF_IA5STRING(placeIA5);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(placeNum, 1, 254);
}
void Fcb::CompartmentDetailsType::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
FCB_READ_CONSTRAINED_INT(coachType, 1, 99);
FCB_READ_CONSTRAINED_INT(compartmentType, 1, 99);
FCB_READ_CONSTRAINED_INT(specialAllocation, 1, 99);
FCB_READ_UTF8STRING(coachTypeDescr);
FCB_READ_UTF8STRING(compartmentTypeDescr);
FCB_READ_UTF8STRING(specialAllocationDescr);
FCB_READ_ENUM(position);
}
void Fcb::BerthDetailData::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
berthType = decoder.readEnumerated<BerthTypeType>();
numberOfBerths = decoder.readConstrainedWholeNumber(1, 999);
FCB_READ_ENUM(gender);
}
void Fcb::TariffType::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
......@@ -255,7 +289,7 @@ void Fcb::IncludedOpenTicketType::decode(UPERDecoder &decoder)
FCB_READ_ENUM(classCode);
// TODO serviceLevel
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(carrierNum, 1, 32000);
// TODO carrierIA5
FCB_READ_SEQUENCE_OF_IA5STRING(carrierIA5);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(includedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(excludedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CUSTOM(tariffs);
......@@ -279,6 +313,50 @@ void Fcb::LuggageRestrictionType::decode(UPERDecoder &decoder)
FCB_READ_SEQUENCE_OF_CUSTOM(registeredLuggage);
}
void Fcb::ReservationData::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
FCB_READ_INT_IA5_PAIR_UNCONSTRAINED(train);
FCB_READ_CONSTRAINED_INT(departureDate, -1, 370);
FCB_READ_IA5STRING(referenceIA5);
FCB_READ_UNCONSTRAINED_INT(referenceNum);
FCB_READ_INT_IA5_PAIR(productOwner, 1, 32000);
FCB_READ_INT_IA5_PAIR(productId, 0, 32000);
FCB_READ_CONSTRAINED_INT(serviceBrand, 0, 32000);
FCB_READ_UTF8STRING(serviceBrandAbrUTF8);
FCB_READ_UTF8STRING(serviceBrandNameUTF8);
FCB_READ_ENUM(service);
FCB_READ_ENUM(stationCodeTable);
FCB_READ_INT_IA5_PAIR(fromStation, 1, 9999999);
FCB_READ_INT_IA5_PAIR(toStation, 1, 9999999);
FCB_READ_UTF8STRING(fromStationNameUTF8);
FCB_READ_UTF8STRING(toStationNameUTF8);
FCB_READ_CONSTRAINED_INT(departureTime, 0, 1440);
FCB_READ_CONSTRAINED_INT(departureUTCOffset, -60, 60);
FCB_READ_CONSTRAINED_INT(arrivalDate, 0, 20);
FCB_READ_CONSTRAINED_INT(arrivalTime, 0, 1440);
FCB_READ_CONSTRAINED_INT(arrivalUTCOffset, -60, 60);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(carrierNum, 1, 32000);
FCB_READ_SEQUENCE_OF_IA5STRING(carrierIA5);
FCB_READ_ENUM(classCode);
// TODO serviceLevel IA5String (SIZE(1..2)) OPTIONAL,
FCB_READ_CUSTOM(places);
FCB_READ_CUSTOM(additionalPlaces);
FCB_READ_CUSTOM(bicyclePlaces);
FCB_READ_CUSTOM(compartmentDetails);
FCB_READ_CONSTRAINED_INT(numberOfOverbooked, 0, 200);
FCB_READ_SEQUENCE_OF_CUSTOM(berth);
FCB_READ_SEQUENCE_OF_CUSTOM(tariffs);
FCB_READ_ENUM(priceType);
FCB_READ_UNCONSTRAINED_INT(price);
FCB_READ_SEQUENCE_OF_CUSTOM(vatDetail);
FCB_READ_CONSTRAINED_INT(typeOfSupplement, 0, 9);
FCB_READ_CONSTRAINED_INT(numberOfSupplements, 0, 200);
FCB_READ_CUSTOM(luggage);
FCB_READ_UTF8STRING(infoText);
FCB_READ_CUSTOM(extension);
}
void Fcb::OpenTicketData::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
......@@ -306,7 +384,7 @@ void Fcb::OpenTicketData::decode(UPERDecoder &decoder)
FCB_READ_ENUM(classCode);
FCB_READ_IA5STRING(serviceLevel); // TODO this is size constrained!
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(carrierNum, 1, 32000);
// TODO carrierIA5
FCB_READ_SEQUENCE_OF_IA5STRING(carrierIA5);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(includedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(excludedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CUSTOM(tariffs);
......@@ -365,9 +443,9 @@ void Fcb::PassData::decode(UPERDecoder &decoder)
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(activatedDay, 0, 370);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(countries, 1, 250);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(includedCarrierNum, 1, 32000);
// TODO includedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
FCB_READ_SEQUENCE_OF_IA5STRING(includedCarrierIA5);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(excludedCarrierNum, 1, 32000);
// TODO excludedCarrierIA5 SEQUENCE OF IA5String OPTIONAL,
FCB_READ_SEQUENCE_OF_IA5STRING(excludedCarrierIA5);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(includedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(excludedServiceBrands, 1, 32000);
FCB_READ_SEQUENCE_OF_CUSTOM(validRegion);
......@@ -387,6 +465,12 @@ void Fcb::DocumentData::decode(UPERDecoder &decoder)
const auto choiceIdx = decoder.readConstrainedWholeNumber(0, 11);
switch (choiceIdx) {
// TODO
case 0: {
ReservationData r;
r.decode(decoder);
ticket = QVariant::fromValue(r);
break;
}
case 2: {
OpenTicketData t;
t.decode(decoder);
......
......@@ -72,6 +72,13 @@ class GeoCoordinateType {
UPER_GADGET_FINALIZE
};
class DeltaCoordinate {
UPER_GADGET
UPER_ELEMENT(int, longitude)
UPER_ELEMENT(int, latitude)
UPER_GADGET_FINALIZE
};
class IssuingData {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(int, securityProviderNum)
......@@ -181,6 +188,38 @@ class TrainLinkType {
UPER_GADGET_FINALIZE
};
class ViaStationType {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CodeTableType, stationCodeTable, stationUIC)
UPER_ELEMENT_OPTIONAL(int, stationNum)
UPER_ELEMENT_OPTIONAL(QByteArray, stationIA5)
UPER_ELEMENT_OPTIONAL(QList<KItinerary::Fcb::ViaStationType>, alternativeRoutes)
UPER_ELEMENT_OPTIONAL(QList<KItinerary::Fcb::ViaStationType>, route)
UPER_ELEMENT(bool, border)
UPER_ELEMENT_OPTIONAL(QList<int>, carrierNum)
UPER_ELEMENT_OPTIONAL(QList<QByteArray>, carrierIA5)
UPER_ELEMENT(int, seriesId)
UPER_ELEMENT(int, routeId)
UPER_GADGET_FINALIZE
};
class ZoneType {
UPER_EXTENDABLE_GADGET
// TODO
};
class LineType {
UPER_EXTENDABLE_GADGET
// TODO
};
class PolygoneType {
UPER_GADGET
UPER_ELEMENT(KItinerary::Fcb::GeoCoordinateType, firstEdge)
UPER_ELEMENT(QList<KItinerary::Fcb::DeltaCoordinate>, edges)
UPER_GADGET_FINALIZE
};
class RegionalValidityType {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT(QVariant, value)
......@@ -266,14 +305,50 @@ class PlacesType {
UPER_GADGET_FINALIZE
};
enum class CompartmentPositionType {
unspecified = 0, // TODO ambiguous, therefore using enum class for now, but that's not going to work in QML
upperLevel = 1,
lowerLevel = 2,
};
UPER_ENUM(CompartmentPositionType)
class CompartmentDetailsType {
UPER_EXTENDABLE_GADGET
// TODO
UPER_ELEMENT_OPTIONAL(int, coachType)
UPER_ELEMENT_OPTIONAL(int, compartmentType)
UPER_ELEMENT_OPTIONAL(int, specialAllocation)
UPER_ELEMENT_OPTIONAL(QString, coachTypeDescr)
UPER_ELEMENT_OPTIONAL(QString, compartmentTypeDescr)
UPER_ELEMENT_OPTIONAL(QString, specialAllocationDescr)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CompartmentPositionType, position, CompartmentPositionType::unspecified)
UPER_GADGET_FINALIZE
};
enum BerthTypeType {
single = 0,
special = 1,
doubleBerth = 2, // "double" in the spec, but that conflicts
t2 = 3,
t3 = 4,
t4 = 5,
};
UPER_ENUM(BerthTypeType)
enum class CompartmentGenderType {
unspecified = 0, // TODO see CompartmentPositionType
family = 1,
female = 2,
male = 3,
mixed = 4,
};
UPER_EXTENABLE_ENUM(CompartmentGenderType)
class BerthDetailData {
UPER_EXTENDABLE_GADGET
// TODO
UPER_ELEMENT(KItinerary::Fcb::BerthTypeType, berthType)
UPER_ELEMENT(int, numberOfBerths)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CompartmentGenderType, gender, CompartmentGenderType::family)
UPER_GADGET_FINALIZE
};
class TariffType {
......@@ -403,8 +478,74 @@ class ReservationData {
UPER_GADGET_FINALIZE
};
enum RoofRackType {
norack = 0,
roofRailing = 1,
luggageRack = 2,
skiRack = 3,
boxRack = 4,
rackWithOneBox = 5,
rackWithTwoBoxes = 6,
bicycleRack = 7,
otherRack = 8,
};
UPER_EXTENABLE_ENUM(RoofRackType)
enum class LoadingDeckType {
unspecified = 0, // TODO see above
upper = 1,
lower = 2,
};
UPER_ENUM(LoadingDeckType)
class CarCarriageReservationData {
// TODO
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(int, trainNum)
UPER_ELEMENT_OPTIONAL(QByteArray, trainIA5)
UPER_ELEMENT_DEFAULT(int, beginLoadingDate, 0)
UPER_ELEMENT_OPTIONAL(int, beginLoadingTime)
UPER_ELEMENT_OPTIONAL(int, endLoadingTime)
UPER_ELEMENT_OPTIONAL(int, loadingUTCOffset)
UPER_ELEMENT_OPTIONAL(QByteArray, referenceIA5)
UPER_ELEMENT_OPTIONAL(int, referenceNum)
UPER_ELEMENT_OPTIONAL(int, productOwnerNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productOwnerIA5)
UPER_ELEMENT_OPTIONAL(int, productIdNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productIdIA5)
UPER_ELEMENT_OPTIONAL(int, serviceBrand)
UPER_ELEMENT_OPTIONAL(QString, serviceBrandAbrUTF8)
UPER_ELEMENT_OPTIONAL(QString, serviceBrandNameUTF8)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CodeTableType, stationCodeTable, stationUICReservation)
UPER_ELEMENT_OPTIONAL(int, fromStationNum)
UPER_ELEMENT_OPTIONAL(QByteArray, fromStationIA5)
UPER_ELEMENT_OPTIONAL(int, toStationNum)
UPER_ELEMENT_OPTIONAL(QByteArray, toStationIA5)
UPER_ELEMENT_OPTIONAL(QString, fromStationNameUTF8)
UPER_ELEMENT_OPTIONAL(QString, toStationNameUTF8)
UPER_ELEMENT_OPTIONAL(QByteArray, coach)
UPER_ELEMENT_OPTIONAL(QByteArray, place)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::CompartmentDetailsType, compartmentDetails)
UPER_ELEMENT_OPTIONAL(QByteArray, numberPlate)
UPER_ELEMENT_OPTIONAL(QByteArray, trailerPlate)
UPER_ELEMENT(int, carCategory)
UPER_ELEMENT_OPTIONAL(int, boatCategory)
UPER_ELEMENT(bool, textileRoof)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::RoofRackType, roofRackType, norack)
UPER_ELEMENT_OPTIONAL(int, roofRackHeight)
UPER_ELEMENT_OPTIONAL(int, attachedBoats)
UPER_ELEMENT_OPTIONAL(int, attachedBicycles)
UPER_ELEMENT_OPTIONAL(int, attachedSurfboards)
UPER_ELEMENT_OPTIONAL(int, loadingListEntry)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::LoadingDeckType, loadingDeck, LoadingDeckType::upper)
UPER_ELEMENT_OPTIONAL(QList<int>, carrierNum)
UPER_ELEMENT_OPTIONAL(QList<QByteArray>, carrierIA5)
UPER_ELEMENT(KItinerary::Fcb::TariffType, tariff)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::PriceTypeType, priceType, travelPrice)
UPER_ELEMENT_OPTIONAL(int, price)
UPER_ELEMENT_OPTIONAL(QList<KItinerary::Fcb::VatDetailType>, vatDetail)
UPER_ELEMENT_OPTIONAL(QString, infoText)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class OpenTicketData {
......@@ -515,11 +656,41 @@ class PassData {
};
class VoucherData {
// TODO
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(QByteArray, referenceIA5)
UPER_ELEMENT_OPTIONAL(int, referenceNum)
UPER_ELEMENT_OPTIONAL(int, productOwnerNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productOwnerIA5)
UPER_ELEMENT_OPTIONAL(int, productIdNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productIdIA5)
UPER_ELEMENT(int, validFromYear)
UPER_ELEMENT(int, validFromDay)
UPER_ELEMENT(int, validUntilYear)
UPER_ELEMENT(int, validUntilDay)
UPER_ELEMENT_DEFAULT(int, value, 0)
UPER_ELEMENT_OPTIONAL(int, type)
UPER_ELEMENT_OPTIONAL(QString, infoText)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class CustomerCardData {
// TODO
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::TravelerType, customer)
UPER_ELEMENT_OPTIONAL(QByteArray, cardIdIA5)
UPER_ELEMENT_OPTIONAL(int, cardIdNum)
UPER_ELEMENT(int, validFromYear)
UPER_ELEMENT_OPTIONAL(int, validFromDay)
UPER_ELEMENT_DEFAULT(int, validUntilYear, 0)
UPER_ELEMENT_OPTIONAL(int, validUntilDay)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::TravelClassType, classCode)
UPER_ELEMENT_OPTIONAL(int, cardType)
UPER_ELEMENT_OPTIONAL(QString, cardTypeDescr)
UPER_ELEMENT_OPTIONAL(int, customerStatus)
UPER_ELEMENT_OPTIONAL(QString, customerStatusDescr)
UPER_ELEMENT_OPTIONAL(QList<int>, includedServices)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class CountermarkData {
......@@ -558,9 +729,31 @@ class DocumentData {
UPER_GADGET_FINALIZE
};
enum TicketType {
openTicket = 0,
pass = 1,
reservation = 2,
carCarriageReservation = 3,
};
UPER_EXTENABLE_ENUM(TicketType)
enum LinkMode {
issuedTogether = 0,
onlyValidInCombination = 1,
};
UPER_EXTENABLE_ENUM(LinkMode)
class TicketLinkType {
UPER_EXTENDABLE_GADGET
// TODO
UPER_ELEMENT_OPTIONAL(QByteArray, referenceIA5)
UPER_ELEMENT_OPTIONAL(int, referenceNum)
UPER_ELEMENT_OPTIONAL(QString, issuerName)
UPER_ELEMENT_OPTIONAL(QByteArray, issuerPNR)
UPER_ELEMENT_OPTIONAL(int, productOwnerNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productOwnerIA5)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::TicketType, ticketType, openTicket)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::LinkMode, linkMode, issuedTogether)
UPER_GADGET_FINALIZE
};
class ControlData {
......@@ -603,10 +796,16 @@ private:
Q_DECLARE_METATYPE(KItinerary::Fcb::ExtensionData)
Q_DECLARE_METATYPE(KItinerary::Fcb::GeoCoordinateType)
Q_DECLARE_METATYPE(KItinerary::Fcb::DeltaCoordinate)
Q_DECLARE_METATYPE(KItinerary::Fcb::IssuingData)
Q_DECLARE_METATYPE(KItinerary::Fcb::TravelerType)
Q_DECLARE_METATYPE(KItinerary::Fcb::CustomerStatusType)
Q_DECLARE_METATYPE(KItinerary::Fcb::TravelerData)
Q_DECLARE_METATYPE(KItinerary::Fcb::TrainLinkType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ViaStationType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ZoneType)
Q_DECLARE_METATYPE(KItinerary::Fcb::LineType)
Q_DECLARE_METATYPE(KItinerary::Fcb::PolygoneType)
Q_DECLARE_METATYPE(KItinerary::Fcb::RegionalValidityType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ReturnRouteDescriptionType)
Q_DECLARE_METATYPE(KItinerary::Fcb::RouteSectionType)
......@@ -620,11 +819,14 @@ Q_DECLARE_METATYPE(KItinerary::Fcb::IncludedOpenTicketType)
Q_DECLARE_METATYPE(KItinerary::Fcb::RegisteredLuggageType)
Q_DECLARE_METATYPE(KItinerary::Fcb::LuggageRestrictionType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ReservationData)
Q_DECLARE_METATYPE(KItinerary::Fcb::CarCarriageReservationData)
Q_DECLARE_METATYPE(KItinerary::Fcb::OpenTicketData)
Q_DECLARE_METATYPE(KItinerary::Fcb::TimeRangeType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ValidityPeriodType)
Q_DECLARE_METATYPE(KItinerary::Fcb::ValidityPeriodDetailType)
Q_DECLARE_METATYPE(KItinerary::Fcb::PassData)
Q_DECLARE_METATYPE(KItinerary::Fcb::VoucherData)
Q_DECLARE_METATYPE(KItinerary::Fcb::CustomerCardData)
Q_DECLARE_METATYPE(KItinerary::Fcb::TokenType)
Q_DECLARE_METATYPE(KItinerary::Fcb::DocumentData)
Q_DECLARE_METATYPE(KItinerary::Fcb::CardReferenceType)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment