7 #include <stdair/basic/BasFileMgr.hpp>
8 #include <stdair/bom/BomRoot.hpp>
9 #include <stdair/service/Logger.hpp>
15 namespace bsc = boost::spirit::classic;
19 namespace ScheduleParserHelper {
27 : _flightPeriod (ioFlightPeriod) {
39 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
87 const stdair::DateOffset_T oneDay (1);
110 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) {
315 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
328 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
352 std::string lClasses (iStr, iStrEnd);
376 std::ostringstream ostr;
390 const std::string lKey (iStr, iStrEnd);
404 const std::string lKey (iStr, iStrEnd);
417 std::string lClasses (iStr, iStrEnd);
443 _bomRoot (ioBomRoot) {
535 : _bomRoot (ioBomRoot),
536 _flightPeriod (ioFlightPeriod) {
540 template<
typename ScannerT>
544 flight_period_list = *(not_to_be_parsed
548 not_to_be_parsed =bsc::
549 lexeme_d[bsc::comment_p(
"//") |bsc::comment_p(
"/*",
"*/")
552 flight_period = flight_key
554 >>
';' >> segment_section
555 >> flight_period_end[
doEndFlight (
self._bomRoot,
self._flightPeriod)]
562 flight_key = airline_code
563 >>
';' >> flight_number
566 >>
';' >> dow[
storeDow(
self._flightPeriod)]
578 lexeme_d[(
year_p)[bsc::assign_a(
self._flightPeriod._itYear)]
580 >> (
month_p)[bsc::assign_a(
self._flightPeriod._itMonth)]
582 >> (
day_p)[bsc::assign_a(
self._flightPeriod._itDay)]
586 dow =bsc::lexeme_d[
dow_p ]
589 leg = !( operating_leg_details >>
';' )
591 >>
';' >> leg_details
592 >> +(
';' >> leg_cabin_details )
600 operating_leg_details =
617 lexeme_d[(
hours_p)[bsc::assign_a(
self._flightPeriod._itHours)]
619 >> (
minutes_p)[bsc::assign_a(
self._flightPeriod._itMinutes)]
621 >> (
seconds_p)[bsc::assign_a(
self._flightPeriod._itSeconds)])
625 date_offset =bsc::ch_p(
'/')
626 >> (
int1_p)[bsc::assign_a(
self._flightPeriod._dateOffset)]
640 generic_segment | specific_segment_list
643 generic_segment =bsc::
645 >> +(
';' >> segment_cabin_details)
648 specific_segment_list =bsc::
650 >> +(
';' >> segment_key >> full_segment_cabin_details)
653 full_segment_cabin_details =
654 +(
';' >> segment_cabin_details)
657 segment_cabin_details =
660 >> *(
';' >> family_cabin_details)
663 family_cabin_details =
674 BOOST_SPIRIT_DEBUG_NODE (flight_period_list);
675 BOOST_SPIRIT_DEBUG_NODE (flight_period);
676 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
677 BOOST_SPIRIT_DEBUG_NODE (flight_period_end);
678 BOOST_SPIRIT_DEBUG_NODE (flight_key);
679 BOOST_SPIRIT_DEBUG_NODE (airline_code);
680 BOOST_SPIRIT_DEBUG_NODE (flight_number);
681 BOOST_SPIRIT_DEBUG_NODE (date);
682 BOOST_SPIRIT_DEBUG_NODE (dow);
683 BOOST_SPIRIT_DEBUG_NODE (leg);
684 BOOST_SPIRIT_DEBUG_NODE (leg_key);
685 BOOST_SPIRIT_DEBUG_NODE (leg_details);
686 BOOST_SPIRIT_DEBUG_NODE (time);
687 BOOST_SPIRIT_DEBUG_NODE (date_offset);
688 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_details);
689 BOOST_SPIRIT_DEBUG_NODE (segment_section);
690 BOOST_SPIRIT_DEBUG_NODE (segment_key);
691 BOOST_SPIRIT_DEBUG_NODE (generic_segment);
692 BOOST_SPIRIT_DEBUG_NODE (specific_segment_list);
693 BOOST_SPIRIT_DEBUG_NODE (full_segment_cabin_details);
694 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_details);
695 BOOST_SPIRIT_DEBUG_NODE (family_cabin_details);
699 template<
typename ScannerT>
700 bsc::rule<ScannerT>
const&
702 return flight_period_list;
717 const stdair::Filename_T& iFilename)
718 : _filename (iFilename), _bomRoot (ioBomRoot) {
723 void FlightPeriodFileParser::init() {
725 const bool doesExistAndIsReadable =
726 stdair::BasFileMgr::doesExistAndIsReadable (_filename);
728 if (doesExistAndIsReadable ==
false) {
729 STDAIR_LOG_ERROR (
"The schedule file " << _filename
730 <<
" does not exist or can not be read.");
733 +
" does not exist or can not be read");
740 if (!_startIterator) {
741 STDAIR_LOG_ERROR (
"The schedule file " << _filename <<
" can not be open."
744 throw ScheduleInputFileNotFoundException (
"The file " + _filename
745 +
" does not exist or can not be read");
749 _endIterator = _startIterator.make_end();
754 bool oResult =
false;
756 STDAIR_LOG_DEBUG (
"Parsing schedule input file: " << _filename);
765 bsc::parse_info<iterator_t> info =
766 bsc::parse (_startIterator, _endIterator, lFPParser,
767 bsc::space_p - bsc::eol_p);
772 const std::string hasBeenFullyReadStr = (info.full ==
true)?
"":
"not ";
773 if (oResult ==
true) {
774 STDAIR_LOG_DEBUG (
"Parsing of schedule input file: " << _filename
775 <<
" succeeded: read " << info.length
776 <<
" characters. The input file has "
777 << hasBeenFullyReadStr
778 <<
"been fully read. Stop point: " << info.stop);
782 STDAIR_LOG_ERROR (
"Parsing of schedule input file: " << _filename
783 <<
" failed: read " << info.length
784 <<
" characters. The input file has "
785 << hasBeenFullyReadStr
786 <<
"been fully read. Stop point: " << info.stop);