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");