6#include "uicrailwaycoach.h"
7#include "datatypes/featureutil_p.h"
16 if (coachNumber.
size() > 4) {
17 return coachNumber.
mid(2, 2);
25 if (coachNumber.
size() > 5) {
26 return coachNumber.
mid(4, 1);
35 Feature::Type feature;
36 VehicleSection::Type type;
38}
static constexpr const class_prefix_table[] = {
39 {
"AB", VehicleSection::FirstClass | VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
40 {
"AR", VehicleSection::FirstClass, Feature::Restaurant, VehicleSection::PassengerCar, 1 },
41 {
"A", VehicleSection::FirstClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
42 {
"BR", VehicleSection::SecondClass, Feature::Restaurant, VehicleSection::PassengerCar, 1 },
43 {
"B", VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
44 {
"DAB", VehicleSection::FirstClass | VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 2 },
45 {
"DA", VehicleSection::FirstClass, Feature::NoFeature, VehicleSection::UnknownType, 2 },
46 {
"DB", VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 2 },
47 {
"DD", VehicleSection::UnknownClass, Feature::NoFeature, VehicleSection::CarTransportCar, 2 },
48 {
"WLAB", VehicleSection::FirstClass | VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::SleepingCar, 1 },
49 {
"WLA", VehicleSection::FirstClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
50 {
"WLB", VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
51 {
"WR", VehicleSection::UnknownClass, Feature::Restaurant, VehicleSection::RestaurantCar, 1 },
52 {
"KA", VehicleSection::FirstClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
53 {
"KB", VehicleSection::SecondClass, Feature::NoFeature, VehicleSection::UnknownType, 1 },
58 const auto it = std::find_if(std::begin(class_prefix_table), std::end(class_prefix_table), [coachClassification](
const auto &prefix) {
61 if (it != std::end(class_prefix_table)) {
66 if (type == VehicleSection::PassengerCar || type == VehicleSection::SleepingCar) {
67 const auto cls = classificationDigit(coachNumber);
69 switch (cls.at(0).cell()) {
71 return VehicleSection::FirstClass;
74 return VehicleSection::SecondClass;
76 return VehicleSection::FirstClass | VehicleSection::SecondClass;
87 VehicleSection::Type type;
88 Feature::Type feature;
89}
static constexpr const number_prefix_table[] = {
90 {
"50", VehicleSection::PassengerCar, Feature::NoFeature },
91 {
"70", VehicleSection::PassengerCar, Feature::AirConditioning },
92 {
"71", VehicleSection::SleepingCar, Feature::NoFeature },
93 {
"73", VehicleSection::PassengerCar, Feature::AirConditioning },
94 {
"91", VehicleSection::Engine, Feature::NoFeature },
95 {
"92", VehicleSection::Engine, Feature::NoFeature },
99struct UicClassificationSecondary {
101 Feature::Type feature;
102 VehicleSection::Type type;
107static constexpr const UicClassificationSecondary secondary_54_table[] = {
108 {
"b", Feature::WheelchairAccessible, VehicleSection::UnknownType, 1 },
109 {
"c", Feature::NoFeature, VehicleSection::CouchetteCar, 1 },
110 {
"d", Feature::BikeStorage, VehicleSection::UnknownType, 1 },
111 {
"f", Feature::NoFeature, VehicleSection::ControlCar, 1 },
112 {
"o", Feature::NoFeature, VehicleSection::UnknownType, 2 },
113 {
"z", Feature::AirConditioning, VehicleSection::PassengerCar, 1 },
117static constexpr const UicClassificationSecondary secondary_80_table[] = {
118 {
"b", Feature::WheelchairAccessible, VehicleSection::UnknownType, 1 },
119 {
"c", Feature::NoFeature, VehicleSection::CouchetteCar, 1 },
120 {
"d", Feature::BikeStorage, VehicleSection::UnknownType, 1 },
121 {
"f", Feature::NoFeature, VehicleSection::ControlCar, 1 },
122 {
"k", Feature::Restaurant, VehicleSection::UnknownType, 1 },
123 {
"p", Feature::AirConditioning, VehicleSection::PassengerCar, 1 },
124 {
"q", Feature::NoFeature, VehicleSection::ControlCar, 1 },
128static constexpr const UicClassificationSecondary secondary_81_table[] = {
129 {
"b", Feature::WheelchairAccessible, VehicleSection::UnknownType, 1 },
130 {
"c", Feature::NoFeature, VehicleSection::CouchetteCar, 1 },
131 {
"f", Feature::NoFeature, VehicleSection::ControlCar, 1 },
132 {
"p", Feature::NoFeature, VehicleSection::PassengerCar, 1 },
133 {
"-s", Feature::NoFeature, VehicleSection::ControlCar, 1 },
134 {
"-dl", Feature::NoFeature, VehicleSection::PassengerCar, 2 },
135 {
"-ds", Feature::NoFeature, VehicleSection::ControlCar, 2 },
139static constexpr const UicClassificationSecondary secondary_85_table[] = {
140 {
"c", Feature::NoFeature, VehicleSection::CouchetteCar, 1 },
141 {
"r", Feature::Restaurant, VehicleSection::UnknownType, 1 },
142 {
"t", Feature::NoFeature, VehicleSection::ControlCar, 1 },
146static constexpr const UicClassificationSecondary secondary_87_table[] = {
147 {
"c", Feature::NoFeature, VehicleSection::CouchetteCar, 1 },
148 {
"e", Feature::NoFeature, VehicleSection::UnknownType, 2 },
149 {
"h", Feature::WheelchairAccessible, VehicleSection::UnknownType, 1 },
150 {
"u", Feature::AirConditioning, VehicleSection::UnknownType, 1 },
154 const char country[3];
155 const UicClassificationSecondary *begin;
156 const UicClassificationSecondary *end;
157}
static constexpr const secondary_tables[] = {
158 {
"54", std::begin(secondary_54_table), std::end(secondary_54_table) },
159 {
"80", std::begin(secondary_80_table), std::end(secondary_80_table) },
160 {
"81", std::begin(secondary_81_table), std::end(secondary_81_table) },
161 {
"85", std::begin(secondary_85_table), std::end(secondary_85_table) },
162 {
"87", std::begin(secondary_87_table), std::end(secondary_87_table) },
168 const auto it = std::find_if(std::begin(class_prefix_table), std::end(class_prefix_table), [coachClassification](
const auto &prefix) {
171 if (it != std::end(class_prefix_table)) {
172 decks = std::max(decks, (*it).deckCount);
176 for (
const auto &tab : secondary_tables) {
180 for (
auto it = tab.begin; it != tab.end; ++it) {
182 decks = std::max(decks, (*it).deckCount);
192 std::vector<Feature> f;
193 const auto it = std::find_if(std::begin(class_prefix_table), std::end(class_prefix_table), [coachClassification](
const auto &prefix) {
196 if (it != std::end(class_prefix_table) && (*it).feature != Feature::NoFeature) {
197 FeatureUtil::add(f,
Feature((*it).feature, Feature::Available));
200 const auto it2 = std::find_if(std::begin(number_prefix_table), std::end(number_prefix_table), [coachNumber](
const auto &prefix) {
203 if (it2 != std::end(number_prefix_table) && (*it2).feature != Feature::NoFeature) {
204 FeatureUtil::add(f,
Feature((*it2).feature, Feature::Available));
208 for (
const auto &tab : secondary_tables) {
212 for (
auto it = tab.begin; it != tab.end; ++it) {
213 if (coachClassification.
contains(
QLatin1String((*it).code)) && (*it).feature != Feature::NoFeature) {
214 FeatureUtil::add(f,
Feature((*it).feature, Feature::Available));
224 bool seenPassengerCar =
false;
225 const auto it = std::find_if(std::begin(class_prefix_table), std::end(class_prefix_table), [coachClassification](
const auto &prefix) {
226 return prefix.type != VehicleSection::UnknownType && coachClassification.
startsWith(
QLatin1String(prefix.prefix));
228 if (it != std::end(class_prefix_table)) {
229 if ((*it).type == VehicleSection::PassengerCar) {
230 seenPassengerCar =
true;
236 const auto it2 = std::find_if(std::begin(number_prefix_table), std::end(number_prefix_table), [coachNumber](
const auto &prefix) {
239 if (it2 != std::end(number_prefix_table)) {
240 if ((*it2).type == VehicleSection::PassengerCar) {
241 seenPassengerCar =
true;
248 for (
const auto &tab : secondary_tables) {
252 const auto it = std::find_if(tab.begin, tab.end, [coachClassification](
const auto &prefix) {
253 return prefix.type != VehicleSection::UnknownType && coachClassification.contains(QLatin1String(prefix.code));
256 if ((*it).type == VehicleSection::PassengerCar) {
257 seenPassengerCar =
true;
264 return seenPassengerCar ? VehicleSection::PassengerCar : VehicleSection::UnknownType;
An amenity, facility or other relevant property of a vehicle (train, bus, etc), vehicle part (e....
int deckCount(QStringView coachNumber, QStringView coachClassification)
Determine the number of decks from a UIC coachNumber and/or coachClassification.
QStringView countryCode(QStringView coachNumber)
Returns the UIC country code from coachNumber.
std::vector< Feature > features(QStringView coachNumber, QStringView coachClassification)
Determine coach features from a UIC coachNumber and/or coachClassification.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
Determine the vehicle type from a UIC coachNumber and/or coachClassification.
VehicleSection::Classes coachClass(QStringView coachNumber, QStringView coachClassification)
Determine the coach class(es) from a UIC coachNumber and/or coachClassification.
Query operations and data types for accessing realtime public transport information from online servi...
QStringView mid(qsizetype start, qsizetype length) const const
bool contains(QChar c, Qt::CaseSensitivity cs) const const
qsizetype size() const const
bool startsWith(QChar ch) const const