7 #include <stdair/service/Logger.hpp>
8 #include <stdair/stdair_exceptions.hpp>
15 namespace bsc = boost::spirit::classic;
19 namespace InventoryParserHelper {
27 : _flightDate (ioFlightDate) {
51 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
98 const std::string lFlightTypeCodeStr (iStr, iStrEnd);
113 const std::string lFlightVisibilityCodeStr (iStr, iStrEnd);
128 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
167 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
183 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
184 if (lAirlineCode.size() == 2) {
422 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
471 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
743 std::ostringstream ostr;
756 std::string lClasses (iStr, iStrEnd);
780 unsigned int& ioNbOfFlights)
782 _nbOfFlights (ioNbOfFlights) {
896 unsigned int& ioNbOfFlights)
897 : _bomRoot (ioBomRoot), _flightDate (ioFlightDate),
898 _nbOfFlights (ioNbOfFlights) {
902 template<
typename ScannerT>
906 flight_date_list = *( not_to_be_parsed | flight_date )
910 bsc::lexeme_d[ bsc::comment_p(
"//") | bsc::comment_p(
"/*",
"*/")
914 flight_date = flight_key
921 flight_date_end = bsc::ch_p(
';')
925 >>
'/' >> airline_code
926 >>
'/' >> flight_number
941 bsc::lexeme_d[(
day_p)[bsc::assign_a(
self._flightDate._itDay)]
942 >> (
month_p)[bsc::assign_a(
self._flightDate._itMonth)]
943 >> (
year_p)[bsc::assign_a(
self._flightDate._itYear)]]
947 ( bsc::chseq_p(
"INT") | bsc::chseq_p(
"DOM") | bsc::chseq_p(
"GRD") )
950 flight_visibility_code =
951 ( bsc::chseq_p(
"HID") | bsc::chseq_p(
"PSD") )
954 leg_list = +(
'/' >> leg )
957 leg = !( operating_leg_details >>
';' )
958 >> leg_key >>
';' >> leg_details >> leg_cabin_list
961 operating_leg_details =
977 leg_cabin_list = +(
';' >> leg_cabin_details >> !bucket_list )
982 >>
',' >> (bsc::real_p)[
storeAU(
self._flightDate)]
983 >>
',' >> (bsc::real_p)[
storeUPR(
self._flightDate)]
985 >>
',' >> (bsc::real_p)[
storeNAV(
self._flightDate)]
986 >>
',' >> (bsc::real_p)[
storeGAV(
self._flightDate)]
987 >>
',' >> (bsc::ureal_p)[
storeACP(
self._flightDate)]
988 >>
',' >> (bsc::real_p)[
storeETB(
self._flightDate)]
993 (
hours_p)[bsc::assign_a(
self._flightDate._itHours)]
994 >> (
minutes_p)[bsc::assign_a(
self._flightDate._itMinutes)]
995 >> !((
seconds_p)[bsc::assign_a(
self._flightDate._itSeconds)])
999 bucket_list = +(
',' >> bucket_details )
1007 segment_list = +(
'/' >> segment )
1010 segment = segment_key >> segment_cabin_list
1017 segment_cabin_list =
1018 +(
';' >> segment_cabin_key >>
','
1019 >> segment_cabin_details >> class_list >> family_cabin_list )
1023 +(
';' >> family_cabin_details)
1030 segment_cabin_details =
1034 class_list = +(
',' >> class_key >>
'|' >> class_details )
1040 parent_subclass_code =
1050 (bsc::ureal_p)[
storeNego(
self._flightDate)]
1055 >>
':' >> !( parent_subclass_code )
1056 >>
':' >> !( class_protection )
1057 >>
':' >> (bsc::ureal_p)[
storeNoShow(
self._flightDate)]
1065 >>
':' >> !( class_nego )
1071 family_cabin_details =
1078 BOOST_SPIRIT_DEBUG_NODE (flight_date_list);
1079 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
1080 BOOST_SPIRIT_DEBUG_NODE (flight_date);
1081 BOOST_SPIRIT_DEBUG_NODE (flight_date_end);
1082 BOOST_SPIRIT_DEBUG_NODE (flight_key);
1083 BOOST_SPIRIT_DEBUG_NODE (airline_code);
1084 BOOST_SPIRIT_DEBUG_NODE (flight_number);
1085 BOOST_SPIRIT_DEBUG_NODE (flight_type_code);
1086 BOOST_SPIRIT_DEBUG_NODE (flight_visibility_code);
1087 BOOST_SPIRIT_DEBUG_NODE (date);
1088 BOOST_SPIRIT_DEBUG_NODE (leg_list);
1089 BOOST_SPIRIT_DEBUG_NODE (leg);
1090 BOOST_SPIRIT_DEBUG_NODE (operating_leg_details);
1091 BOOST_SPIRIT_DEBUG_NODE (leg_key);
1092 BOOST_SPIRIT_DEBUG_NODE (leg_details);
1093 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_list);
1094 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_details);
1095 BOOST_SPIRIT_DEBUG_NODE (bucket_list);
1096 BOOST_SPIRIT_DEBUG_NODE (bucket_details);
1097 BOOST_SPIRIT_DEBUG_NODE (time);
1098 BOOST_SPIRIT_DEBUG_NODE (segment_list);
1099 BOOST_SPIRIT_DEBUG_NODE (segment);
1100 BOOST_SPIRIT_DEBUG_NODE (segment_key);
1101 BOOST_SPIRIT_DEBUG_NODE (full_segment_cabin_details);
1102 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_list);
1103 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_key);
1104 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_details);
1105 BOOST_SPIRIT_DEBUG_NODE (class_list);
1106 BOOST_SPIRIT_DEBUG_NODE (class_key);
1107 BOOST_SPIRIT_DEBUG_NODE (parent_subclass_code);
1108 BOOST_SPIRIT_DEBUG_NODE (class_protection);
1109 BOOST_SPIRIT_DEBUG_NODE (class_nego);
1110 BOOST_SPIRIT_DEBUG_NODE (class_details);
1111 BOOST_SPIRIT_DEBUG_NODE (family_cabin_list);
1112 BOOST_SPIRIT_DEBUG_NODE (family_cabin_details);
1116 template<
typename ScannerT>
1117 bsc::rule<ScannerT>
const&
1119 return flight_date_list;
1133 : _filename (iFilename), _bomRoot (ioBomRoot),
1139 void InventoryFileParser::init() {
1144 if (!_startIterator) {
1145 std::ostringstream oMessage;
1146 oMessage <<
"The file " << _filename <<
" can not be open.";
1147 STDAIR_LOG_ERROR (oMessage.str());
1152 _endIterator = _startIterator.make_end();
1157 bool oResult =
false;
1159 STDAIR_LOG_DEBUG (
"Parsing inventory input file: " << _filename);
1169 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
1171 bsc::space_p - bsc::eol_p);
1176 const std::string hasBeenFullyReadStr = (info.full ==
true)?
"":
"not ";
1177 if (oResult ==
true) {
1178 STDAIR_LOG_DEBUG (
"Parsing of inventory input file: " << _filename
1179 <<
" succeeded: read " << info.length
1180 <<
" characters. The input file has "
1181 << hasBeenFullyReadStr
1182 <<
"been fully read. Stop point: " << info.stop);
1185 STDAIR_LOG_ERROR (
"Parsing of inventory input file: " << _filename
1186 <<
" failed: read " << info.length
1187 <<
" characters. The input file has "
1188 << hasBeenFullyReadStr
1189 <<
"been fully read. Stop point: " << info.stop);
1191 ": " + _filename +
" failed");
repeat_p_t airport_p(chset_t("0-9A-Z").derived(), 3, 3)
storeAU(FlightDateStruct &)
void operator()(unsigned int iNumber) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
chset_t class_code_p("A-Z")
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 4 > uint1_4_p_t
void operator()(double iReal) const
storeBoardingDate(FlightDateStruct &)
bounded2_p_t year_p(uint2_p.derived(), 0u, 99u)
storeBookingCounter(FlightDateStruct &)
void addAirport(const stdair::AirportCode_T &)
storeProtection(FlightDateStruct &)
void operator()(double iReal) const
BookingClassStruct _itBookingClass
void operator()(double iReal) const
void operator()(double iReal) const
void operator()(unsigned int iNumber) const
storeBoardingTime(FlightDateStruct &)
boost::spirit::classic::bounded< uint1_2_p_t, unsigned int > bounded1_2_p_t
void operator()(double iReal) const
storeLegBoardingPoint(FlightDateStruct &)
boost::spirit::classic::bounded< uint1_4_p_t, unsigned int > bounded1_4_p_t
bounded2_p_t day_p(uint2_p.derived(), 1u, 31u)
bounded2_p_t seconds_p(uint2_p.derived(), 0u, 59u)
bounded2_p_t month_p(uint2_p.derived(), 1u, 12u)
storeSegmentOffPoint(FlightDateStruct &)
stdair::NbOfBookings_T _nbOfStaffBookings
storeNbOfGroupBkgs(FlightDateStruct &)
void operator()(double iReal) const
void operator()(double iReal) const
bounded1_3_p_t stay_duration_p(uint1_3_p.derived(), 0u, 999u)
stdair::NbOfBookings_T _nbOfBookings
LegCabinStructList_T _cabinList
stdair::AuthorizationLevel_T _protection
void operator()(unsigned int iNumber) const
storeSaleableCapacity(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(char iChar) const
boost::spirit::classic::impl::loop_traits< chset_t, unsigned int, unsigned int >::type repeat_p_t
storeNoShow(FlightDateStruct &)
storeYieldUpperRange(FlightDateStruct &)
stdair::AirportCode_T _boardingPoint
storeOffDate(FlightDateStruct &)
boost::spirit::classic::chset< char_t > chset_t
void operator()(iterator_t iStr, iterator_t iStrEnd) const
EN_FlightTypeCode getCode() const
void operator()(char iChar) const
stdair::SubclassCode_T _subclassCode
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeFlightDate(FlightDateStruct &)
storeFlightVisibilityCode(FlightDateStruct &)
ParserSemanticAction(FlightDateStruct &)
void operator()(double iReal) const
boost::spirit::classic::rule< ScannerT > const & start() const
storeNbOfStaffBkgs(FlightDateStruct &)
EN_FlightVisibilityCode getCode() const
void operator()(double iReal) const
stdair::AirlineCode_T _airlineCode
storeParentClassCode(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 2 > uint1_2_p_t
storeSnapshotDate(FlightDateStruct &)
boost::spirit::classic::bounded< uint1_3_p_t, unsigned int > bounded1_3_p_t
repeat_p_t class_code_list_p(chset_t("A-Z").derived(), 1, 26)
stdair::AirportCode_T _offPoint
storeUPR(FlightDateStruct &)
void operator()(double iReal) const
storeSegmentCabinCode(FlightDateStruct &)
stdair::Duration_T _offTime
BucketStructList_T _bucketList
void operator()(double iReal) const
storeBucketAvaibality(FlightDateStruct &)
storeOffTime(FlightDateStruct &)
void operator()(double iReal) const
stdair::CabinCapacity_T _saleableCapacity
SegmentStructList_T _segmentList
stdair::FlightNumber_T _flightNumber
stdair::AirportCode_T _boardingPoint
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 3 > uint1_3_p_t
void operator()(double iReal) const
bounded1_4_p_t flight_number_p(uint1_4_p.derived(), 0u, 9999u)
BookingClassStructList_T _classList
void operator()(double iReal) const
stdair::Availability_T _nav
void operator()(double iReal) const
stdair::CabinCode_T _cabinCode
storeCumulatedProtection(FlightDateStruct &)
bounded2_p_t minutes_p(uint2_p.derived(), 0u, 59u)
definition(InventoryParser const &self)
storeNbOfPendingGroupBkgs(FlightDateStruct &)
stdair::OverbookingRate_T _overbookingPercentage
void operator()(double iReal) const
SegmentCabinStructList_T _cabinList
stdair::FlightNumber_T _flightNumber
stdair::BomRoot & _bomRoot
void operator()(double iReal) const
stdair::AirlineCode_T _airlineCode
chset_t passenger_type_p("A-Z")
void operator()(double iReal) const
storeNego(FlightDateStruct &)
storeNbOfBkgs(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::NbOfBookings_T _nbOfPendingGroupBookings
unsigned int & _nbOfFlights
stdair::NbOfSeats_T _nego
void operator()(unsigned int iNumber) const
stdair::NbOfBookings_T _nbOfBookings
storeOperatingAirlineCode(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::Date_T _flightDate
stdair::AuthorizationLevel_T _au
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::OverbookingRate_T _noShowPercentage
storeSubclassCode(FlightDateStruct &)
stdair::CabinCapacity_T _availability
stdair::NbOfBookings_T _nbOfGroupBookings
boost::spirit::classic::file_iterator< char_t > iterator_t
repeat_p_t dow_p(chset_t("0-1").derived().derived(), 7, 7)
storeOverbooking(FlightDateStruct &)
stdair::AirportCode_T _offPoint
storeNAV(FlightDateStruct &)
stdair::OverbookingRate_T _acp
stdair::ClassCode_T _classCode
void operator()(double iReal) const
boost::spirit::classic::uint_parser< unsigned int, 10, 2, 2 > uint2_p_t
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::NbOfBookings_T _etb
void operator()(double iReal) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::Duration_T _boardingTime
void operator()(double iReal) const
storeSeatIndex(FlightDateStruct &)
stdair::Yield_T _yieldRangeUpperValue
void operator()(double iReal) const
storeLegOffPoint(FlightDateStruct &)
stdair::NbOfBookings_T _nbOfBookings
boost::spirit::classic::bounded< uint2_p_t, unsigned int > bounded2_p_t
storeParentSubclassCode(FlightDateStruct &)
stdair::ClassList_String_T _classes
void operator()(double iReal) const
doEndFlightDate(stdair::BomRoot &, FlightDateStruct &, unsigned int &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
stdair::ClassCode_T _parentClassCode
SegmentCabinStruct _itSegmentCabin
stdair::NbOfBookings_T _nbOfWLBookings
void operator()(int iCode) const
FlightVisibilityCode _flightVisibilityCode
boost::spirit::classic::uint_parser< unsigned int, 10, 4, 4 > uint4_p_t
storeSegmentAvailability(FlightDateStruct &)
storeClassETB(FlightDateStruct &)
FareFamilyStructList_T _fareFamilies
repeat_p_t airline_code_p(chset_t("0-9A-Z").derived(), 2, 3)
stdair::SeatIndex_T _seatIndex
storeSegmentBoardingPoint(FlightDateStruct &)
storeOperatingFlightNumber(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeAirlineCode(FlightDateStruct &)
storeFamilyCode(FlightDateStruct &)
storeLegCabinCode(FlightDateStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeACP(FlightDateStruct &)
storeClassAvailability(FlightDateStruct &)
void operator()(char iChar) const
stdair::Availability_T _segmentAvailability
stdair::Date_T getDate() const
bounded1_2_p_t hours_p(uint1_2_p.derived(), 0u, 24u)
stdair::Date_T _boardingDate
FlightDateStruct & _flightDate
storeETB(FlightDateStruct &)
storeClassCode(FlightDateStruct &)
FareFamilyStruct _itFareFamily
void operator()(double iReal) const
stdair::SubclassCode_T _parentSubclassCode
stdair::Availability_T _netRevenueAvailability
stdair::NbOfBookings_T _etb
stdair::AuthorizationLevel_T _cumulatedProtection
void operator()(double iReal) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
boost::spirit::classic::int_parser< unsigned int, 10, 1, 1 > int1_p_t
stdair::Duration_T getTime() const
storeRevenueAvailability(FlightDateStruct &)
void operator()(char iChar) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeFlightNumber(FlightDateStruct &)
stdair::CabinCode_T _cabinCode
storeGAV(FlightDateStruct &)
InventoryParser(stdair::BomRoot &, FlightDateStruct &, unsigned int &)
LegCabinStruct _itLegCabin
stdair::Availability_T _gav
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(double iReal) const
storeFlightTypeCode(FlightDateStruct &)
stdair::FamilyCode_T _familyCode
FlightTypeCode _flightTypeCode
chset_t cabin_code_p("A-Z")
stdair::Availability_T _netClassAvailability
storeSegmentCabinBookingCounter(FlightDateStruct &)
InventoryFileParser(stdair::BomRoot &, const stdair::Filename_T &iInventoryInputFilename)
storeFClasses(FlightDateStruct &)
storeNbOfWLBkgs(FlightDateStruct &)