00001
00002
00003
00004
00005 #include <cassert>
00006
00007 #include <stdair/service/Logger.hpp>
00008 #include <stdair/stdair_exceptions.hpp>
00009
00010 #include <airinv/command/InventoryBuilder.hpp>
00011
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
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
00055
00056 _flightDate._legList.clear();
00057 _flightDate._itLeg._cabinList.clear();
00058 _flightDate._itLegCabin._bucketList.clear();
00059 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00060
00061
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
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
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
00132
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
00140
00141 _flightDate._itLeg._cabinList.clear();
00142 _flightDate._itLegCabin._cabinCode = "";
00143 _flightDate._itLegCabin._bucketList.clear();
00144 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00145
00146
00147
00148
00149 _flightDate._itLeg._boardingPoint = lBoardingPoint;
00150
00151
00152 _flightDate.addAirport (lBoardingPoint);
00153 }
00154
00155
00156 storeLegOffPoint::
00157 storeLegOffPoint (FlightDateStruct& ioFlightDate)
00158 : ParserSemanticAction (ioFlightDate) {
00159 }
00160
00161
00162 void storeLegOffPoint::operator() (iterator_t iStr,
00163 iterator_t iStrEnd) const {
00164 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
00165 _flightDate._itLeg._offPoint = lOffPoint;
00166
00167
00168 _flightDate.addAirport (lOffPoint);
00169 }
00170
00171
00172 storeBoardingDate::storeBoardingDate (FlightDateStruct& ioFlightDate)
00173 : ParserSemanticAction (ioFlightDate) {
00174 }
00175
00176
00177 void storeBoardingDate::operator() (iterator_t iStr,
00178 iterator_t iStrEnd) const {
00179 _flightDate._itLeg._boardingDate = _flightDate.getDate();
00180 }
00181
00182
00183 storeBoardingTime::storeBoardingTime (FlightDateStruct& ioFlightDate)
00184 : ParserSemanticAction (ioFlightDate) {
00185 }
00186
00187
00188 void storeBoardingTime::operator() (iterator_t iStr,
00189 iterator_t iStrEnd) const {
00190 _flightDate._itLeg._boardingTime = _flightDate.getTime();
00191
00192
00193 _flightDate._itSeconds = 0;
00194
00195
00196 _flightDate._dateOffSet = 0;
00197 }
00198
00199
00200 storeOffDate::storeOffDate (FlightDateStruct& ioFlightDate)
00201 : ParserSemanticAction (ioFlightDate) {
00202 }
00203
00204
00205 void storeOffDate::operator() (iterator_t iStr, iterator_t iStrEnd) const {
00206 _flightDate._itLeg._offDate = _flightDate.getDate();
00207 }
00208
00209
00210 storeOffTime::storeOffTime (FlightDateStruct& ioFlightDate)
00211 : ParserSemanticAction (ioFlightDate) {
00212 }
00213
00214
00215 void storeOffTime::operator() (iterator_t iStr, iterator_t iStrEnd) const {
00216 _flightDate._itLeg._offTime = _flightDate.getTime();
00217
00218
00219 _flightDate._itSeconds = 0;
00220 }
00221
00222
00223 storeLegCabinCode::storeLegCabinCode (FlightDateStruct& ioFlightDate)
00224 : ParserSemanticAction (ioFlightDate) {
00225 }
00226
00227
00228 void storeLegCabinCode::operator() (char iChar) const {
00229
00230
00231
00232
00233 if (_flightDate._itLegCabin._cabinCode != "") {
00234 if (_flightDate._itLegCabin._bucketList.empty() == false) {
00235 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00236 }
00237 _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
00238 }
00239
00240
00241 _flightDate._itLegCabin._bucketList.clear();
00242 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
00243
00244
00245
00246 _flightDate._itLegCabin._cabinCode = iChar;
00247
00248 }
00249
00250
00251 storeSaleableCapacity::
00252 storeSaleableCapacity (FlightDateStruct& ioFlightDate)
00253 : ParserSemanticAction (ioFlightDate) {
00254 }
00255
00256
00257 void storeSaleableCapacity::operator() (double iReal) const {
00258 _flightDate._itLegCabin._saleableCapacity = iReal;
00259
00260 }
00261
00262
00263 storeAU::storeAU (FlightDateStruct& ioFlightDate)
00264 : ParserSemanticAction (ioFlightDate) {
00265 }
00266
00267
00268 void storeAU::operator() (double iReal) const {
00269 _flightDate._itLegCabin._au = iReal;
00270
00271 }
00272
00273
00274 storeUPR::storeUPR (FlightDateStruct& ioFlightDate)
00275 : ParserSemanticAction (ioFlightDate) {
00276 }
00277
00278
00279 void storeUPR::operator() (double iReal) const {
00280 _flightDate._itLegCabin._upr = iReal;
00281
00282 }
00283
00284
00285 storeBookingCounter::storeBookingCounter (FlightDateStruct& ioFlightDate)
00286 : ParserSemanticAction (ioFlightDate) {
00287 }
00288
00289
00290 void storeBookingCounter::operator() (double iReal) const {
00291 _flightDate._itLegCabin._nbOfBookings = iReal;
00292
00293 }
00294
00295
00296 storeNAV::storeNAV (FlightDateStruct& ioFlightDate)
00297 : ParserSemanticAction (ioFlightDate) {
00298 }
00299
00300
00301 void storeNAV::operator() (double iReal) const {
00302 _flightDate._itLegCabin._nav = iReal;
00303
00304 }
00305
00306
00307 storeGAV::storeGAV (FlightDateStruct& ioFlightDate)
00308 : ParserSemanticAction (ioFlightDate) {
00309 }
00310
00311
00312 void storeGAV::operator() (double iReal) const {
00313 _flightDate._itLegCabin._gav = iReal;
00314
00315 }
00316
00317
00318 storeACP::storeACP (FlightDateStruct& ioFlightDate)
00319 : ParserSemanticAction (ioFlightDate) {
00320 }
00321
00322
00323 void storeACP::operator() (double iReal) const {
00324 _flightDate._itLegCabin._acp = iReal;
00325
00326 }
00327
00328
00329 storeETB::storeETB (FlightDateStruct& ioFlightDate)
00330 : ParserSemanticAction (ioFlightDate) {
00331 }
00332
00333
00334 void storeETB::operator() (double iReal) const {
00335 _flightDate._itLegCabin._etb = iReal;
00336
00337 }
00338
00339
00340 storeYieldUpperRange::storeYieldUpperRange(FlightDateStruct& ioFlightDate)
00341 : ParserSemanticAction (ioFlightDate) {
00342 }
00343
00344
00345 void storeYieldUpperRange::operator() (double iReal) const {
00346
00347
00348 if (_flightDate._itBucket._yieldRangeUpperValue != 0.0) {
00349 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00350 }
00351
00352
00353
00354 _flightDate._itBucket._yieldRangeUpperValue = iReal;
00355
00356 }
00357
00358
00359 storeBucketAvaibality::
00360 storeBucketAvaibality (FlightDateStruct& ioFlightDate)
00361 : ParserSemanticAction (ioFlightDate) {
00362 }
00363
00364
00365 void storeBucketAvaibality::operator() (double iReal) const {
00366 _flightDate._itBucket._availability = iReal;
00367
00368 }
00369
00370
00371 storeSeatIndex::storeSeatIndex (FlightDateStruct& ioFlightDate)
00372 : ParserSemanticAction (ioFlightDate) {
00373 }
00374
00375
00376 void storeSeatIndex::operator() (double iReal) const {
00377 _flightDate._itBucket._seatIndex = iReal;
00378
00379 }
00380
00381
00382 storeSegmentBoardingPoint::
00383 storeSegmentBoardingPoint (FlightDateStruct& ioFlightDate)
00384 : ParserSemanticAction (ioFlightDate) {
00385 }
00386
00387
00388 void storeSegmentBoardingPoint::operator() (iterator_t iStr,
00389 iterator_t iStrEnd) const {
00390 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
00391
00392
00393
00394
00395 if (_flightDate._itLeg._cabinList.empty() == false) {
00396 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
00397 _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
00398 _flightDate._legList.push_back (_flightDate._itLeg);
00399
00400
00401 _flightDate._itLeg._cabinList.clear();
00402 _flightDate._itLegCabin._cabinCode = "";
00403 _flightDate._itLeg._cabinList.clear();
00404 _flightDate._itLegCabin._bucketList.clear();
00405 }
00406
00407
00408
00409
00410
00411 if (_flightDate._itSegment._cabinList.empty() == false) {
00412 _flightDate._itSegmentCabin._itFareFamily._classList.push_back (_flightDate._itBookingClass);
00413 _flightDate._itSegmentCabin._fareFamilies.push_back (_flightDate._itSegmentCabin._itFareFamily);
00414 _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
00415 _flightDate._segmentList.push_back (_flightDate._itSegment);
00416 }
00417
00418
00419
00420 _flightDate._itSegment._cabinList.clear();
00421 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00422 _flightDate._itSegmentCabin._fareFamilies.clear();
00423 _flightDate._itBookingClass._classCode = "";
00424
00425
00426
00427 _flightDate._itSegment._boardingPoint = lBoardingPoint;
00428
00429 }
00430
00431
00432 storeSegmentOffPoint::storeSegmentOffPoint (FlightDateStruct& ioFlightDate)
00433 : ParserSemanticAction (ioFlightDate) {
00434 }
00435
00436
00437 void storeSegmentOffPoint::operator() (iterator_t iStr,
00438 iterator_t iStrEnd) const {
00439 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
00440 _flightDate._itSegment._offPoint = lOffPoint;
00441
00442 }
00443
00444
00445 storeSegmentCabinCode::
00446 storeSegmentCabinCode (FlightDateStruct& ioFlightDate)
00447 : ParserSemanticAction (ioFlightDate) {
00448 }
00449
00450
00451 void storeSegmentCabinCode::operator() (char iChar) const {
00452
00453
00454 _flightDate._itSegmentCabin._fareFamilies.clear();
00455
00456
00457
00458
00459 if (_flightDate._itSegmentCabin._itFareFamily._classList.empty() == false){
00460 _flightDate._itSegmentCabin._itFareFamily._classList.
00461 push_back (_flightDate._itBookingClass);
00462 _flightDate._itSegmentCabin._fareFamilies.
00463 push_back (_flightDate._itSegmentCabin._itFareFamily);
00464 _flightDate._itSegment._cabinList.
00465 push_back (_flightDate._itSegmentCabin);
00466 }
00467
00468
00469 _flightDate._itSegmentCabin._fareFamilies.clear();
00470 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00471 _flightDate._itBookingClass._classCode = "";
00472
00473
00474
00475 _flightDate._itSegmentCabin._cabinCode = iChar;
00476
00477 }
00478
00479
00480 storeSegmentCabinBookingCounter::
00481 storeSegmentCabinBookingCounter (FlightDateStruct& ioFlightDate)
00482 : ParserSemanticAction (ioFlightDate) {
00483 }
00484
00485
00486 void storeSegmentCabinBookingCounter::operator() (double iReal) const {
00487 _flightDate._itSegmentCabin._nbOfBookings = iReal;
00488
00489 }
00490
00491
00492 storeClassCode::storeClassCode (FlightDateStruct& ioFlightDate)
00493 : ParserSemanticAction (ioFlightDate) {
00494 }
00495
00496
00497 void storeClassCode::operator() (char iChar) const {
00498
00499
00500 if (_flightDate._itBookingClass._classCode != "") {
00501 _flightDate._itSegmentCabin._itFareFamily._classList.
00502 push_back (_flightDate._itBookingClass);
00503 }
00504
00505
00506 _flightDate._itBookingClass._classCode = iChar;
00507
00508 }
00509
00510
00511 storeSubclassCode::storeSubclassCode (FlightDateStruct& ioFlightDate)
00512 : ParserSemanticAction (ioFlightDate) {
00513 }
00514
00515
00516 void storeSubclassCode::operator() (unsigned int iNumber) const {
00517 _flightDate._itBookingClass._subclassCode = iNumber;
00518
00519 }
00520
00521
00522 storeParentClassCode::
00523 storeParentClassCode (FlightDateStruct& ioFlightDate)
00524 : ParserSemanticAction (ioFlightDate) {
00525 }
00526
00527
00528 void storeParentClassCode::operator() (char iChar) const {
00529 _flightDate._itBookingClass._parentClassCode = iChar;
00530
00531 }
00532
00533
00534 storeParentSubclassCode::
00535 storeParentSubclassCode (FlightDateStruct& ioFlightDate)
00536 : ParserSemanticAction (ioFlightDate) {
00537 }
00538
00539
00540 void storeParentSubclassCode::operator() (unsigned int iNumber) const {
00541 _flightDate._itBookingClass._parentSubclassCode = iNumber;
00542
00543 }
00544
00545
00546 storeCumulatedProtection::
00547 storeCumulatedProtection (FlightDateStruct& ioFlightDate)
00548 : ParserSemanticAction (ioFlightDate) {
00549 }
00550
00551
00552 void storeCumulatedProtection::operator() (double iReal) const {
00553 _flightDate._itBookingClass._cumulatedProtection = iReal;
00554
00555 }
00556
00557
00558 storeProtection::storeProtection (FlightDateStruct& ioFlightDate)
00559 : ParserSemanticAction (ioFlightDate) {
00560 }
00561
00562
00563 void storeProtection::operator() (double iReal) const {
00564 _flightDate._itBookingClass._protection = iReal;
00565
00566 }
00567
00568
00569 storeNego::storeNego (FlightDateStruct& ioFlightDate)
00570 : ParserSemanticAction (ioFlightDate) {
00571 }
00572
00573
00574 void storeNego::operator() (double iReal) const {
00575 _flightDate._itBookingClass._nego = iReal;
00576
00577 }
00578
00579
00580 storeNoShow::storeNoShow (FlightDateStruct& ioFlightDate)
00581 : ParserSemanticAction (ioFlightDate) {
00582 }
00583
00584
00585 void storeNoShow::operator() (double iReal) const {
00586 _flightDate._itBookingClass._noShowPercentage = iReal;
00587
00588 }
00589
00590
00591 storeOverbooking::storeOverbooking (FlightDateStruct& ioFlightDate)
00592 : ParserSemanticAction (ioFlightDate) {
00593 }
00594
00595
00596 void storeOverbooking::operator() (double iReal) const {
00597 _flightDate._itBookingClass._overbookingPercentage = iReal;
00598
00599 }
00600
00601
00602 storeNbOfBkgs::storeNbOfBkgs (FlightDateStruct& ioFlightDate)
00603 : ParserSemanticAction (ioFlightDate) {
00604 }
00605
00606
00607 void storeNbOfBkgs::operator() (double iReal) const {
00608 _flightDate._itBookingClass._nbOfBookings = iReal;
00609
00610 }
00611
00612
00613 storeNbOfGroupBkgs::storeNbOfGroupBkgs (FlightDateStruct& ioFlightDate)
00614 : ParserSemanticAction (ioFlightDate) {
00615 }
00616
00617
00618 void storeNbOfGroupBkgs::operator() (double iReal) const {
00619 _flightDate._itBookingClass._nbOfGroupBookings = iReal;
00620
00621 }
00622
00623
00624 storeNbOfPendingGroupBkgs::
00625 storeNbOfPendingGroupBkgs (FlightDateStruct& ioFlightDate)
00626 : ParserSemanticAction (ioFlightDate) {
00627 }
00628
00629
00630 void storeNbOfPendingGroupBkgs::operator() (double iReal) const {
00631 _flightDate._itBookingClass._nbOfPendingGroupBookings = iReal;
00632
00633 }
00634
00635
00636 storeNbOfStaffBkgs::storeNbOfStaffBkgs (FlightDateStruct& ioFlightDate)
00637 : ParserSemanticAction (ioFlightDate) {
00638 }
00639
00640
00641 void storeNbOfStaffBkgs::operator() (double iReal) const {
00642 _flightDate._itBookingClass._nbOfStaffBookings = iReal;
00643
00644 }
00645
00646
00647 storeNbOfWLBkgs::storeNbOfWLBkgs (FlightDateStruct& ioFlightDate)
00648 : ParserSemanticAction (ioFlightDate) {
00649 }
00650
00651
00652 void storeNbOfWLBkgs::operator() (double iReal) const {
00653 _flightDate._itBookingClass._nbOfWLBookings = iReal;
00654
00655 }
00656
00657
00658 storeClassETB::storeClassETB (FlightDateStruct& ioFlightDate)
00659 : ParserSemanticAction (ioFlightDate) {
00660 }
00661
00662
00663 void storeClassETB::operator() (double iReal) const {
00664 _flightDate._itBookingClass._etb = iReal;
00665
00666 }
00667
00668
00669 storeClassAvailability::
00670 storeClassAvailability (FlightDateStruct& ioFlightDate)
00671 : ParserSemanticAction (ioFlightDate) {
00672 }
00673
00674
00675 void storeClassAvailability::operator() (double iReal) const {
00676 _flightDate._itBookingClass._netClassAvailability = iReal;
00677
00678 }
00679
00680
00681 storeSegmentAvailability::
00682 storeSegmentAvailability (FlightDateStruct& ioFlightDate)
00683 : ParserSemanticAction (ioFlightDate) {
00684 }
00685
00686
00687 void storeSegmentAvailability::operator() (double iReal) const {
00688 _flightDate._itBookingClass._segmentAvailability = iReal;
00689
00690 }
00691
00692
00693 storeRevenueAvailability::
00694 storeRevenueAvailability (FlightDateStruct& ioFlightDate)
00695 : ParserSemanticAction (ioFlightDate) {
00696 }
00697
00698
00699 void storeRevenueAvailability::operator() (double iReal) const {
00700 _flightDate._itBookingClass._netRevenueAvailability = iReal;
00701
00702 }
00703
00704
00705 storeFamilyCode::storeFamilyCode (FlightDateStruct& ioFlightDate)
00706 : ParserSemanticAction (ioFlightDate) {
00707 }
00708
00709
00710 void storeFamilyCode::operator() (int iCode) const {
00711 std::ostringstream ostr;
00712 ostr << iCode;
00713 _flightDate._itSegmentCabin._itFareFamily._familyCode = ostr.str();
00714 }
00715
00716
00717 storeFClasses::storeFClasses (FlightDateStruct& ioFlightDate)
00718 : ParserSemanticAction (ioFlightDate) {
00719 }
00720
00721
00722 void storeFClasses::operator() (iterator_t iStr,
00723 iterator_t iStrEnd) const {
00724 std::string lClasses (iStr, iStrEnd);
00725 _flightDate._itSegmentCabin._itFareFamily._classes = lClasses;
00726
00727
00728
00729
00730
00731
00732 _flightDate._itSegmentCabin._itFareFamily._classList.
00733 push_back (_flightDate._itBookingClass);
00734 _flightDate._itSegmentCabin._fareFamilies.
00735 push_back (_flightDate._itSegmentCabin._itFareFamily);
00736 _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
00737
00738
00739
00740 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
00741 _flightDate._itSegmentCabin._fareFamilies.clear();
00742 _flightDate._itBookingClass._classCode = "";
00743 }
00744
00745
00746 doEndFlightDate::doEndFlightDate (stdair::BomRoot& ioBomRoot,
00747 FlightDateStruct& ioFlightDate,
00748 unsigned int& ioNbOfFlights)
00749 : ParserSemanticAction (ioFlightDate), _bomRoot (ioBomRoot),
00750 _nbOfFlights (ioNbOfFlights) {
00751 }
00752
00753
00754
00755 void doEndFlightDate::operator() (iterator_t iStr,
00756 iterator_t iStrEnd) const {
00757
00758
00759
00760
00761 if (_flightDate._itSegment._cabinList.empty() == false) {
00762 _flightDate._segmentList.push_back (_flightDate._itSegment);
00763 }
00764
00765
00766
00767 _flightDate._itSegment._cabinList.clear();
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778 InventoryBuilder::buildInventory (_bomRoot, _flightDate);
00779
00780
00781 ++_nbOfFlights;
00782 }
00783
00784
00785
00786
00787
00788
00789
00791 int1_p_t int1_p;
00792
00794 uint2_p_t uint2_p;
00795
00797 uint1_2_p_t uint1_2_p;
00798
00800 uint1_3_p_t uint1_3_p;
00801
00803 uint4_p_t uint4_p;
00804
00806 uint1_4_p_t uint1_4_p;
00807
00809 repeat_p_t airline_code_p (chset_t("0-9A-Z").derived(), 2, 3);
00810
00812 bounded1_4_p_t flight_number_p (uint1_4_p.derived(), 0u, 9999u);
00813
00815 bounded2_p_t year_p (uint2_p.derived(), 0u, 99u);
00816
00818 bounded2_p_t month_p (uint2_p.derived(), 1u, 12u);
00819
00821 bounded2_p_t day_p (uint2_p.derived(), 1u, 31u);
00822
00824 repeat_p_t dow_p (chset_t("0-1").derived().derived(), 7, 7);
00825
00827 repeat_p_t airport_p (chset_t("0-9A-Z").derived(), 3, 3);
00828
00830 bounded1_2_p_t hours_p (uint1_2_p.derived(), 0u, 24u);
00831
00833 bounded2_p_t minutes_p (uint2_p.derived(), 0u, 59u);
00834
00836 bounded2_p_t seconds_p (uint2_p.derived(), 0u, 59u);
00837
00839 chset_t cabin_code_p ("A-Z");
00840
00842 chset_t class_code_p ("A-Z");
00843
00845 chset_t passenger_type_p ("A-Z");
00846
00848 int1_p_t family_code_p;
00849
00851 repeat_p_t class_code_list_p (chset_t("A-Z").derived(), 1, 26);
00852
00854 bounded1_3_p_t stay_duration_p (uint1_3_p.derived(), 0u, 999u);
00855
00856
00857
00858
00859
00860
00861
00862 InventoryParser::InventoryParser (stdair::BomRoot& ioBomRoot,
00863 FlightDateStruct& ioFlightDate,
00864 unsigned int& ioNbOfFlights)
00865 : _bomRoot (ioBomRoot), _flightDate (ioFlightDate),
00866 _nbOfFlights (ioNbOfFlights) {
00867 }
00868
00869
00870 template<typename ScannerT>
00871 InventoryParser::definition<ScannerT>::
00872 definition (InventoryParser const& self) {
00873
00874 flight_date_list = *( not_to_be_parsed | flight_date )
00875 ;
00876
00877 not_to_be_parsed =
00878 bsc::lexeme_d[ bsc::comment_p("//") | bsc::comment_p("/*", "*/")
00879 | bsc::space_p ]
00880 ;
00881
00882 flight_date = flight_key
00883 >> leg_list
00884 >> segment_list
00885 >> flight_date_end[doEndFlightDate (self._bomRoot, self._flightDate,
00886 self._nbOfFlights)]
00887 ;
00888
00889 flight_date_end = bsc::ch_p(';')
00890 ;
00891
00892 flight_key = date[storeSnapshotDate(self._flightDate)]
00893 >> '/' >> airline_code
00894 >> '/' >> flight_number
00895 >> '/' >> date[storeFlightDate(self._flightDate)]
00896 >> '/' >> flight_type_code[storeFlightTypeCode(self._flightDate)]
00897 >> !( '/' >> flight_visibility_code[storeFlightVisibilityCode(self._flightDate)])
00898 ;
00899
00900 airline_code =
00901 bsc::lexeme_d[(airline_code_p)[storeAirlineCode(self._flightDate)]]
00902 ;
00903
00904 flight_number =
00905 bsc::lexeme_d[(flight_number_p)[storeFlightNumber(self._flightDate)]]
00906 ;
00907
00908 date =
00909 bsc::lexeme_d[(day_p)[bsc::assign_a(self._flightDate._itDay)]
00910 >> (month_p)[bsc::assign_a(self._flightDate._itMonth)]
00911 >> (year_p)[bsc::assign_a(self._flightDate._itYear)]]
00912 ;
00913
00914 flight_type_code =
00915 ( bsc::chseq_p("INT") | bsc::chseq_p("DOM") | bsc::chseq_p("GRD") )
00916 ;
00917
00918 flight_visibility_code =
00919 ( bsc::chseq_p("HID") | bsc::chseq_p("PSD") )
00920 ;
00921
00922 leg_list = +( '/' >> leg )
00923 ;
00924
00925 leg = leg_key >> ';' >> leg_details >> leg_cabin_list
00926 ;
00927
00928 leg_key = (airport_p)[storeLegBoardingPoint(self._flightDate)]
00929 >> ';' >> (airport_p)[storeLegOffPoint(self._flightDate)]
00930 ;
00931
00932 leg_details = date[storeBoardingDate(self._flightDate)]
00933 >> ';' >> time[storeBoardingTime(self._flightDate)]
00934 >> ';' >> date[storeOffDate(self._flightDate)]
00935 >> ';' >> time[storeOffTime(self._flightDate)]
00936 ;
00937
00938 leg_cabin_list = +( ';' >> leg_cabin_details >> !bucket_list )
00939 ;
00940
00941 leg_cabin_details = (cabin_code_p)[storeLegCabinCode(self._flightDate)]
00942 >> ',' >> (bsc::ureal_p)[storeSaleableCapacity(self._flightDate)]
00943 >> ',' >> (bsc::real_p)[storeAU(self._flightDate)]
00944 >> ',' >> (bsc::real_p)[storeUPR(self._flightDate)]
00945 >> ',' >> (bsc::real_p)[storeBookingCounter(self._flightDate)]
00946 >> ',' >> (bsc::real_p)[storeNAV(self._flightDate)]
00947 >> ',' >> (bsc::real_p)[storeGAV(self._flightDate)]
00948 >> ',' >> (bsc::ureal_p)[storeACP(self._flightDate)]
00949 >> ',' >> (bsc::real_p)[storeETB(self._flightDate)]
00950 ;
00951
00952 time =
00953 bsc::lexeme_d[
00954 (hours_p)[bsc::assign_a(self._flightDate._itHours)]
00955 >> (minutes_p)[bsc::assign_a(self._flightDate._itMinutes)]
00956 >> !((seconds_p)[bsc::assign_a(self._flightDate._itSeconds)])
00957 ]
00958 ;
00959
00960 bucket_list = +( ',' >> bucket_details )
00961 ;
00962
00963 bucket_details =
00964 (bsc::ureal_p)[storeYieldUpperRange(self._flightDate)]
00965 >> ':' >> (bsc::real_p)[storeBucketAvaibality(self._flightDate)]
00966 >> ':' >> (uint1_3_p)[storeSeatIndex(self._flightDate)];
00967
00968 segment_list = +( '/' >> segment )
00969 ;
00970
00971 segment = segment_key >> segment_cabin_list
00972 ;
00973
00974 segment_key = (airport_p)[storeSegmentBoardingPoint(self._flightDate)]
00975 >> ';' >> (airport_p)[storeSegmentOffPoint(self._flightDate)]
00976 ;
00977
00978 segment_cabin_list =
00979 +( ';' >> segment_cabin_key >> ','
00980 >> segment_cabin_details >> class_list >> family_cabin_list )
00981 ;
00982
00983 family_cabin_list =
00984 +( ';' >> family_cabin_details)
00985 ;
00986
00987 segment_cabin_key =
00988 (cabin_code_p)[storeSegmentCabinCode(self._flightDate)]
00989 ;
00990
00991 segment_cabin_details =
00992 (bsc::ureal_p)[storeSegmentCabinBookingCounter(self._flightDate)]
00993 ;
00994
00995 class_list = +( ',' >> class_key >> '|' >> class_details )
00996 ;
00997
00998 class_key = (class_code_p)[storeClassCode(self._flightDate)]
00999 ;
01000
01001 parent_subclass_code =
01002 (class_code_p)[storeParentClassCode(self._flightDate)]
01003 >> (uint1_2_p)[storeParentSubclassCode(self._flightDate)]
01004 ;
01005
01006 class_protection =
01007 (bsc::ureal_p)[storeProtection(self._flightDate)]
01008 ;
01009
01010 class_nego =
01011 (bsc::ureal_p)[storeNego(self._flightDate)]
01012 ;
01013
01014 class_details = (uint1_2_p)[storeSubclassCode(self._flightDate)]
01015 >> ':' >> (bsc::ureal_p)[storeCumulatedProtection(self._flightDate)]
01016 >> ':' >> !( parent_subclass_code )
01017 >> ':' >> !( class_protection )
01018 >> ':' >> (bsc::ureal_p)[storeNoShow(self._flightDate)]
01019 >> ':' >> (bsc::ureal_p)[storeOverbooking(self._flightDate)]
01020 >> ':' >> (bsc::ureal_p)[storeNbOfBkgs(self._flightDate)]
01021 >> ':' >> (bsc::ureal_p)[storeNbOfGroupBkgs(self._flightDate)]
01022 >> ':' >> (bsc::ureal_p)[storeNbOfPendingGroupBkgs(self._flightDate)]
01023 >> ':' >> (bsc::ureal_p)[storeNbOfStaffBkgs(self._flightDate)]
01024 >> ':' >> (bsc::ureal_p)[storeNbOfWLBkgs(self._flightDate)]
01025 >> ':' >> (bsc::ureal_p)[storeClassETB(self._flightDate)]
01026 >> ':' >> !( class_nego )
01027 >> ':' >> (bsc::real_p)[storeClassAvailability(self._flightDate)]
01028 >> ':' >> (bsc::real_p)[storeSegmentAvailability(self._flightDate)]
01029 >> ':' >> (bsc::real_p)[storeRevenueAvailability(self._flightDate)]
01030 ;
01031
01032 family_cabin_details =
01033 (family_code_p)[storeFamilyCode(self._flightDate)]
01034 >> ';'
01035 >> (class_code_list_p)[storeFClasses(self._flightDate)]
01036 ;
01037
01038
01039 BOOST_SPIRIT_DEBUG_NODE (flight_date_list);
01040 BOOST_SPIRIT_DEBUG_NODE (not_to_be_parsed);
01041 BOOST_SPIRIT_DEBUG_NODE (flight_date);
01042 BOOST_SPIRIT_DEBUG_NODE (flight_date_end);
01043 BOOST_SPIRIT_DEBUG_NODE (flight_key);
01044 BOOST_SPIRIT_DEBUG_NODE (airline_code);
01045 BOOST_SPIRIT_DEBUG_NODE (flight_number);
01046 BOOST_SPIRIT_DEBUG_NODE (flight_type_code);
01047 BOOST_SPIRIT_DEBUG_NODE (flight_visibility_code);
01048 BOOST_SPIRIT_DEBUG_NODE (date);
01049 BOOST_SPIRIT_DEBUG_NODE (leg_list);
01050 BOOST_SPIRIT_DEBUG_NODE (leg);
01051 BOOST_SPIRIT_DEBUG_NODE (leg_key);
01052 BOOST_SPIRIT_DEBUG_NODE (leg_details);
01053 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_list);
01054 BOOST_SPIRIT_DEBUG_NODE (leg_cabin_details);
01055 BOOST_SPIRIT_DEBUG_NODE (bucket_list);
01056 BOOST_SPIRIT_DEBUG_NODE (bucket_details);
01057 BOOST_SPIRIT_DEBUG_NODE (time);
01058 BOOST_SPIRIT_DEBUG_NODE (segment_list);
01059 BOOST_SPIRIT_DEBUG_NODE (segment);
01060 BOOST_SPIRIT_DEBUG_NODE (segment_key);
01061 BOOST_SPIRIT_DEBUG_NODE (full_segment_cabin_details);
01062 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_list);
01063 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_key);
01064 BOOST_SPIRIT_DEBUG_NODE (segment_cabin_details);
01065 BOOST_SPIRIT_DEBUG_NODE (class_list);
01066 BOOST_SPIRIT_DEBUG_NODE (class_key);
01067 BOOST_SPIRIT_DEBUG_NODE (parent_subclass_code);
01068 BOOST_SPIRIT_DEBUG_NODE (class_protection);
01069 BOOST_SPIRIT_DEBUG_NODE (class_nego);
01070 BOOST_SPIRIT_DEBUG_NODE (class_details);
01071 BOOST_SPIRIT_DEBUG_NODE (family_cabin_list);
01072 BOOST_SPIRIT_DEBUG_NODE (family_cabin_details);
01073 }
01074
01075
01076 template<typename ScannerT>
01077 bsc::rule<ScannerT> const&
01078 InventoryParser::definition<ScannerT>::start() const {
01079 return flight_date_list;
01080 }
01081 }
01082
01083
01085
01086
01087
01089
01090
01091 InventoryFileParser::
01092 InventoryFileParser (stdair::BomRoot& ioBomRoot, const std::string& iFilename)
01093 : _filename (iFilename), _bomRoot (ioBomRoot),
01094 _nbOfFlights (0) {
01095 init();
01096 }
01097
01098
01099 void InventoryFileParser::init() {
01100
01101 _startIterator = iterator_t (_filename);
01102
01103
01104 if (!_startIterator) {
01105 std::ostringstream oMessage;
01106 oMessage << "The file " << _filename << " can not be open.";
01107 STDAIR_LOG_ERROR (oMessage.str());
01108 throw InventoryInputFileNotFoundException (oMessage.str());
01109 }
01110
01111
01112 _endIterator = _startIterator.make_end();
01113 }
01114
01115
01116 bool InventoryFileParser::buildInventory () {
01117 bool oResult = false;
01118
01119 STDAIR_LOG_DEBUG ("Parsing inventory input file: " << _filename);
01120
01121
01122 InventoryParserHelper::InventoryParser lInventoryParser (_bomRoot,
01123 _flightDate,
01124 _nbOfFlights);
01125
01126
01127
01128
01129 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
01130 lInventoryParser,
01131 bsc::space_p - bsc::eol_p);
01132
01133
01134 oResult = info.hit;
01135
01136 const std::string hasBeenFullyReadStr = (info.full == true)?"":"not ";
01137 if (oResult == true) {
01138 STDAIR_LOG_DEBUG ("Parsing of inventory input file: " << _filename
01139 << " succeeded: read " << info.length
01140 << " characters. The input file has "
01141 << hasBeenFullyReadStr
01142 << "been fully read. Stop point: " << info.stop);
01143
01144 } else {
01145 STDAIR_LOG_ERROR ("Parsing of inventory input file: " << _filename
01146 << " failed: read " << info.length
01147 << " characters. The input file has "
01148 << hasBeenFullyReadStr
01149 << "been fully read. Stop point: " << info.stop);
01150 throw InventoryFileParsingFailedException("Parsing of inventory input file"
01151 ": " + _filename + " failed");
01152 }
01153
01154 return oResult;
01155 }
01156
01157 }