7 #include <stdair/stdair_exceptions.hpp>
8 #include <stdair/stdair_types.hpp>
9 #include <stdair/bom/BomRoot.hpp>
10 #include <stdair/service/Logger.hpp>
17 namespace bsc = boost::spirit::classic;
21 namespace ScheduleParserHelper {
29 : _flightPeriod (ioFlightPeriod) {
41 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
87 const stdair::DateOffset_T oneDay (1);
111 stdair::DOW_String_T lDow (iStr, iStrEnd);
124 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
153 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
169 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
170 if (lAirlineCode.size() == 2) {
314 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
327 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
351 std::string lClasses (iStr, iStrEnd);
375 std::ostringstream ostr;
389 const std::string lKey (iStr, iStrEnd);
403 const std::string lKey (iStr, iStrEnd);
416 std::string lClasses (iStr, iStrEnd);
439 _bomRoot (ioBomRoot) {
531 : _bomRoot (ioBomRoot),
532 _flightPeriod (ioFlightPeriod) {
536 template<
typename ScannerT>
540 flight_period_list = *( not_to_be_parsed | flight_period )
544 bsc::lexeme_d[ bsc::comment_p(
"//") | bsc::comment_p(
"/*",
"*/")
548 flight_period = flight_key
550 >>
';' >> segment_section
551 >> flight_period_end[
doEndFlight (
self._bomRoot,
self._flightPeriod)]
554 flight_period_end = bsc::ch_p(
';')
557 flight_key = airline_code
558 >>
';' >> flight_number
561 >>
';' >> dow[
storeDow(
self._flightPeriod)]
573 bsc::lexeme_d[(
year_p)[bsc::assign_a(
self._flightPeriod._itYear)]
574 >>
'-' >> (
month_p)[bsc::assign_a(
self._flightPeriod._itMonth)]
575 >>
'-' >> (
day_p)[bsc::assign_a(
self._flightPeriod._itDay)]]
578 dow = bsc::lexeme_d[
dow_p ]
581 leg = !( operating_leg_details >>
';' )
583 >>
';' >> leg_details
584 >> +(
';' >> leg_cabin_details )
592 operating_leg_details =
609 bsc::lexeme_d[(
hours_p)[bsc::assign_a(
self._flightPeriod._itHours)]
610 >>
':' >> (
minutes_p)[bsc::assign_a(
self._flightPeriod._itMinutes)]
611 >> !(
':' >> (
seconds_p)[bsc::assign_a(
self._flightPeriod._itSeconds)])]
616 >> (
int1_p)[bsc::assign_a(
self._flightPeriod._dateOffset)]
631 generic_segment | specific_segment_list
636 >> +(
';' >> segment_cabin_details)
639 specific_segment_list =
641 >> +(
';' >> segment_key >> full_segment_cabin_details)
644 full_segment_cabin_details =
645 +(
';' >> segment_cabin_details)
648 segment_cabin_details =
651 >> +(
';' >> family_cabin_details)
654 family_cabin_details =
665 BOOST_SPIRIT_DEBUG_NODE (flight_period_list);
666 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
667 BOOST_SPIRIT_DEBUG_NODE (flight_period);
668 BOOST_SPIRIT_DEBUG_NODE (flight_period_end);
669 BOOST_SPIRIT_DEBUG_NODE (flight_key);
670 BOOST_SPIRIT_DEBUG_NODE (airline_code);
671 BOOST_SPIRIT_DEBUG_NODE (flight_number);
672 BOOST_SPIRIT_DEBUG_NODE (date);
673 BOOST_SPIRIT_DEBUG_NODE (dow);
674 BOOST_SPIRIT_DEBUG_NODE (leg);
675 BOOST_SPIRIT_DEBUG_NODE (leg_key);
676 BOOST_SPIRIT_DEBUG_NODE (leg_details);
677 BOOST_SPIRIT_DEBUG_NODE (time);
678 BOOST_SPIRIT_DEBUG_NODE (date_offset);
679 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_details);
680 BOOST_SPIRIT_DEBUG_NODE (segment_section);
681 BOOST_SPIRIT_DEBUG_NODE (segment_key);
682 BOOST_SPIRIT_DEBUG_NODE (generic_segment);
683 BOOST_SPIRIT_DEBUG_NODE (specific_segment_list);
684 BOOST_SPIRIT_DEBUG_NODE (full_segment_cabin_details);
685 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_details);
686 BOOST_SPIRIT_DEBUG_NODE (family_cabin_details);
690 template<
typename ScannerT>
691 bsc::rule<ScannerT>
const&
693 return flight_period_list;
707 const stdair::Filename_T& iFilename)
708 : _filename (iFilename), _bomRoot (ioBomRoot) {
713 void FlightPeriodFileParser::init() {
718 if (!_startIterator) {
719 std::ostringstream oMessage;
720 oMessage <<
"The file " << _filename <<
" can not be open." << std::endl;
721 STDAIR_LOG_ERROR (oMessage.str());
726 _endIterator = _startIterator.make_end();
731 bool oResult =
false;
733 STDAIR_LOG_DEBUG (
"Parsing schedule input file: " << _filename);
741 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
743 bsc::space_p - bsc::eol_p);
748 const bool isFull = info.full;
750 const std::string hasBeenFullyReadStr = (isFull ==
true)?
"":
"not ";
751 if (oResult ==
true && isFull ==
true) {
752 STDAIR_LOG_DEBUG (
"Parsing of schedule input file: " << _filename
753 <<
" succeeded: read " << info.length
754 <<
" characters. The input file has "
755 << hasBeenFullyReadStr
756 <<
"been fully read. Stop point: " << info.stop);
759 STDAIR_LOG_ERROR (
"Parsing of schedule input file: " << _filename
760 <<
" failed: read " << info.length
761 <<
" characters. The input file has "
762 << hasBeenFullyReadStr
763 <<
"been fully read. Stop point: " << info.stop);
765 + _filename +
" failed.");