$treeview $search $mathjax
AirInv Logo  1.00.1
$projectbrief
$projectbrief
$searchbox

InventoryParserHelper.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 // StdAir
00007 #include <stdair/service/Logger.hpp>
00008 #include <stdair/stdair_exceptions.hpp>
00009 // Airinv
00010 #include <airinv/command/InventoryBuilder.hpp>
00011 //#define BOOST_SPIRIT_DEBUG
00012 #include <airinv/command/InventoryParserHelper.hpp>
00013 
00014 //
00015 namespace bsc = boost::spirit::classic;
00016 
00017 namespace AIRINV {
00018 
00019   namespace InventoryParserHelper {
00020       
00021     // //////////////////////////////////////////////////////////////////
00022     //  Semantic actions
00023     // //////////////////////////////////////////////////////////////////
00024 
00025     ParserSemanticAction::
00026     ParserSemanticAction (FlightDateStruct& ioFlightDate)
00027       : _flightDate (ioFlightDate) {
00028     }      
00029 
00030     // //////////////////////////////////////////////////////////////////
00031     storeSnapshotDate::
00032     storeSnapshotDate (FlightDateStruct& ioFlightDate)
00033       : ParserSemanticAction (ioFlightDate) {
00034     }
00035     
00036     // //////////////////////////////////////////////////////////////////
00037     void storeSnapshotDate::operator() (iterator_t iStr,
00038                                         iterator_t iStrEnd) const {
00039       _flightDate._flightDate = _flightDate.getDate();
00040     }
00041       
00042     // //////////////////////////////////////////////////////////////////
00043     storeAirlineCode::
00044     storeAirlineCode (FlightDateStruct& ioFlightDate)
00045       : ParserSemanticAction (ioFlightDate) {
00046     }
00047     
00048     // //////////////////////////////////////////////////////////////////
00049     void storeAirlineCode::operator() (iterator_t iStr,
00050                                        iterator_t iStrEnd) const {
00051       const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
00052       _flightDate._airlineCode = lAirlineCode;
00053                 
00054       // As that's the beginning of a new flight, all the list must be reset
00055       // 1. Leg branch of the tree
00056       _flightDate._legList.clear();
00057       _flightDate._itLeg._cabinList.clear();
00058       _flightDate._itLegCabin._bucketList.clear();
00059       _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00060 
00061       // 2. Segment branch of the tree
00062       _flightDate._segmentList.clear();
00063       _flightDate._itSegment._cabinList.clear();
00064       _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00065       _flightDate._itSegmentCabin._fareFamilies.clear();
00066       _flightDate._itBookingClass._classCode = "";
00067     }
00068       
00069     // //////////////////////////////////////////////////////////////////
00070     storeFlightNumber::storeFlightNumber (FlightDateStruct& ioFlightDate)
00071       : ParserSemanticAction (ioFlightDate) {
00072     }
00073 
00074     // //////////////////////////////////////////////////////////////////
00075     void storeFlightNumber::operator() (unsigned int iNumber) const { 
00076       _flightDate._flightNumber = iNumber;
00077     }
00078 
00079     // //////////////////////////////////////////////////////////////////
00080     storeFlightDate::storeFlightDate (FlightDateStruct& ioFlightDate)
00081       : ParserSemanticAction (ioFlightDate) {
00082     }
00083     
00084     // //////////////////////////////////////////////////////////////////
00085     void storeFlightDate::operator() (iterator_t iStr,
00086                                       iterator_t iStrEnd) const {
00087       _flightDate._flightDate = _flightDate.getDate();
00088     }
00089       
00090     // //////////////////////////////////////////////////////////////////
00091     storeFlightTypeCode::storeFlightTypeCode (FlightDateStruct& ioFlightDate)
00092       : ParserSemanticAction (ioFlightDate) {
00093     }
00094     
00095     // //////////////////////////////////////////////////////////////////
00096     void storeFlightTypeCode::operator() (iterator_t iStr,
00097                                           iterator_t iStrEnd) const {
00098       const std::string lFlightTypeCodeStr (iStr, iStrEnd);
00099       const FlightTypeCode lFlightTypeCode (lFlightTypeCodeStr);
00100       _flightDate._flightTypeCode = lFlightTypeCode.getCode();
00101       //STDAIR_LOG_DEBUG ("FlightType code: " << lFlightTypeCode);
00102     }
00103 
00104     // //////////////////////////////////////////////////////////////////
00105     storeFlightVisibilityCode::
00106     storeFlightVisibilityCode (FlightDateStruct& ioFlightDate)
00107       : ParserSemanticAction (ioFlightDate) {
00108     }
00109     
00110     // //////////////////////////////////////////////////////////////////
00111     void storeFlightVisibilityCode::operator() (iterator_t iStr,
00112                                                 iterator_t iStrEnd) const {
00113       const std::string lFlightVisibilityCodeStr (iStr, iStrEnd);
00114       const FlightVisibilityCode lFlightVisibilityCode(lFlightVisibilityCodeStr);
00115       _flightDate._flightVisibilityCode = lFlightVisibilityCode.getCode();
00116       //STDAIR_LOG_DEBUG ("FlightVisibility code: " << lFlightVisibilityCode);
00117     }
00118 
00119     // //////////////////////////////////////////////////////////////////
00120     storeLegBoardingPoint::
00121     storeLegBoardingPoint (FlightDateStruct& ioFlightDate)
00122       : ParserSemanticAction (ioFlightDate) {
00123     }
00124 
00125     // //////////////////////////////////////////////////////////////////
00126     void storeLegBoardingPoint::operator() (iterator_t iStr,
00127                                             iterator_t iStrEnd) const {
00128       stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
00129 
00130       // ///////////////////
00131       // If this is not the first leg-date of the flight-date,
00132       // the already parsed leg-date must be added to the flight-date.
00133       if (_flightDate._itLeg._cabinList.empty() == false) {
00134         _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00135         _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
00136         _flightDate._legList.push_back (_flightDate._itLeg);
00137       }
00138 
00139       // As that's the beginning of a new leg-date,
00140       // (re-)initialise the leg-cabin branch of the tree
00141       _flightDate._itLeg._cabinList.clear();
00142       _flightDate._itLegCabin._cabinCode = "";
00143       _flightDate._itLegCabin._bucketList.clear();
00144       _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00145 
00146       // ///////////////////
00147       // Set the (default) operating airline and flight number
00148       _flightDate._itLeg._airlineCode = _flightDate._airlineCode;
00149       _flightDate._itLeg._flightNumber = _flightDate._flightNumber;
00150       
00151       // Set the (new) boarding point
00152       _flightDate._itLeg._boardingPoint = lBoardingPoint;
00153       
00154       // Add the airport code if it is not already stored in the airport lists
00155       _flightDate.addAirport (lBoardingPoint);
00156     }
00157 
00158     // //////////////////////////////////////////////////////////////////
00159     storeLegOffPoint::
00160     storeLegOffPoint (FlightDateStruct& ioFlightDate)
00161       : ParserSemanticAction (ioFlightDate) {
00162     }
00163 
00164     // //////////////////////////////////////////////////////////////////
00165     void storeLegOffPoint::operator() (iterator_t iStr,
00166                                        iterator_t iStrEnd) const {
00167       stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
00168       _flightDate._itLeg._offPoint = lOffPoint;
00169 
00170       // Add the airport code if it is not already stored in the airport lists
00171       _flightDate.addAirport (lOffPoint);
00172     }  
00173 
00174     // //////////////////////////////////////////////////////////////////
00175     storeOperatingAirlineCode::
00176     storeOperatingAirlineCode (FlightDateStruct& ioFlightDate)
00177       : ParserSemanticAction (ioFlightDate) {
00178     }
00179     
00180     // //////////////////////////////////////////////////////////////////
00181     void storeOperatingAirlineCode::operator() (iterator_t iStr,
00182                                                 iterator_t iStrEnd) const { 
00183       const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
00184       if (lAirlineCode.size() == 2) {
00185         _flightDate._itLeg._airlineCode = lAirlineCode;
00186       }
00187       //STDAIR_LOG_DEBUG ("Airline code: " << lAirlineCode);
00188     }
00189 
00190     // //////////////////////////////////////////////////////////////////
00191     storeOperatingFlightNumber::
00192     storeOperatingFlightNumber (FlightDateStruct& ioFlightDate)
00193       : ParserSemanticAction (ioFlightDate) {
00194     }
00195 
00196     // //////////////////////////////////////////////////////////////////
00197     void storeOperatingFlightNumber::operator() (unsigned int iNumber) const { 
00198       _flightDate._itLeg._flightNumber = iNumber;
00199       //STDAIR_LOG_DEBUG ("Flight number: " << iNumber);
00200     }
00201 
00202 
00203     // //////////////////////////////////////////////////////////////////
00204     storeBoardingDate::storeBoardingDate (FlightDateStruct& ioFlightDate)
00205       : ParserSemanticAction (ioFlightDate) {
00206     }
00207     
00208     // //////////////////////////////////////////////////////////////////
00209     void storeBoardingDate::operator() (iterator_t iStr,
00210                                         iterator_t iStrEnd) const {
00211       _flightDate._itLeg._boardingDate = _flightDate.getDate();
00212     }
00213 
00214     // //////////////////////////////////////////////////////////////////
00215     storeBoardingTime::storeBoardingTime (FlightDateStruct& ioFlightDate)
00216       : ParserSemanticAction (ioFlightDate) {
00217     }
00218     
00219     // //////////////////////////////////////////////////////////////////
00220     void storeBoardingTime::operator() (iterator_t iStr,
00221                                         iterator_t iStrEnd) const {
00222       _flightDate._itLeg._boardingTime = _flightDate.getTime();
00223         
00224       // Reset the number of seconds
00225       _flightDate._itSeconds = 0;
00226 
00227       // Reset the date off-set
00228       _flightDate._dateOffSet = 0;
00229     }
00230 
00231     // //////////////////////////////////////////////////////////////////
00232     storeOffDate::storeOffDate (FlightDateStruct& ioFlightDate)
00233       : ParserSemanticAction (ioFlightDate) {
00234     }
00235     
00236     // //////////////////////////////////////////////////////////////////
00237     void storeOffDate::operator() (iterator_t iStr, iterator_t iStrEnd) const {
00238       _flightDate._itLeg._offDate = _flightDate.getDate();
00239     }
00240 
00241     // //////////////////////////////////////////////////////////////////
00242     storeOffTime::storeOffTime (FlightDateStruct& ioFlightDate)
00243       : ParserSemanticAction (ioFlightDate) {
00244     }
00245     
00246     // //////////////////////////////////////////////////////////////////
00247     void storeOffTime::operator() (iterator_t iStr, iterator_t iStrEnd) const {
00248       _flightDate._itLeg._offTime = _flightDate.getTime();
00249         
00250       // Reset the number of seconds
00251       _flightDate._itSeconds = 0;
00252     }
00253 
00254     // //////////////////////////////////////////////////////////////////
00255     storeLegCabinCode::storeLegCabinCode (FlightDateStruct& ioFlightDate)
00256       : ParserSemanticAction (ioFlightDate) {
00257     }
00258     
00259     // //////////////////////////////////////////////////////////////////
00260     void storeLegCabinCode::operator() (char iChar) const { 
00261 
00262       // ///////////////////
00263       // If this is not the first leg-cabin of the leg-date,
00264       // the already parsed leg-cabin must be added to the leg-date.
00265       if (_flightDate._itLegCabin._cabinCode != "") {
00266         if (_flightDate._itLegCabin._bucketList.empty() == false) {
00267           _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00268         }
00269         _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
00270       }
00271 
00272       // (Re-)initialise the leg-cabin branch of the tree
00273       _flightDate._itLegCabin._bucketList.clear();
00274       _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00275 
00276       
00277       // ///////////////////
00278       _flightDate._itLegCabin._cabinCode = iChar; 
00279       //std::cout << "Cabin code: " << iChar << std::endl;
00280     }
00281 
00282     // //////////////////////////////////////////////////////////////////
00283     storeSaleableCapacity::
00284     storeSaleableCapacity (FlightDateStruct& ioFlightDate)
00285       : ParserSemanticAction (ioFlightDate) {
00286     }
00287     
00288     // //////////////////////////////////////////////////////////////////
00289     void storeSaleableCapacity::operator() (double iReal) const { 
00290       _flightDate._itLegCabin._saleableCapacity = iReal; 
00291       //std::cout << "Saleable capacity: " << iReal << std::endl;
00292     }
00293 
00294     // //////////////////////////////////////////////////////////////////
00295     storeAU::storeAU (FlightDateStruct& ioFlightDate)
00296       : ParserSemanticAction (ioFlightDate) {
00297     }
00298     
00299     // //////////////////////////////////////////////////////////////////
00300     void storeAU::operator() (double iReal) const {
00301       _flightDate._itLegCabin._au = iReal; 
00302       //std::cout << "AU: " << iReal << std::endl;
00303     }
00304 
00305     // //////////////////////////////////////////////////////////////////
00306     storeUPR::storeUPR (FlightDateStruct& ioFlightDate)
00307       : ParserSemanticAction (ioFlightDate) {
00308     }
00309     
00310     // //////////////////////////////////////////////////////////////////
00311     void storeUPR::operator() (double iReal) const {
00312       _flightDate._itLegCabin._upr = iReal; 
00313       //std::cout << "UPR: " << iReal << std::endl;
00314     }
00315 
00316     // //////////////////////////////////////////////////////////////////
00317     storeBookingCounter::storeBookingCounter (FlightDateStruct& ioFlightDate)
00318       : ParserSemanticAction (ioFlightDate) {
00319     }
00320     
00321     // //////////////////////////////////////////////////////////////////
00322     void storeBookingCounter::operator() (double iReal) const {
00323       _flightDate._itLegCabin._nbOfBookings = iReal; 
00324       //std::cout << "Nb of bookings: " << iReal << std::endl;
00325     }
00326 
00327     // //////////////////////////////////////////////////////////////////
00328     storeNAV::storeNAV (FlightDateStruct& ioFlightDate)
00329       : ParserSemanticAction (ioFlightDate) {
00330     }
00331     
00332     // //////////////////////////////////////////////////////////////////
00333     void storeNAV::operator() (double iReal) const {
00334       _flightDate._itLegCabin._nav = iReal; 
00335       //std::cout << "NAV: " << iReal << std::endl;
00336     }
00337 
00338     // //////////////////////////////////////////////////////////////////
00339     storeGAV::storeGAV (FlightDateStruct& ioFlightDate)
00340       : ParserSemanticAction (ioFlightDate) {
00341     }
00342     
00343     // //////////////////////////////////////////////////////////////////
00344     void storeGAV::operator() (double iReal) const {
00345       _flightDate._itLegCabin._gav = iReal; 
00346       //std::cout << "GAV: " << iReal << std::endl;
00347     }
00348 
00349     // //////////////////////////////////////////////////////////////////
00350     storeACP::storeACP (FlightDateStruct& ioFlightDate)
00351       : ParserSemanticAction (ioFlightDate) {
00352     }
00353     
00354     // //////////////////////////////////////////////////////////////////
00355     void storeACP::operator() (double iReal) const {
00356       _flightDate._itLegCabin._acp = iReal; 
00357       //std::cout << "ACP: " << iReal << std::endl;
00358     }
00359 
00360     // //////////////////////////////////////////////////////////////////
00361     storeETB::storeETB (FlightDateStruct& ioFlightDate)
00362       : ParserSemanticAction (ioFlightDate) {
00363     }
00364     
00365     // //////////////////////////////////////////////////////////////////
00366     void storeETB::operator() (double iReal) const { 
00367       _flightDate._itLegCabin._etb = iReal; 
00368       //std::cout << "ETB: " << iReal << std::endl;
00369     }
00370 
00371     // //////////////////////////////////////////////////////////////////
00372     storeYieldUpperRange::storeYieldUpperRange(FlightDateStruct& ioFlightDate)
00373       : ParserSemanticAction (ioFlightDate) {
00374     }
00375     
00376     // //////////////////////////////////////////////////////////////////
00377     void storeYieldUpperRange::operator() (double iReal) const {
00378       // If this is not the first bucket of the leg-cabin,
00379       // the already parsed bucket must be added to the leg-cabin.
00380       if (_flightDate._itBucket._yieldRangeUpperValue != 0.0) {
00381         _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00382       }
00383 
00384 
00385       // ///////////////////
00386       _flightDate._itBucket._yieldRangeUpperValue = iReal; 
00387       //std::cout << "Yield Upper Range Value: " << iReal << std::endl;
00388     }
00389 
00390     // //////////////////////////////////////////////////////////////////
00391     storeBucketAvaibality::
00392     storeBucketAvaibality (FlightDateStruct& ioFlightDate)
00393       : ParserSemanticAction (ioFlightDate) {
00394     }
00395     
00396     // //////////////////////////////////////////////////////////////////
00397     void storeBucketAvaibality::operator() (double iReal) const {
00398       _flightDate._itBucket._availability = iReal; 
00399       //std::cout << "Availability: " << iReal << std::endl;
00400     }
00401 
00402     // //////////////////////////////////////////////////////////////////
00403     storeSeatIndex::storeSeatIndex (FlightDateStruct& ioFlightDate)
00404       : ParserSemanticAction (ioFlightDate) {
00405     }
00406     
00407     // //////////////////////////////////////////////////////////////////
00408     void storeSeatIndex::operator() (double iReal) const {
00409       _flightDate._itBucket._seatIndex = iReal; 
00410       //std::cout << "Seat Index: " << iReal << std::endl;
00411     }
00412 
00413     // //////////////////////////////////////////////////////////////////
00414     storeSegmentBoardingPoint::
00415     storeSegmentBoardingPoint (FlightDateStruct& ioFlightDate)
00416       : ParserSemanticAction (ioFlightDate) {
00417     }
00418 
00419     // //////////////////////////////////////////////////////////////////
00420     void storeSegmentBoardingPoint::operator() (iterator_t iStr,
00421                                                 iterator_t iStrEnd) const {
00422       stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
00423 
00424       // ///////////////////
00425       // When the first segment-date is read, it means that the leg section
00426       // is over. The parsed leg can therefore be added to the list.
00427       if (_flightDate._itLeg._cabinList.empty() == false) {
00428         _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00429         _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
00430         _flightDate._legList.push_back (_flightDate._itLeg);
00431 
00432         // (Re-)initialise the leg-date branch of the tree
00433         _flightDate._itLeg._cabinList.clear();
00434         _flightDate._itLegCabin._cabinCode = "";
00435         _flightDate._itLeg._cabinList.clear();
00436         _flightDate._itLegCabin._bucketList.clear();
00437       }
00438 
00439       
00440       // ///////////////////
00441       // If this is not the first segment-date of the flight-date,
00442       // the already parsed segment-date must be added to the flight-date.
00443       if (_flightDate._itSegment._cabinList.empty() == false) {
00444         _flightDate._itSegmentCabin._itFareFamily._classList.push_back (_flightDate._itBookingClass);
00445         _flightDate._itSegmentCabin._fareFamilies.push_back (_flightDate._itSegmentCabin._itFareFamily);
00446         _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
00447         _flightDate._segmentList.push_back (_flightDate._itSegment);
00448       }
00449 
00450       // As that's the beginning of a new segment-date,
00451       // (re-)initialise the segment-cabin branch of the tree
00452       _flightDate._itSegment._cabinList.clear();
00453       _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00454       _flightDate._itSegmentCabin._fareFamilies.clear();
00455       _flightDate._itBookingClass._classCode = "";
00456 
00457 
00458       // ///////////////////
00459       _flightDate._itSegment._boardingPoint = lBoardingPoint;
00460       //std::cout << "Board point: " << lBoardingPoint << std::endl;
00461     }
00462 
00463     // //////////////////////////////////////////////////////////////////
00464     storeSegmentOffPoint::storeSegmentOffPoint (FlightDateStruct& ioFlightDate)
00465       : ParserSemanticAction (ioFlightDate) {
00466     }
00467 
00468     // //////////////////////////////////////////////////////////////////
00469     void storeSegmentOffPoint::operator() (iterator_t iStr,
00470                                            iterator_t iStrEnd) const {
00471       stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
00472       _flightDate._itSegment._offPoint = lOffPoint;
00473       //std::cout << "Off point: " << lOffPoint << std::endl;
00474     }
00475 
00476     // //////////////////////////////////////////////////////////////////
00477     storeSegmentCabinCode::
00478     storeSegmentCabinCode (FlightDateStruct& ioFlightDate)
00479       : ParserSemanticAction (ioFlightDate) {
00480     }
00481     
00482     // //////////////////////////////////////////////////////////////////
00483     void storeSegmentCabinCode::operator() (char iChar) const {
00484 
00485       // Reset the list of fare families, as it is a new segment-cabin
00486       _flightDate._itSegmentCabin._fareFamilies.clear();
00487 
00488       // ///////////////////
00489       // If this is not the first segment-cabin of the segment-date,
00490       // the already parsed segment-cabin must be added to the segment-date.
00491       if (_flightDate._itSegmentCabin._itFareFamily._classList.empty() == false){
00492         _flightDate._itSegmentCabin._itFareFamily._classList.
00493           push_back (_flightDate._itBookingClass);
00494         _flightDate._itSegmentCabin._fareFamilies.
00495           push_back (_flightDate._itSegmentCabin._itFareFamily);
00496         _flightDate._itSegment._cabinList.
00497           push_back (_flightDate._itSegmentCabin);
00498       }
00499 
00500       // (Re-)initialise the booking-class branch of the tree
00501       _flightDate._itSegmentCabin._fareFamilies.clear();
00502       _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00503       _flightDate._itBookingClass._classCode = "";
00504 
00505       
00506       // ///////////////////
00507       _flightDate._itSegmentCabin._cabinCode = iChar; 
00508       //std::cout << "Segment-cabin code: " << iChar << std::endl;
00509     }
00510 
00511     // //////////////////////////////////////////////////////////////////
00512     storeSegmentCabinBookingCounter::
00513     storeSegmentCabinBookingCounter (FlightDateStruct& ioFlightDate)
00514       : ParserSemanticAction (ioFlightDate) {
00515     }
00516     
00517     // //////////////////////////////////////////////////////////////////
00518     void storeSegmentCabinBookingCounter::operator() (double iReal) const {
00519       _flightDate._itSegmentCabin._nbOfBookings = iReal; 
00520       //std::cout << "Nb of bookings: " << iReal << std::endl;
00521     }
00522 
00523     // //////////////////////////////////////////////////////////////////
00524     storeClassCode::storeClassCode (FlightDateStruct& ioFlightDate)
00525       : ParserSemanticAction (ioFlightDate) {
00526     }
00527     
00528     // //////////////////////////////////////////////////////////////////
00529     void storeClassCode::operator() (char iChar) const { 
00530       // If this is not the first booking-class of the segment-cabin,
00531       // the already parsed booking-class must be added to the segment-cabin.
00532       if (_flightDate._itBookingClass._classCode != "") {
00533         _flightDate._itSegmentCabin._itFareFamily._classList.
00534           push_back (_flightDate._itBookingClass);
00535       }
00536 
00537       // ///////////////////
00538       _flightDate._itBookingClass._classCode = iChar; 
00539       //std::cout << "Booking class code: " << iChar << std::endl;
00540     }
00541 
00542     // //////////////////////////////////////////////////////////////////
00543     storeSubclassCode::storeSubclassCode (FlightDateStruct& ioFlightDate)
00544       : ParserSemanticAction (ioFlightDate) {
00545     }
00546     
00547     // //////////////////////////////////////////////////////////////////
00548     void storeSubclassCode::operator() (unsigned int iNumber) const { 
00549       _flightDate._itBookingClass._subclassCode = iNumber; 
00550       //std::cout << "Sub-class code: " << iNumber << std::endl;
00551     }
00552 
00553     // //////////////////////////////////////////////////////////////////
00554     storeParentClassCode::
00555     storeParentClassCode (FlightDateStruct& ioFlightDate)
00556       : ParserSemanticAction (ioFlightDate) {
00557     }
00558     
00559     // //////////////////////////////////////////////////////////////////
00560     void storeParentClassCode::operator() (char iChar) const { 
00561       _flightDate._itBookingClass._parentClassCode = iChar; 
00562       //std::cout << "Parent booking class code: " << iChar << std::endl;
00563     }
00564 
00565     // //////////////////////////////////////////////////////////////////
00566     storeParentSubclassCode::
00567     storeParentSubclassCode (FlightDateStruct& ioFlightDate)
00568       : ParserSemanticAction (ioFlightDate) {
00569     }
00570     
00571     // //////////////////////////////////////////////////////////////////
00572     void storeParentSubclassCode::operator() (unsigned int iNumber) const { 
00573       _flightDate._itBookingClass._parentSubclassCode = iNumber; 
00574       //std::cout << "Parent sub-class code: " << iNumber << std::endl;
00575     }
00576 
00577     // //////////////////////////////////////////////////////////////////
00578     storeCumulatedProtection::
00579     storeCumulatedProtection (FlightDateStruct& ioFlightDate)
00580       : ParserSemanticAction (ioFlightDate) {
00581     }
00582     
00583     // //////////////////////////////////////////////////////////////////
00584     void storeCumulatedProtection::operator() (double iReal) const {
00585       _flightDate._itBookingClass._cumulatedProtection = iReal; 
00586       //std::cout << "Cumulated protection: " << iReal << std::endl;
00587     }
00588 
00589     // //////////////////////////////////////////////////////////////////
00590     storeProtection::storeProtection (FlightDateStruct& ioFlightDate)
00591       : ParserSemanticAction (ioFlightDate) {
00592     }
00593     
00594     // //////////////////////////////////////////////////////////////////
00595     void storeProtection::operator() (double iReal) const {
00596       _flightDate._itBookingClass._protection = iReal; 
00597       //std::cout << "Protection: " << iReal << std::endl;
00598     }
00599 
00600     // //////////////////////////////////////////////////////////////////
00601     storeNego::storeNego (FlightDateStruct& ioFlightDate)
00602       : ParserSemanticAction (ioFlightDate) {
00603     }
00604     
00605     // //////////////////////////////////////////////////////////////////
00606     void storeNego::operator() (double iReal) const {
00607       _flightDate._itBookingClass._nego = iReal; 
00608       //std::cout << "Negotiated allotment: " << iReal << std::endl;
00609     }
00610 
00611     // //////////////////////////////////////////////////////////////////
00612     storeNoShow::storeNoShow (FlightDateStruct& ioFlightDate)
00613       : ParserSemanticAction (ioFlightDate) {
00614     }
00615     
00616     // //////////////////////////////////////////////////////////////////
00617     void storeNoShow::operator() (double iReal) const {
00618       _flightDate._itBookingClass._noShowPercentage = iReal; 
00619       //std::cout << "No-Show percentage: " << iReal << std::endl;
00620     }
00621 
00622     // //////////////////////////////////////////////////////////////////
00623     storeOverbooking::storeOverbooking (FlightDateStruct& ioFlightDate)
00624       : ParserSemanticAction (ioFlightDate) {
00625     }
00626     
00627     // //////////////////////////////////////////////////////////////////
00628     void storeOverbooking::operator() (double iReal) const {
00629       _flightDate._itBookingClass._overbookingPercentage = iReal; 
00630       //std::cout << "Overbooking percentage: " << iReal << std::endl;
00631     }
00632 
00633     // //////////////////////////////////////////////////////////////////
00634     storeNbOfBkgs::storeNbOfBkgs (FlightDateStruct& ioFlightDate)
00635       : ParserSemanticAction (ioFlightDate) {
00636     }
00637     
00638     // //////////////////////////////////////////////////////////////////
00639     void storeNbOfBkgs::operator() (double iReal) const {
00640       _flightDate._itBookingClass._nbOfBookings = iReal; 
00641       //std::cout << "Nb of bookings: " << iReal << std::endl;
00642     }
00643     
00644     // //////////////////////////////////////////////////////////////////
00645     storeNbOfGroupBkgs::storeNbOfGroupBkgs (FlightDateStruct& ioFlightDate)
00646       : ParserSemanticAction (ioFlightDate) {
00647     }
00648     
00649     // //////////////////////////////////////////////////////////////////
00650     void storeNbOfGroupBkgs::operator() (double iReal) const {
00651       _flightDate._itBookingClass._nbOfGroupBookings = iReal; 
00652       //std::cout << "Nb of group bookings: " << iReal << std::endl;
00653     }
00654     
00655     // //////////////////////////////////////////////////////////////////
00656     storeNbOfPendingGroupBkgs::
00657     storeNbOfPendingGroupBkgs (FlightDateStruct& ioFlightDate)
00658       : ParserSemanticAction (ioFlightDate) {
00659     }
00660     
00661     // //////////////////////////////////////////////////////////////////
00662     void storeNbOfPendingGroupBkgs::operator() (double iReal) const {
00663       _flightDate._itBookingClass._nbOfPendingGroupBookings = iReal; 
00664       //std::cout << "Nb of pending group bookings: " << iReal << std::endl;
00665     }
00666     
00667     // //////////////////////////////////////////////////////////////////
00668     storeNbOfStaffBkgs::storeNbOfStaffBkgs (FlightDateStruct& ioFlightDate)
00669       : ParserSemanticAction (ioFlightDate) {
00670     }
00671     
00672     // //////////////////////////////////////////////////////////////////
00673     void storeNbOfStaffBkgs::operator() (double iReal) const {
00674       _flightDate._itBookingClass._nbOfStaffBookings = iReal; 
00675       //std::cout << "Nb of staff bookings: " << iReal << std::endl;
00676     }
00677     
00678     // //////////////////////////////////////////////////////////////////
00679     storeNbOfWLBkgs::storeNbOfWLBkgs (FlightDateStruct& ioFlightDate)
00680       : ParserSemanticAction (ioFlightDate) {
00681     }
00682     
00683     // //////////////////////////////////////////////////////////////////
00684     void storeNbOfWLBkgs::operator() (double iReal) const {
00685       _flightDate._itBookingClass._nbOfWLBookings = iReal; 
00686       //std::cout << "Nb of wait-list bookings: " << iReal << std::endl;
00687     }
00688     
00689     // //////////////////////////////////////////////////////////////////
00690     storeClassETB::storeClassETB (FlightDateStruct& ioFlightDate)
00691       : ParserSemanticAction (ioFlightDate) {
00692     }
00693     
00694     // //////////////////////////////////////////////////////////////////
00695     void storeClassETB::operator() (double iReal) const {
00696       _flightDate._itBookingClass._etb = iReal; 
00697       //std::cout << "Class-level ETB: " << iReal << std::endl;
00698     }
00699     
00700     // //////////////////////////////////////////////////////////////////
00701     storeClassAvailability::
00702     storeClassAvailability (FlightDateStruct& ioFlightDate)
00703       : ParserSemanticAction (ioFlightDate) {
00704     }
00705     
00706     // //////////////////////////////////////////////////////////////////
00707     void storeClassAvailability::operator() (double iReal) const {
00708       _flightDate._itBookingClass._netClassAvailability = iReal; 
00709       //std::cout << "Net class availability: " << iReal << std::endl;
00710     }
00711     
00712     // //////////////////////////////////////////////////////////////////
00713     storeSegmentAvailability::
00714     storeSegmentAvailability (FlightDateStruct& ioFlightDate)
00715       : ParserSemanticAction (ioFlightDate) {
00716     }
00717     
00718     // //////////////////////////////////////////////////////////////////
00719     void storeSegmentAvailability::operator() (double iReal) const {
00720       _flightDate._itBookingClass._segmentAvailability = iReal; 
00721       //std::cout << "Segment availability: " << iReal << std::endl;
00722     }
00723     
00724     // //////////////////////////////////////////////////////////////////
00725     storeRevenueAvailability::
00726     storeRevenueAvailability (FlightDateStruct& ioFlightDate)
00727       : ParserSemanticAction (ioFlightDate) {
00728     }
00729     
00730     // //////////////////////////////////////////////////////////////////
00731     void storeRevenueAvailability::operator() (double iReal) const {
00732       _flightDate._itBookingClass._netRevenueAvailability = iReal; 
00733       //std::cout << "Net revenue availability: " << iReal << std::endl;
00734     }
00735     
00736     // //////////////////////////////////////////////////////////////////
00737     storeFamilyCode::storeFamilyCode (FlightDateStruct& ioFlightDate)
00738       : ParserSemanticAction (ioFlightDate) {
00739     }
00740     
00741     // //////////////////////////////////////////////////////////////////
00742     void storeFamilyCode::operator() (int iCode) const {
00743       std::ostringstream ostr;
00744       ostr << iCode;
00745       _flightDate._itSegmentCabin._itFareFamily._familyCode = ostr.str(); 
00746     }
00747 
00748     // //////////////////////////////////////////////////////////////////
00749     storeFClasses::storeFClasses (FlightDateStruct& ioFlightDate)
00750       : ParserSemanticAction (ioFlightDate) {
00751     }
00752 
00753     // //////////////////////////////////////////////////////////////////
00754     void storeFClasses::operator() (iterator_t iStr,
00755                                     iterator_t iStrEnd) const {
00756       std::string lClasses (iStr, iStrEnd);
00757       _flightDate._itSegmentCabin._itFareFamily._classes = lClasses;
00758       
00759       // The list of classes is the last (according to the arrival order
00760       // within the schedule input file) detail of the segment cabin. Hence,
00761       // when a list of classes is parsed, it means that the full segment
00762       // cabin details have already been parsed as well: the segment cabin
00763       // can thus be added to the segment.
00764       _flightDate._itSegmentCabin._itFareFamily._classList.
00765         push_back (_flightDate._itBookingClass);
00766       _flightDate._itSegmentCabin._fareFamilies.
00767         push_back (_flightDate._itSegmentCabin._itFareFamily);
00768       _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
00769 
00770       // As that's the beginning of a new segment-cabin,
00771       // (re-)initialise the segment-cabin branch of the tree
00772       _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00773       _flightDate._itSegmentCabin._fareFamilies.clear();
00774       _flightDate._itBookingClass._classCode = "";
00775     }
00776 
00777     // //////////////////////////////////////////////////////////////////
00778     doEndFlightDate::doEndFlightDate (stdair::BomRoot& ioBomRoot,
00779                                       FlightDateStruct& ioFlightDate,
00780                                       unsigned int& ioNbOfFlights)
00781       : ParserSemanticAction (ioFlightDate), _bomRoot (ioBomRoot),
00782         _nbOfFlights (ioNbOfFlights) {
00783     }
00784     
00785     // //////////////////////////////////////////////////////////////////
00786     // void doEndFlightDate::operator() (char iChar) const {
00787     void doEndFlightDate::operator() (iterator_t iStr,
00788                                       iterator_t iStrEnd) const {
00789 
00790       // ///////////////////
00791       // The segment-date section is now over. It means that the
00792       // already parsed segment-date must be added to the flight-date.
00793       if (_flightDate._itSegment._cabinList.empty() == false) {
00794         _flightDate._segmentList.push_back (_flightDate._itSegment);
00795       }
00796 
00797       // As that's the beginning of a new flight-date,
00798       // (re-)initialise the segment-cabin branch of the tree
00799       _flightDate._itSegment._cabinList.clear();
00800       
00801 
00802       // ///////////////////
00803       //if (_nbOfFlights % 1000 == 0) {
00804         // DEBUG: Display the result
00805         //STDAIR_LOG_DEBUG ("FlightDate #" << _nbOfFlights
00806         //                  << ": " << _flightDate.describe());
00807         //}
00808 
00809       // Build the FlightDate BOM objects
00810       InventoryBuilder::buildInventory (_bomRoot, _flightDate);
00811 
00812       //
00813       ++_nbOfFlights;
00814     }
00815 
00816       
00817     // ///////////////////////////////////////////////////////////////////
00818     //
00819     //  Utility Parsers
00820     //
00821     // ///////////////////////////////////////////////////////////////////
00823     int1_p_t int1_p;
00824     
00826     uint2_p_t uint2_p;
00827     
00829     uint1_2_p_t uint1_2_p;
00830 
00832     uint1_3_p_t uint1_3_p;
00833 
00835     uint4_p_t uint4_p;
00836     
00838     uint1_4_p_t uint1_4_p;
00839 
00841     repeat_p_t airline_code_p (chset_t("0-9A-Z").derived(), 2, 3);
00842       
00844     bounded1_4_p_t flight_number_p (uint1_4_p.derived(), 0u, 9999u);
00845 
00847     bounded2_p_t year_p (uint2_p.derived(), 0u, 99u);
00848       
00850     bounded2_p_t month_p (uint2_p.derived(), 1u, 12u);
00851 
00853     bounded2_p_t day_p (uint2_p.derived(), 1u, 31u);
00854      
00856     repeat_p_t dow_p (chset_t("0-1").derived().derived(), 7, 7);
00857 
00859     repeat_p_t airport_p (chset_t("0-9A-Z").derived(), 3, 3);
00860       
00862     bounded1_2_p_t hours_p (uint1_2_p.derived(), 0u, 24u);
00863 
00865     bounded2_p_t minutes_p (uint2_p.derived(), 0u, 59u);
00866 
00868     bounded2_p_t seconds_p (uint2_p.derived(), 0u, 59u);
00869 
00871     chset_t cabin_code_p ("A-Z");
00872 
00874     chset_t class_code_p ("A-Z");
00875 
00877     chset_t passenger_type_p ("A-Z");
00878 
00880     int1_p_t family_code_p;
00881       
00883     repeat_p_t class_code_list_p (chset_t("A-Z").derived(), 1, 26);
00884 
00886     bounded1_3_p_t stay_duration_p (uint1_3_p.derived(), 0u, 999u);
00887 
00888 
00889     // //////////////////////////////////////////////////////////////////
00890     //  (Boost Spirit) Grammar Definition
00891     // //////////////////////////////////////////////////////////////////
00892 
00893     // //////////////////////////////////////////////////////////////////
00894     InventoryParser::InventoryParser (stdair::BomRoot& ioBomRoot,
00895                                       FlightDateStruct& ioFlightDate,
00896                                       unsigned int& ioNbOfFlights) 
00897       : _bomRoot (ioBomRoot), _flightDate (ioFlightDate),
00898         _nbOfFlights (ioNbOfFlights) {
00899     }
00900 
00901     // //////////////////////////////////////////////////////////////////
00902     template<typename ScannerT>
00903     InventoryParser::definition<ScannerT>::
00904     definition (InventoryParser const& self) {
00905 
00906       flight_date_list = *( not_to_be_parsed | flight_date )
00907         ;
00908       
00909       not_to_be_parsed =
00910         bsc::lexeme_d[ bsc::comment_p("//") | bsc::comment_p("/*", "*/")
00911                        | bsc::space_p ]
00912         ;
00913       
00914       flight_date = flight_key
00915         >> leg_list
00916         >> segment_list
00917         >> flight_date_end[doEndFlightDate (self._bomRoot, self._flightDate,
00918                                             self._nbOfFlights)]
00919         ;
00920 
00921       flight_date_end = bsc::ch_p(';')
00922         ;
00923       
00924       flight_key = date[storeSnapshotDate(self._flightDate)]
00925         >> '/' >> airline_code
00926         >> '/' >> flight_number
00927         >> '/' >> date[storeFlightDate(self._flightDate)]
00928         >> '/' >> flight_type_code[storeFlightTypeCode(self._flightDate)]
00929         >> !( '/' >> flight_visibility_code[storeFlightVisibilityCode(self._flightDate)])
00930         ;
00931 
00932       airline_code =
00933         bsc::lexeme_d[(airline_code_p)[storeAirlineCode(self._flightDate)]]
00934         ;
00935         
00936       flight_number =
00937         bsc::lexeme_d[(flight_number_p)[storeFlightNumber(self._flightDate)]]
00938         ;
00939 
00940       date =
00941         bsc::lexeme_d[(day_p)[bsc::assign_a(self._flightDate._itDay)]
00942                       >> (month_p)[bsc::assign_a(self._flightDate._itMonth)]
00943                       >> (year_p)[bsc::assign_a(self._flightDate._itYear)]]
00944         ;
00945 
00946       flight_type_code =
00947         ( bsc::chseq_p("INT") | bsc::chseq_p("DOM") | bsc::chseq_p("GRD") )
00948         ;
00949 
00950       flight_visibility_code =
00951         ( bsc::chseq_p("HID") | bsc::chseq_p("PSD") )
00952         ;
00953 
00954       leg_list = +( '/' >> leg )
00955         ; 
00956 
00957       leg = !( operating_leg_details >> ';' )
00958         >> leg_key >> ';' >> leg_details >> leg_cabin_list
00959         ;
00960 
00961       operating_leg_details =
00962         bsc::lexeme_d[(airline_code_p)[storeOperatingAirlineCode(self._flightDate)] ]
00963         >> ";"
00964         >> bsc::lexeme_d[(flight_number_p)[storeOperatingFlightNumber(self._flightDate)] ]
00965         ;
00966          
00967       leg_key = (airport_p)[storeLegBoardingPoint(self._flightDate)]
00968         >> ';' >> (airport_p)[storeLegOffPoint(self._flightDate)]
00969         ;
00970          
00971       leg_details = date[storeBoardingDate(self._flightDate)]
00972         >> ';' >> time[storeBoardingTime(self._flightDate)]
00973         >> ';' >> date[storeOffDate(self._flightDate)]
00974         >> ';' >> time[storeOffTime(self._flightDate)]
00975         ;
00976 
00977       leg_cabin_list = +( ';' >> leg_cabin_details >> !bucket_list )
00978         ;
00979         
00980       leg_cabin_details = (cabin_code_p)[storeLegCabinCode(self._flightDate)]
00981         >> ',' >> (bsc::ureal_p)[storeSaleableCapacity(self._flightDate)]
00982         >> ',' >> (bsc::real_p)[storeAU(self._flightDate)]
00983         >> ',' >> (bsc::real_p)[storeUPR(self._flightDate)]
00984         >> ',' >> (bsc::real_p)[storeBookingCounter(self._flightDate)]
00985         >> ',' >> (bsc::real_p)[storeNAV(self._flightDate)]
00986         >> ',' >> (bsc::real_p)[storeGAV(self._flightDate)]
00987         >> ',' >> (bsc::ureal_p)[storeACP(self._flightDate)]
00988         >> ',' >> (bsc::real_p)[storeETB(self._flightDate)]
00989         ;
00990         
00991       time =
00992         bsc::lexeme_d[
00993             (hours_p)[bsc::assign_a(self._flightDate._itHours)]
00994          >> (minutes_p)[bsc::assign_a(self._flightDate._itMinutes)]
00995          >> !((seconds_p)[bsc::assign_a(self._flightDate._itSeconds)])
00996                                          ]
00997         ;
00998       
00999       bucket_list = +( ',' >> bucket_details )
01000         ;
01001 
01002       bucket_details =
01003         (bsc::ureal_p)[storeYieldUpperRange(self._flightDate)]
01004         >> ':' >> (bsc::real_p)[storeBucketAvaibality(self._flightDate)]
01005         >> ':' >> (uint1_3_p)[storeSeatIndex(self._flightDate)];
01006       
01007       segment_list = +( '/' >> segment )
01008         ;
01009       
01010       segment = segment_key >> segment_cabin_list
01011         ;
01012 
01013       segment_key = (airport_p)[storeSegmentBoardingPoint(self._flightDate)]
01014         >> ';' >> (airport_p)[storeSegmentOffPoint(self._flightDate)]
01015         ;
01016 
01017       segment_cabin_list =
01018         +( ';' >> segment_cabin_key >> ','
01019            >> segment_cabin_details >> class_list >> family_cabin_list )
01020         ;
01021 
01022       family_cabin_list =
01023         +( ';' >> family_cabin_details)
01024         ;
01025 
01026       segment_cabin_key =
01027         (cabin_code_p)[storeSegmentCabinCode(self._flightDate)]
01028         ;
01029       
01030       segment_cabin_details =
01031         (bsc::ureal_p)[storeSegmentCabinBookingCounter(self._flightDate)]
01032         ;
01033 
01034       class_list = +( ',' >> class_key >> '|' >> class_details )
01035         ;
01036 
01037       class_key = (class_code_p)[storeClassCode(self._flightDate)]
01038         ;
01039 
01040       parent_subclass_code =
01041         (class_code_p)[storeParentClassCode(self._flightDate)]
01042         >> (uint1_2_p)[storeParentSubclassCode(self._flightDate)]
01043         ;
01044 
01045       class_protection =
01046         (bsc::ureal_p)[storeProtection(self._flightDate)]
01047         ;
01048         
01049       class_nego =
01050         (bsc::ureal_p)[storeNego(self._flightDate)]
01051         ;
01052         
01053       class_details = (uint1_2_p)[storeSubclassCode(self._flightDate)]
01054         >> ':' >> (bsc::ureal_p)[storeCumulatedProtection(self._flightDate)]
01055         >> ':' >> !( parent_subclass_code )
01056         >> ':' >> !( class_protection )
01057         >> ':' >> (bsc::ureal_p)[storeNoShow(self._flightDate)]
01058         >> ':' >> (bsc::ureal_p)[storeOverbooking(self._flightDate)]
01059         >> ':' >> (bsc::ureal_p)[storeNbOfBkgs(self._flightDate)]
01060         >> ':' >> (bsc::ureal_p)[storeNbOfGroupBkgs(self._flightDate)]
01061         >> ':' >> (bsc::ureal_p)[storeNbOfPendingGroupBkgs(self._flightDate)]
01062         >> ':' >> (bsc::ureal_p)[storeNbOfStaffBkgs(self._flightDate)]
01063         >> ':' >> (bsc::ureal_p)[storeNbOfWLBkgs(self._flightDate)]
01064         >> ':' >> (bsc::ureal_p)[storeClassETB(self._flightDate)]
01065         >> ':' >> !( class_nego )
01066         >> ':' >> (bsc::real_p)[storeClassAvailability(self._flightDate)]
01067         >> ':' >> (bsc::real_p)[storeSegmentAvailability(self._flightDate)]
01068         >> ':' >> (bsc::real_p)[storeRevenueAvailability(self._flightDate)]
01069         ;
01070 
01071       family_cabin_details =
01072         (family_code_p)[storeFamilyCode(self._flightDate)]
01073         >> ';'
01074         >> (class_code_list_p)[storeFClasses(self._flightDate)]
01075         ;
01076 
01077       // BOOST_SPIRIT_DEBUG_NODE (InventoryParser);
01078       BOOST_SPIRIT_DEBUG_NODE (flight_date_list);
01079       BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
01080       BOOST_SPIRIT_DEBUG_NODE (flight_date);
01081       BOOST_SPIRIT_DEBUG_NODE (flight_date_end);
01082       BOOST_SPIRIT_DEBUG_NODE (flight_key);
01083       BOOST_SPIRIT_DEBUG_NODE (airline_code);
01084       BOOST_SPIRIT_DEBUG_NODE (flight_number);
01085       BOOST_SPIRIT_DEBUG_NODE (flight_type_code);
01086       BOOST_SPIRIT_DEBUG_NODE (flight_visibility_code);
01087       BOOST_SPIRIT_DEBUG_NODE (date);
01088       BOOST_SPIRIT_DEBUG_NODE (leg_list);
01089       BOOST_SPIRIT_DEBUG_NODE (leg);
01090       BOOST_SPIRIT_DEBUG_NODE (operating_leg_details);
01091       BOOST_SPIRIT_DEBUG_NODE (leg_key);
01092       BOOST_SPIRIT_DEBUG_NODE (leg_details);
01093       BOOST_SPIRIT_DEBUG_NODE (leg_cabin_list);
01094       BOOST_SPIRIT_DEBUG_NODE (leg_cabin_details);
01095       BOOST_SPIRIT_DEBUG_NODE (bucket_list);
01096       BOOST_SPIRIT_DEBUG_NODE (bucket_details);
01097       BOOST_SPIRIT_DEBUG_NODE (time);
01098       BOOST_SPIRIT_DEBUG_NODE (segment_list);
01099       BOOST_SPIRIT_DEBUG_NODE (segment);
01100       BOOST_SPIRIT_DEBUG_NODE (segment_key);
01101       BOOST_SPIRIT_DEBUG_NODE (full_segment_cabin_details);
01102       BOOST_SPIRIT_DEBUG_NODE (segment_cabin_list);
01103       BOOST_SPIRIT_DEBUG_NODE (segment_cabin_key);
01104       BOOST_SPIRIT_DEBUG_NODE (segment_cabin_details);
01105       BOOST_SPIRIT_DEBUG_NODE (class_list);
01106       BOOST_SPIRIT_DEBUG_NODE (class_key);
01107       BOOST_SPIRIT_DEBUG_NODE (parent_subclass_code);
01108       BOOST_SPIRIT_DEBUG_NODE (class_protection);
01109       BOOST_SPIRIT_DEBUG_NODE (class_nego);
01110       BOOST_SPIRIT_DEBUG_NODE (class_details);
01111       BOOST_SPIRIT_DEBUG_NODE (family_cabin_list);
01112       BOOST_SPIRIT_DEBUG_NODE (family_cabin_details);
01113     }
01114 
01115     // //////////////////////////////////////////////////////////////////
01116     template<typename ScannerT>
01117     bsc::rule<ScannerT> const&
01118     InventoryParser::definition<ScannerT>::start() const {
01119       return flight_date_list;
01120     }
01121   }
01122 
01123 
01125   //
01126   //  Entry class for the file parser
01127   //
01129 
01130   // //////////////////////////////////////////////////////////////////////
01131   InventoryFileParser::
01132   InventoryFileParser (stdair::BomRoot& ioBomRoot, const std::string& iFilename)
01133     : _filename (iFilename), _bomRoot (ioBomRoot),
01134       _nbOfFlights (0) {
01135     init();
01136   }
01137 
01138   // //////////////////////////////////////////////////////////////////////
01139   void InventoryFileParser::init() {
01140     // Open the file
01141     _startIterator = iterator_t (_filename);
01142 
01143     // Check the filename exists and can be open
01144     if (!_startIterator) {
01145       std::ostringstream oMessage;
01146       oMessage << "The file " << _filename << " can not be open.";
01147       STDAIR_LOG_ERROR (oMessage.str());
01148       throw InventoryInputFileNotFoundException (oMessage.str());
01149     }
01150 
01151     // Create an EOF iterator
01152     _endIterator = _startIterator.make_end();
01153   }
01154     
01155   // //////////////////////////////////////////////////////////////////////
01156   bool InventoryFileParser::buildInventory () {
01157     bool oResult = false;
01158       
01159     STDAIR_LOG_DEBUG ("Parsing inventory input file: " << _filename);
01160 
01161     // Initialise the parser (grammar) with the helper/staging structure.
01162     InventoryParserHelper::InventoryParser lInventoryParser (_bomRoot,
01163                                                              _flightDate,
01164                                                              _nbOfFlights);
01165       
01166     // Launch the parsing of the file and, thanks to the doEndFlightDate
01167     // call-back structure, the building of the whole Inventory BOM
01168     // (i.e., including Inventory, FlightDate, LegDate, SegmentDate, etc.)
01169     bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
01170                                                    lInventoryParser,
01171                                                    bsc::space_p - bsc::eol_p);
01172 
01173     // Retrieves whether or not the parsing was successful
01174     oResult = info.hit;
01175       
01176     const std::string hasBeenFullyReadStr = (info.full == true)?"":"not ";
01177     if (oResult == true) {
01178       STDAIR_LOG_DEBUG ("Parsing of inventory input file: " << _filename
01179                        << " succeeded: read " << info.length
01180                        << " characters. The input file has "
01181                        << hasBeenFullyReadStr
01182                        << "been fully read. Stop point: " << info.stop);
01183         
01184     } else {
01185       STDAIR_LOG_ERROR ("Parsing of inventory input file: " << _filename
01186                         << " failed: read " << info.length
01187                         << " characters. The input file has "
01188                         << hasBeenFullyReadStr
01189                         << "been fully read. Stop point: " << info.stop);
01190       throw InventoryFileParsingFailedException("Parsing of inventory input file"
01191                                                 ": " + _filename + " failed");
01192     }
01193 
01194     return oResult;
01195   }
01196     
01197 }