Commit a871a40f authored by Volker Krause's avatar Volker Krause
Browse files

Implement decoding uPER unconstrained integer sequences

This now also completes the FCB type declarations to cover everything
that is in the current specification. We are still missing parts of
the implementation though.
parent e51ee0c8
Pipeline #252080 passed with stage
in 13 minutes and 21 seconds
......@@ -110,6 +110,17 @@ QList<int> UPERDecoder::readSequenceOfConstrainedWholeNumber(int64_t minimum, in
return result;
}
QList<int> UPERDecoder::readSequenceOfUnconstrainedWholeNumber()
{
const auto size = readLengthDeterminant();
QList<int> result;
result.reserve(size);
for (size_type i = 0; i < size; ++i) {
result.push_back(readUnconstrainedWholeNumber());
}
return result;
}
QList<QByteArray> UPERDecoder::readSequenceOfIA5String()
{
const auto size = readLengthDeterminant();
......
......@@ -81,6 +81,7 @@ public:
return result;
}
QList<int> readSequenceOfConstrainedWholeNumber(int64_t minimum, int64_t maximum);
QList<int> readSequenceOfUnconstrainedWholeNumber();
QList<QByteArray> readSequenceOfIA5String();
/** Read enumerated value.
......
......@@ -46,6 +46,10 @@
if (Name ## IsSet()) \
Name = decoder.readSequenceOfConstrainedWholeNumber(Min, Max)
#define FCB_READ_SEQUENCE_OF_UNCONTRAINED_INT(Name) \
if (Name ## IsSet()) \
Name = decoder.readSequenceOfUnconstrainedWholeNumber()
#define FCB_READ_SEQUENCE_OF_IA5STRING(Name) \
if (Name ## IsSet()) \
Name = decoder.readSequenceOfIA5String()
......@@ -187,7 +191,7 @@ void Fcb::ZoneType::decode(UPERDecoder &decoder)
FCB_READ_INT_IA5_PAIR(entryStation, 1, 9999999);
FCB_READ_INT_IA5_PAIR(terminatingStation, 1, 9999999);
FCB_READ_UNCONSTRAINED_INT(city);
// TODO zoneId SEQUENCE OF INTEGER OPTIONAL,
FCB_READ_SEQUENCE_OF_UNCONTRAINED_INT(zoneId);
// TODO binaryZoneId OCTET STRING OPTIONAL,
FCB_READ_IA5STRING(nutsCode);
}
......@@ -196,7 +200,7 @@ void Fcb::LineType::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
FCB_READ_INT_IA5_PAIR(carrier, 1, 32000);
// TODO lineId SEQUENCE OF INTEGER OPTIONAL,
FCB_READ_SEQUENCE_OF_UNCONTRAINED_INT(lineId);
FCB_READ_ENUM(stationCodeTable);
FCB_READ_INT_IA5_PAIR(entryStation, 1, 9999999);
FCB_READ_INT_IA5_PAIR(terminatingStation, 1, 9999999);
......@@ -573,20 +577,67 @@ void Fcb::CustomerCardData::decode(UPERDecoder &decoder)
FCB_READ_UTF8STRING(cardTypeDescr);
FCB_READ_UNCONSTRAINED_INT(customerStatus);
FCB_READ_IA5STRING(customerStatusDescr);
// TODO includedServices SEQUENCE OF INTEGER OPTIONAL,
FCB_READ_SEQUENCE_OF_UNCONTRAINED_INT(includedServices);
FCB_READ_CUSTOM(extension);
}
void Fcb::CountermarkData::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
// TODO
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_IA5STRING(ticketReferenceIA5);
FCB_READ_UNCONSTRAINED_INT(ticketReferenceNum);
numberOfCountermark = decoder.readConstrainedWholeNumber(1, 200);
totalOfCountermarks = decoder.readConstrainedWholeNumber(1, 200);
groupName = decoder.readUtf8String();
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_UTF8STRING(validRegionDesc);
FCB_READ_SEQUENCE_OF_CUSTOM(validRegion);
returnIncluded = decoder.readBoolean();
FCB_READ_CUSTOM(returnDescription);
FCB_READ_CONSTRAINED_INT(validFromDay, -1, 700);
FCB_READ_CONSTRAINED_INT(validFromTime, 0, 1440);
FCB_READ_CONSTRAINED_INT(validFromUTCOffset, -60, 60);
FCB_READ_CONSTRAINED_INT(validUntilDay, 0, 370);
FCB_READ_CONSTRAINED_INT(validUntilTime, 0, 1440);
FCB_READ_CONSTRAINED_INT(validUntilUTCOffset, -60, 60);
FCB_READ_ENUM(classCode);
FCB_READ_SEQUENCE_OF_CONTRAINED_INT(carrierNum, 1, 32000);
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_UTF8STRING(infoText);
FCB_READ_CUSTOM(extension);
}
void Fcb::ParkingGroundData::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
// TODO
FCB_READ_IA5STRING(referenceIA5);
FCB_READ_UNCONSTRAINED_INT(referenceNum);
parkingGroundId = decoder.readIA5String();
fromParkingDate = decoder.readConstrainedWholeNumber(-1, 370);
FCB_READ_CONSTRAINED_INT(untilParkingDate, 0, 370);
FCB_READ_INT_IA5_PAIR(productOwner, 1, 32000);
FCB_READ_INT_IA5_PAIR(productId, 0, 32000);
FCB_READ_IA5STRING(accessCode);
location = decoder.readUtf8String();
FCB_READ_ENUM(stationCodeTable);
FCB_READ_UNCONSTRAINED_INT(stationNum);
FCB_READ_UTF8STRING(stationIA5);
FCB_READ_UTF8STRING(specialInformation);
FCB_READ_UTF8STRING(entryTrack);
FCB_READ_IA5STRING(numberPlate);
FCB_READ_UNCONSTRAINED_INT(price);
FCB_READ_SEQUENCE_OF_CUSTOM(vatDetail);
FCB_READ_CUSTOM(extension);
}
void Fcb::FIPTicketData::decode(UPERDecoder &decoder)
......@@ -604,7 +655,21 @@ void Fcb::StationPassageData::decode(UPERDecoder &decoder)
void Fcb::DelayConfirmation::decode(UPERDecoder &decoder)
{
decodeSequence(decoder);
// TODO
FCB_READ_IA5STRING(referenceIA5);
FCB_READ_UNCONSTRAINED_INT(referenceNum);
FCB_READ_INT_IA5_PAIR_UNCONSTRAINED(train);
FCB_READ_CONSTRAINED_INT(departureYear, 2016, 2269);
FCB_READ_CONSTRAINED_INT(departureDay, 1, 366);
FCB_READ_CONSTRAINED_INT(departureTime, 0, 1440);
FCB_READ_CONSTRAINED_INT(departureUTCOffset, -60, 60);
FCB_READ_ENUM(stationCodeTable);
FCB_READ_INT_IA5_PAIR(station, 1, 9999999);
delay = decoder.readConstrainedWholeNumber(1, 999);
trainCancelled = decoder.readBoolean();
FCB_READ_ENUM(confirmationType);
FCB_READ_SEQUENCE_OF_CUSTOM(affectedTickets);
FCB_READ_UTF8STRING(infoText);
FCB_READ_CUSTOM(extension);
}
void Fcb::TokenType::decode(UPERDecoder &decoder)
......
......@@ -755,19 +755,73 @@ class CountermarkData {
class ParkingGroundData {
UPER_EXTENDABLE_GADGET
// TODO
UPER_ELEMENT_OPTIONAL(QByteArray, referenceIA5)
UPER_ELEMENT_OPTIONAL(int, referenceNum)
UPER_ELEMENT(QByteArray, parkingGroundId)
UPER_ELEMENT(int, fromParkingDate)
UPER_ELEMENT_DEFAULT(int, untilParkingDate, 0)
UPER_ELEMENT_OPTIONAL(int, productOwnerNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productOwnerIA5)
UPER_ELEMENT_OPTIONAL(int, productIdNum)
UPER_ELEMENT_OPTIONAL(QByteArray, productIdIA5)
UPER_ELEMENT_OPTIONAL(QByteArray, accessCode)
UPER_ELEMENT(QString, location)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CodeTableType, stationCodeTable, stationUIC)
UPER_ELEMENT_OPTIONAL(int, stationNum)
UPER_ELEMENT_OPTIONAL(QString, stationIA5) // yep, actually UTF8String rather than IA5String
UPER_ELEMENT_OPTIONAL(QString, specialInformation)
UPER_ELEMENT_OPTIONAL(QString, entryTrack)
UPER_ELEMENT_OPTIONAL(QByteArray, numberPlate)
UPER_ELEMENT_OPTIONAL(int, price)
UPER_ELEMENT_OPTIONAL(QList<KItinerary::Fcb::VatDetailType>, vatDetail)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class FIPTicketData {
UPER_EXTENDABLE_GADGET
// TODO
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_DEFAULT(int, validFromDay, 0)
UPER_ELEMENT_DEFAULT(int, validUntilDay, 0)
UPER_ELEMENT_OPTIONAL(QList<int>, activatedDay)
UPER_ELEMENT_OPTIONAL(QList<int>, carrierNum)
UPER_ELEMENT_OPTIONAL(QList<QByteArray>, carrierIA5)
UPER_ELEMENT(int, numberOfTravelDays)
UPER_ELEMENT(bool, includesSupplements)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::TravelClassType, classCode, second)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class StationPassageData {
UPER_EXTENDABLE_GADGET
// TODO
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(QString, productName)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CodeTableType, stationCodeTable, stationUIC)
UPER_ELEMENT_OPTIONAL(QList<int>, stationNum)
UPER_ELEMENT_OPTIONAL(QList<QByteArray>, stationIA5)
UPER_ELEMENT_OPTIONAL(QList<QString>, stationNameUTF8)
UPER_ELEMENT_OPTIONAL(QList<int>, areaCodeNum)
UPER_ELEMENT_OPTIONAL(QList<QByteArray>, areaCodeIA5)
UPER_ELEMENT_OPTIONAL(QList<QString>, areaNameUTF8)
UPER_ELEMENT(int, validFromDay)
UPER_ELEMENT_OPTIONAL(int, validFromTime)
UPER_ELEMENT_OPTIONAL(int, validFromUTCOffset)
UPER_ELEMENT_DEFAULT(int, validUntilDay, 0)
UPER_ELEMENT_OPTIONAL(int, validUntilTime)
UPER_ELEMENT_OPTIONAL(int, validUntilUTCOffset)
UPER_ELEMENT_OPTIONAL(int, numberOfDaysValid)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
......@@ -778,28 +832,6 @@ enum ConfirmationType {
};
UPER_EXTENABLE_ENUM(ConfirmationType)
class DelayConfirmation {
UPER_EXTENDABLE_GADGET
// TODO
UPER_GADGET_FINALIZE
};
class TokenType {
UPER_GADGET
UPER_ELEMENT_OPTIONAL(int, tokenProviderNum)
UPER_ELEMENT_OPTIONAL(QByteArray, tokenProviderIA5)
UPER_ELEMENT_OPTIONAL(QByteArray, tokenSpecification)
UPER_ELEMENT(QByteArray, token)
UPER_GADGET_FINALIZE
};
class DocumentData {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::TokenType, token)
UPER_ELEMENT(QVariant, ticket)
UPER_GADGET_FINALIZE
};
enum TicketType {
openTicket = 0,
pass = 1,
......@@ -827,6 +859,44 @@ class TicketLinkType {
UPER_GADGET_FINALIZE
};
class DelayConfirmation {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(QByteArray, referenceIA5)
UPER_ELEMENT_OPTIONAL(int, referenceNum)
UPER_ELEMENT_OPTIONAL(int, trainNum)
UPER_ELEMENT_OPTIONAL(QByteArray, trainIA5)
UPER_ELEMENT_OPTIONAL(int, departureYear)
UPER_ELEMENT_OPTIONAL(int, departureDay)
UPER_ELEMENT_OPTIONAL(int, departureTime)
UPER_ELEMENT_OPTIONAL(int, departureUTCOffset)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::CodeTableType, stationCodeTable, stationUIC)
UPER_ELEMENT_OPTIONAL(int, stationNum)
UPER_ELEMENT_OPTIONAL(QByteArray, stationIA5)
UPER_ELEMENT(int, delay)
UPER_ELEMENT(bool, trainCancelled)
UPER_ELEMENT_DEFAULT(KItinerary::Fcb::ConfirmationType, confirmationType, travelerDelayConfirmation)
UPER_ELEMENT_OPTIONAL(QList<KItinerary::Fcb::TicketLinkType>, affectedTickets)
UPER_ELEMENT_OPTIONAL(QString, infoText)
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::ExtensionData, extension)
UPER_GADGET_FINALIZE
};
class TokenType {
UPER_GADGET
UPER_ELEMENT_OPTIONAL(int, tokenProviderNum)
UPER_ELEMENT_OPTIONAL(QByteArray, tokenProviderIA5)
UPER_ELEMENT_OPTIONAL(QByteArray, tokenSpecification)
UPER_ELEMENT(QByteArray, token)
UPER_GADGET_FINALIZE
};
class DocumentData {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(KItinerary::Fcb::TokenType, token)
UPER_ELEMENT(QVariant, ticket)
UPER_GADGET_FINALIZE
};
class ControlData {
UPER_EXTENDABLE_GADGET
UPER_ELEMENT_OPTIONAL(QList <KItinerary::Fcb::CardReferenceType>, identificationByCardReference)
......
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