AirInv Logo  1.00.11
C++ Simulated Airline Inventory Management System Library
Loading...
Searching...
No Matches
InventoryParserHelper.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6// StdAir
7#include <stdair/service/Logger.hpp>
8#include <stdair/stdair_exceptions.hpp>
9// Airinv
11//#define BOOST_SPIRIT_DEBUG
13
14//
15namespace bsc = boost::spirit::classic;
16
17namespace AIRINV {
18
19 namespace InventoryParserHelper {
20
21 // //////////////////////////////////////////////////////////////////
22 // Semantic actions
23 // //////////////////////////////////////////////////////////////////
24
27 : _flightDate (ioFlightDate) {
28 }
29
30 // //////////////////////////////////////////////////////////////////
35
36 // //////////////////////////////////////////////////////////////////
38 iterator_t iStrEnd) const {
39 _flightDate._flightDate = _flightDate.getDate();
40 }
41
42 // //////////////////////////////////////////////////////////////////
45 : ParserSemanticAction (ioFlightDate) {
46 }
47
48 // //////////////////////////////////////////////////////////////////
50 iterator_t iStrEnd) const {
51 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
52 _flightDate._airlineCode = lAirlineCode;
53
54 // As that's the beginning of a new flight, all the list must be reset
55 // 1. Leg branch of the tree
56 _flightDate._legList.clear();
57 _flightDate._itLeg._cabinList.clear();
58 _flightDate._itLegCabin._bucketList.clear();
59 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
60
61 // 2. Segment branch of the tree
62 _flightDate._segmentList.clear();
63 _flightDate._itSegment._cabinList.clear();
64 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
65 _flightDate._itSegmentCabin._fareFamilies.clear();
66 _flightDate._itBookingClass._classCode = "";
67 }
68
69 // //////////////////////////////////////////////////////////////////
73
74 // //////////////////////////////////////////////////////////////////
75 void storeFlightNumber::operator() (unsigned int iNumber) const {
76 _flightDate._flightNumber = iNumber;
77 }
78
79 // //////////////////////////////////////////////////////////////////
83
84 // //////////////////////////////////////////////////////////////////
86 iterator_t iStrEnd) const {
87 _flightDate._flightDate = _flightDate.getDate();
88 }
89
90 // //////////////////////////////////////////////////////////////////
94
95 // //////////////////////////////////////////////////////////////////
97 iterator_t iStrEnd) const {
98 const std::string lFlightTypeCodeStr (iStr, iStrEnd);
99 const FlightTypeCode lFlightTypeCode (lFlightTypeCodeStr);
100 _flightDate._flightTypeCode = lFlightTypeCode.getCode();
101 //STDAIR_LOG_DEBUG ("FlightType code: " << lFlightTypeCode);
102 }
103
104 // //////////////////////////////////////////////////////////////////
109
110 // //////////////////////////////////////////////////////////////////
112 iterator_t iStrEnd) const {
113 const std::string lFlightVisibilityCodeStr (iStr, iStrEnd);
114 const FlightVisibilityCode lFlightVisibilityCode(lFlightVisibilityCodeStr);
115 _flightDate._flightVisibilityCode = lFlightVisibilityCode.getCode();
116 //STDAIR_LOG_DEBUG ("FlightVisibility code: " << lFlightVisibilityCode);
117 }
118
119 // //////////////////////////////////////////////////////////////////
124
125 // //////////////////////////////////////////////////////////////////
127 iterator_t iStrEnd) const {
128 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
129
130 // ///////////////////
131 // If this is not the first leg-date of the flight-date,
132 // the already parsed leg-date must be added to the flight-date.
133 if (_flightDate._itLeg._cabinList.empty() == false) {
134 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
135 _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
136 _flightDate._legList.push_back (_flightDate._itLeg);
137 }
138
139 // As that's the beginning of a new leg-date,
140 // (re-)initialise the leg-cabin branch of the tree
141 _flightDate._itLeg._cabinList.clear();
142 _flightDate._itLegCabin._cabinCode = "";
143 _flightDate._itLegCabin._bucketList.clear();
144 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
145
146 // ///////////////////
147 // Set the (default) operating airline and flight number
148 _flightDate._itLeg._airlineCode = _flightDate._airlineCode;
149 _flightDate._itLeg._flightNumber = _flightDate._flightNumber;
150
151 // Set the (new) boarding point
152 _flightDate._itLeg._boardingPoint = lBoardingPoint;
153
154 // Add the airport code if it is not already stored in the airport lists
155 _flightDate.addAirport (lBoardingPoint);
156 }
157
158 // //////////////////////////////////////////////////////////////////
161 : ParserSemanticAction (ioFlightDate) {
162 }
163
164 // //////////////////////////////////////////////////////////////////
166 iterator_t iStrEnd) const {
167 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
168 _flightDate._itLeg._offPoint = lOffPoint;
169
170 // Add the airport code if it is not already stored in the airport lists
171 _flightDate.addAirport (lOffPoint);
172 }
173
174 // //////////////////////////////////////////////////////////////////
179
180 // //////////////////////////////////////////////////////////////////
182 iterator_t iStrEnd) const {
183 const stdair::AirlineCode_T lAirlineCode (iStr, iStrEnd);
184 if (lAirlineCode.size() == 2) {
185 _flightDate._itLeg._airlineCode = lAirlineCode;
186 }
187 //STDAIR_LOG_DEBUG ("Airline code: " << lAirlineCode);
188 }
189
190 // //////////////////////////////////////////////////////////////////
195
196 // //////////////////////////////////////////////////////////////////
197 void storeOperatingFlightNumber::operator() (unsigned int iNumber) const {
198 _flightDate._itLeg._flightNumber = iNumber;
199 //STDAIR_LOG_DEBUG ("Flight number: " << iNumber);
200 }
201
202
203 // //////////////////////////////////////////////////////////////////
207
208 // //////////////////////////////////////////////////////////////////
210 iterator_t iStrEnd) const {
211 _flightDate._itLeg._boardingDate = _flightDate.getDate();
212 }
213
214 // //////////////////////////////////////////////////////////////////
218
219 // //////////////////////////////////////////////////////////////////
221 iterator_t iStrEnd) const {
222 _flightDate._itLeg._boardingTime = _flightDate.getTime();
223
224 // Reset the number of seconds
225 _flightDate._itSeconds = 0;
226
227 // Reset the date off-set
228 _flightDate._dateOffSet = 0;
229 }
230
231 // //////////////////////////////////////////////////////////////////
233 : ParserSemanticAction (ioFlightDate) {
234 }
235
236 // //////////////////////////////////////////////////////////////////
238 _flightDate._itLeg._offDate = _flightDate.getDate();
239 }
240
241 // //////////////////////////////////////////////////////////////////
243 : ParserSemanticAction (ioFlightDate) {
244 }
245
246 // //////////////////////////////////////////////////////////////////
248 _flightDate._itLeg._offTime = _flightDate.getTime();
249
250 // Reset the number of seconds
251 _flightDate._itSeconds = 0;
252 }
253
254 // //////////////////////////////////////////////////////////////////
258
259 // //////////////////////////////////////////////////////////////////
260 void storeLegCabinCode::operator() (char iChar) const {
261
262 // ///////////////////
263 // If this is not the first leg-cabin of the leg-date,
264 // the already parsed leg-cabin must be added to the leg-date.
265 if (_flightDate._itLegCabin._cabinCode != "") {
266 if (_flightDate._itLegCabin._bucketList.empty() == false) {
267 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
268 }
269 _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
270 }
271
272 // (Re-)initialise the leg-cabin branch of the tree
273 _flightDate._itLegCabin._bucketList.clear();
274 _flightDate._itBucket._yieldRangeUpperValue = 0.0;
275
276
277 // ///////////////////
278 _flightDate._itLegCabin._cabinCode = iChar;
279 //std::cout << "Cabin code: " << iChar << std::endl;
280 }
281
282 // //////////////////////////////////////////////////////////////////
287
288 // //////////////////////////////////////////////////////////////////
289 void storeSaleableCapacity::operator() (double iReal) const {
290 _flightDate._itLegCabin._saleableCapacity = iReal;
291 //std::cout << "Saleable capacity: " << iReal << std::endl;
292 }
293
294 // //////////////////////////////////////////////////////////////////
296 : ParserSemanticAction (ioFlightDate) {
297 }
298
299 // //////////////////////////////////////////////////////////////////
300 void storeAU::operator() (double iReal) const {
301 _flightDate._itLegCabin._au = iReal;
302 //std::cout << "AU: " << iReal << std::endl;
303 }
304
305 // //////////////////////////////////////////////////////////////////
307 : ParserSemanticAction (ioFlightDate) {
308 }
309
310 // //////////////////////////////////////////////////////////////////
311 void storeUPR::operator() (double iReal) const {
312 _flightDate._itLegCabin._upr = iReal;
313 //std::cout << "UPR: " << iReal << std::endl;
314 }
315
316 // //////////////////////////////////////////////////////////////////
320
321 // //////////////////////////////////////////////////////////////////
322 void storeBookingCounter::operator() (double iReal) const {
323 _flightDate._itLegCabin._nbOfBookings = iReal;
324 //std::cout << "Nb of bookings: " << iReal << std::endl;
325 }
326
327 // //////////////////////////////////////////////////////////////////
329 : ParserSemanticAction (ioFlightDate) {
330 }
331
332 // //////////////////////////////////////////////////////////////////
333 void storeNAV::operator() (double iReal) const {
334 _flightDate._itLegCabin._nav = iReal;
335 //std::cout << "NAV: " << iReal << std::endl;
336 }
337
338 // //////////////////////////////////////////////////////////////////
340 : ParserSemanticAction (ioFlightDate) {
341 }
342
343 // //////////////////////////////////////////////////////////////////
344 void storeGAV::operator() (double iReal) const {
345 _flightDate._itLegCabin._gav = iReal;
346 //std::cout << "GAV: " << iReal << std::endl;
347 }
348
349 // //////////////////////////////////////////////////////////////////
351 : ParserSemanticAction (ioFlightDate) {
352 }
353
354 // //////////////////////////////////////////////////////////////////
355 void storeACP::operator() (double iReal) const {
356 _flightDate._itLegCabin._acp = iReal;
357 //std::cout << "ACP: " << iReal << std::endl;
358 }
359
360 // //////////////////////////////////////////////////////////////////
362 : ParserSemanticAction (ioFlightDate) {
363 }
364
365 // //////////////////////////////////////////////////////////////////
366 void storeETB::operator() (double iReal) const {
367 _flightDate._itLegCabin._etb = iReal;
368 //std::cout << "ETB: " << iReal << std::endl;
369 }
370
371 // //////////////////////////////////////////////////////////////////
375
376 // //////////////////////////////////////////////////////////////////
377 void storeYieldUpperRange::operator() (double iReal) const {
378 // If this is not the first bucket of the leg-cabin,
379 // the already parsed bucket must be added to the leg-cabin.
380 if (_flightDate._itBucket._yieldRangeUpperValue != 0.0) {
381 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
382 }
383
384
385 // ///////////////////
386 _flightDate._itBucket._yieldRangeUpperValue = iReal;
387 //std::cout << "Yield Upper Range Value: " << iReal << std::endl;
388 }
389
390 // //////////////////////////////////////////////////////////////////
395
396 // //////////////////////////////////////////////////////////////////
397 void storeBucketAvaibality::operator() (double iReal) const {
398 _flightDate._itBucket._availability = iReal;
399 //std::cout << "Availability: " << iReal << std::endl;
400 }
401
402 // //////////////////////////////////////////////////////////////////
404 : ParserSemanticAction (ioFlightDate) {
405 }
406
407 // //////////////////////////////////////////////////////////////////
408 void storeSeatIndex::operator() (double iReal) const {
409 _flightDate._itBucket._seatIndex = iReal;
410 //std::cout << "Seat Index: " << iReal << std::endl;
411 }
412
413 // //////////////////////////////////////////////////////////////////
418
419 // //////////////////////////////////////////////////////////////////
421 iterator_t iStrEnd) const {
422 stdair::AirportCode_T lBoardingPoint (iStr, iStrEnd);
423
424 // ///////////////////
425 // When the first segment-date is read, it means that the leg section
426 // is over. The parsed leg can therefore be added to the list.
427 if (_flightDate._itLeg._cabinList.empty() == false) {
428 _flightDate._itLegCabin._bucketList.push_back (_flightDate._itBucket);
429 _flightDate._itLeg._cabinList.push_back (_flightDate._itLegCabin);
430 _flightDate._legList.push_back (_flightDate._itLeg);
431
432 // (Re-)initialise the leg-date branch of the tree
433 _flightDate._itLeg._cabinList.clear();
434 _flightDate._itLegCabin._cabinCode = "";
435 _flightDate._itLeg._cabinList.clear();
436 _flightDate._itLegCabin._bucketList.clear();
437 }
438
439
440 // ///////////////////
441 // If this is not the first segment-date of the flight-date,
442 // the already parsed segment-date must be added to the flight-date.
443 if (_flightDate._itSegment._cabinList.empty() == false) {
444 _flightDate._itSegmentCabin._itFareFamily._classList.push_back (_flightDate._itBookingClass);
445 _flightDate._itSegmentCabin._fareFamilies.push_back (_flightDate._itSegmentCabin._itFareFamily);
446 _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
447 _flightDate._segmentList.push_back (_flightDate._itSegment);
448 }
449
450 // As that's the beginning of a new segment-date,
451 // (re-)initialise the segment-cabin branch of the tree
452 _flightDate._itSegment._cabinList.clear();
453 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
454 _flightDate._itSegmentCabin._fareFamilies.clear();
455 _flightDate._itBookingClass._classCode = "";
456
457
458 // ///////////////////
459 _flightDate._itSegment._boardingPoint = lBoardingPoint;
460 //std::cout << "Board point: " << lBoardingPoint << std::endl;
461 }
462
463 // //////////////////////////////////////////////////////////////////
467
468 // //////////////////////////////////////////////////////////////////
470 iterator_t iStrEnd) const {
471 stdair::AirportCode_T lOffPoint (iStr, iStrEnd);
472 _flightDate._itSegment._offPoint = lOffPoint;
473 //std::cout << "Off point: " << lOffPoint << std::endl;
474 }
475
476 // //////////////////////////////////////////////////////////////////
481
482 // //////////////////////////////////////////////////////////////////
483 void storeSegmentCabinCode::operator() (char iChar) const {
484
485 // Reset the list of fare families, as it is a new segment-cabin
486 _flightDate._itSegmentCabin._fareFamilies.clear();
487
488 // ///////////////////
489 // If this is not the first segment-cabin of the segment-date,
490 // the already parsed segment-cabin must be added to the segment-date.
491 if (_flightDate._itSegmentCabin._itFareFamily._classList.empty() == false){
492 _flightDate._itSegmentCabin._itFareFamily._classList.
493 push_back (_flightDate._itBookingClass);
494 _flightDate._itSegmentCabin._fareFamilies.
495 push_back (_flightDate._itSegmentCabin._itFareFamily);
496 _flightDate._itSegment._cabinList.
497 push_back (_flightDate._itSegmentCabin);
498 }
499
500 // (Re-)initialise the booking-class branch of the tree
501 _flightDate._itSegmentCabin._fareFamilies.clear();
502 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
503 _flightDate._itBookingClass._classCode = "";
504
505
506 // ///////////////////
507 _flightDate._itSegmentCabin._cabinCode = iChar;
508 //std::cout << "Segment-cabin code: " << iChar << std::endl;
509 }
510
511 // //////////////////////////////////////////////////////////////////
516
517 // //////////////////////////////////////////////////////////////////
519 _flightDate._itSegmentCabin._nbOfBookings = iReal;
520 //std::cout << "Nb of bookings: " << iReal << std::endl;
521 }
522
523 // //////////////////////////////////////////////////////////////////
525 : ParserSemanticAction (ioFlightDate) {
526 }
527
528 // //////////////////////////////////////////////////////////////////
529 void storeClassCode::operator() (char iChar) const {
530 // If this is not the first booking-class of the segment-cabin,
531 // the already parsed booking-class must be added to the segment-cabin.
532 if (_flightDate._itBookingClass._classCode != "") {
533 _flightDate._itSegmentCabin._itFareFamily._classList.
534 push_back (_flightDate._itBookingClass);
535 }
536
537 // ///////////////////
538 _flightDate._itBookingClass._classCode = iChar;
539 //std::cout << "Booking class code: " << iChar << std::endl;
540 }
541
542 // //////////////////////////////////////////////////////////////////
546
547 // //////////////////////////////////////////////////////////////////
548 void storeSubclassCode::operator() (unsigned int iNumber) const {
549 _flightDate._itBookingClass._subclassCode = iNumber;
550 //std::cout << "Sub-class code: " << iNumber << std::endl;
551 }
552
553 // //////////////////////////////////////////////////////////////////
558
559 // //////////////////////////////////////////////////////////////////
560 void storeParentClassCode::operator() (char iChar) const {
561 _flightDate._itBookingClass._parentClassCode = iChar;
562 //std::cout << "Parent booking class code: " << iChar << std::endl;
563 }
564
565 // //////////////////////////////////////////////////////////////////
570
571 // //////////////////////////////////////////////////////////////////
572 void storeParentSubclassCode::operator() (unsigned int iNumber) const {
573 _flightDate._itBookingClass._parentSubclassCode = iNumber;
574 //std::cout << "Parent sub-class code: " << iNumber << std::endl;
575 }
576
577 // //////////////////////////////////////////////////////////////////
582
583 // //////////////////////////////////////////////////////////////////
584 void storeCumulatedProtection::operator() (double iReal) const {
585 _flightDate._itBookingClass._cumulatedProtection = iReal;
586 //std::cout << "Cumulated protection: " << iReal << std::endl;
587 }
588
589 // //////////////////////////////////////////////////////////////////
591 : ParserSemanticAction (ioFlightDate) {
592 }
593
594 // //////////////////////////////////////////////////////////////////
595 void storeProtection::operator() (double iReal) const {
596 _flightDate._itBookingClass._protection = iReal;
597 //std::cout << "Protection: " << iReal << std::endl;
598 }
599
600 // //////////////////////////////////////////////////////////////////
602 : ParserSemanticAction (ioFlightDate) {
603 }
604
605 // //////////////////////////////////////////////////////////////////
606 void storeNego::operator() (double iReal) const {
607 _flightDate._itBookingClass._nego = iReal;
608 //std::cout << "Negotiated allotment: " << iReal << std::endl;
609 }
610
611 // //////////////////////////////////////////////////////////////////
613 : ParserSemanticAction (ioFlightDate) {
614 }
615
616 // //////////////////////////////////////////////////////////////////
617 void storeNoShow::operator() (double iReal) const {
618 _flightDate._itBookingClass._noShowPercentage = iReal;
619 //std::cout << "No-Show percentage: " << iReal << std::endl;
620 }
621
622 // //////////////////////////////////////////////////////////////////
626
627 // //////////////////////////////////////////////////////////////////
628 void storeOverbooking::operator() (double iReal) const {
629 _flightDate._itBookingClass._overbookingPercentage = iReal;
630 //std::cout << "Overbooking percentage: " << iReal << std::endl;
631 }
632
633 // //////////////////////////////////////////////////////////////////
635 : ParserSemanticAction (ioFlightDate) {
636 }
637
638 // //////////////////////////////////////////////////////////////////
639 void storeNbOfBkgs::operator() (double iReal) const {
640 _flightDate._itBookingClass._nbOfBookings = iReal;
641 //std::cout << "Nb of bookings: " << iReal << std::endl;
642 }
643
644 // //////////////////////////////////////////////////////////////////
648
649 // //////////////////////////////////////////////////////////////////
650 void storeNbOfGroupBkgs::operator() (double iReal) const {
651 _flightDate._itBookingClass._nbOfGroupBookings = iReal;
652 //std::cout << "Nb of group bookings: " << iReal << std::endl;
653 }
654
655 // //////////////////////////////////////////////////////////////////
660
661 // //////////////////////////////////////////////////////////////////
662 void storeNbOfPendingGroupBkgs::operator() (double iReal) const {
663 _flightDate._itBookingClass._nbOfPendingGroupBookings = iReal;
664 //std::cout << "Nb of pending group bookings: " << iReal << std::endl;
665 }
666
667 // //////////////////////////////////////////////////////////////////
671
672 // //////////////////////////////////////////////////////////////////
673 void storeNbOfStaffBkgs::operator() (double iReal) const {
674 _flightDate._itBookingClass._nbOfStaffBookings = iReal;
675 //std::cout << "Nb of staff bookings: " << iReal << std::endl;
676 }
677
678 // //////////////////////////////////////////////////////////////////
680 : ParserSemanticAction (ioFlightDate) {
681 }
682
683 // //////////////////////////////////////////////////////////////////
684 void storeNbOfWLBkgs::operator() (double iReal) const {
685 _flightDate._itBookingClass._nbOfWLBookings = iReal;
686 //std::cout << "Nb of wait-list bookings: " << iReal << std::endl;
687 }
688
689 // //////////////////////////////////////////////////////////////////
691 : ParserSemanticAction (ioFlightDate) {
692 }
693
694 // //////////////////////////////////////////////////////////////////
695 void storeClassETB::operator() (double iReal) const {
696 _flightDate._itBookingClass._etb = iReal;
697 //std::cout << "Class-level ETB: " << iReal << std::endl;
698 }
699
700 // //////////////////////////////////////////////////////////////////
705
706 // //////////////////////////////////////////////////////////////////
707 void storeClassAvailability::operator() (double iReal) const {
708 _flightDate._itBookingClass._netClassAvailability = iReal;
709 //std::cout << "Net class availability: " << iReal << std::endl;
710 }
711
712 // //////////////////////////////////////////////////////////////////
717
718 // //////////////////////////////////////////////////////////////////
719 void storeSegmentAvailability::operator() (double iReal) const {
720 _flightDate._itBookingClass._segmentAvailability = iReal;
721 //std::cout << "Segment availability: " << iReal << std::endl;
722 }
723
724 // //////////////////////////////////////////////////////////////////
729
730 // //////////////////////////////////////////////////////////////////
731 void storeRevenueAvailability::operator() (double iReal) const {
732 _flightDate._itBookingClass._netRevenueAvailability = iReal;
733 //std::cout << "Net revenue availability: " << iReal << std::endl;
734 }
735
736 // //////////////////////////////////////////////////////////////////
738 : ParserSemanticAction (ioFlightDate) {
739 }
740
741 // //////////////////////////////////////////////////////////////////
742 void storeFamilyCode::operator() (int iCode) const {
743 std::ostringstream ostr;
744 ostr << iCode;
745 _flightDate._itSegmentCabin._itFareFamily._familyCode = ostr.str();
746 }
747
748 // //////////////////////////////////////////////////////////////////
750 : ParserSemanticAction (ioFlightDate) {
751 }
752
753 // //////////////////////////////////////////////////////////////////
755 iterator_t iStrEnd) const {
756 std::string lClasses (iStr, iStrEnd);
757 _flightDate._itSegmentCabin._itFareFamily._classes = lClasses;
758
759 // The list of classes is the last (according to the arrival order
760 // within the schedule input file) detail of the segment cabin. Hence,
761 // when a list of classes is parsed, it means that the full segment
762 // cabin details have already been parsed as well: the segment cabin
763 // can thus be added to the segment.
764 _flightDate._itSegmentCabin._itFareFamily._classList.
765 push_back (_flightDate._itBookingClass);
766 _flightDate._itSegmentCabin._fareFamilies.
767 push_back (_flightDate._itSegmentCabin._itFareFamily);
768 _flightDate._itSegment._cabinList.push_back (_flightDate._itSegmentCabin);
769
770 // As that's the beginning of a new segment-cabin,
771 // (re-)initialise the segment-cabin branch of the tree
772 _flightDate._itSegmentCabin._itFareFamily._classList.clear();
773 _flightDate._itSegmentCabin._fareFamilies.clear();
774 _flightDate._itBookingClass._classCode = "";
775 }
776
777 // //////////////////////////////////////////////////////////////////
778 doEndFlightDate::doEndFlightDate (stdair::BomRoot& ioBomRoot,
779 FlightDateStruct& ioFlightDate,
780 unsigned int& ioNbOfFlights)
781 : ParserSemanticAction (ioFlightDate), _bomRoot (ioBomRoot),
782 _nbOfFlights (ioNbOfFlights) {
783 }
784
785 // //////////////////////////////////////////////////////////////////
786 // void doEndFlightDate::operator() (char iChar) const {
788 iterator_t iStrEnd) const {
789
790 // ///////////////////
791 // The segment-date section is now over. It means that the
792 // already parsed segment-date must be added to the flight-date.
793 if (_flightDate._itSegment._cabinList.empty() == false) {
794 _flightDate._segmentList.push_back (_flightDate._itSegment);
795 }
796
797 // As that's the beginning of a new flight-date,
798 // (re-)initialise the segment-cabin branch of the tree
799 _flightDate._itSegment._cabinList.clear();
800
801
802 // ///////////////////
803 //if (_nbOfFlights % 1000 == 0) {
804 // DEBUG: Display the result
805 //STDAIR_LOG_DEBUG ("FlightDate #" << _nbOfFlights
806 // << ": " << _flightDate.describe());
807 //}
808
809 // Build the FlightDate BOM objects
810 InventoryBuilder::buildInventory (_bomRoot, _flightDate);
811
812 //
813 ++_nbOfFlights;
814 }
815
816
817 // ///////////////////////////////////////////////////////////////////
818 //
819 // Utility Parsers
820 //
821 // ///////////////////////////////////////////////////////////////////
824
827
830
833
836
839
841 repeat_p_t airline_code_p (chset_t("0-9A-Z").derived(), 2, 3);
842
845
847 bounded2_p_t year_p (uint2_p.derived(), 0u, 99u);
848
850 bounded2_p_t month_p (uint2_p.derived(), 1u, 12u);
851
853 bounded2_p_t day_p (uint2_p.derived(), 1u, 31u);
854
856 repeat_p_t dow_p (chset_t("0-1").derived().derived(), 7, 7);
857
859 repeat_p_t airport_p (chset_t("0-9A-Z").derived(), 3, 3);
860
862 bounded1_2_p_t hours_p (uint1_2_p.derived(), 0u, 24u);
863
865 bounded2_p_t minutes_p (uint2_p.derived(), 0u, 59u);
866
868 bounded2_p_t seconds_p (uint2_p.derived(), 0u, 59u);
869
872
875
878
881
883 repeat_p_t class_code_list_p (chset_t("A-Z").derived(), 1, 26);
884
887
888
889 // //////////////////////////////////////////////////////////////////
890 // (Boost Spirit) Grammar Definition
891 // //////////////////////////////////////////////////////////////////
892
893 // //////////////////////////////////////////////////////////////////
894 InventoryParser::InventoryParser (stdair::BomRoot& ioBomRoot,
895 FlightDateStruct& ioFlightDate,
896 unsigned int& ioNbOfFlights)
897 : _bomRoot (ioBomRoot), _flightDate (ioFlightDate),
898 _nbOfFlights (ioNbOfFlights) {
899 }
900
901 // //////////////////////////////////////////////////////////////////
902 template<typename ScannerT>
904 definition (InventoryParser const& self) {
905
907 ;
908
910 bsc::lexeme_d[ bsc::comment_p("//") | bsc::comment_p("/*", "*/")
911 | bsc::space_p ]
912 ;
913
915 >> leg_list
916 >> segment_list
918 self._nbOfFlights)]
919 ;
920
921 flight_date_end = bsc::ch_p(';')
922 ;
923
925 >> '/' >> airline_code
926 >> '/' >> flight_number
927 >> '/' >> date[storeFlightDate(self._flightDate)]
930 ;
931
933 bsc::lexeme_d[(airline_code_p)[storeAirlineCode(self._flightDate)]]
934 ;
935
937 bsc::lexeme_d[(flight_number_p)[storeFlightNumber(self._flightDate)]]
938 ;
939
940 date =
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)]]
944 ;
945
947 ( bsc::chseq_p("INT") | bsc::chseq_p("DOM") | bsc::chseq_p("GRD") )
948 ;
949
951 ( bsc::chseq_p("HID") | bsc::chseq_p("PSD") )
952 ;
953
954 leg_list = +( '/' >> leg )
955 ;
956
957 leg = !( operating_leg_details >> ';' )
958 >> leg_key >> ';' >> leg_details >> leg_cabin_list
959 ;
960
963 >> ";"
964 >> bsc::lexeme_d[(flight_number_p)[storeOperatingFlightNumber(self._flightDate)] ]
965 ;
966
968 >> ';' >> (airport_p)[storeLegOffPoint(self._flightDate)]
969 ;
970
972 >> ';' >> time[storeBoardingTime(self._flightDate)]
973 >> ';' >> date[storeOffDate(self._flightDate)]
974 >> ';' >> time[storeOffTime(self._flightDate)]
975 ;
976
978 ;
979
981 >> ',' >> (bsc::ureal_p)[storeSaleableCapacity(self._flightDate)]
982 >> ',' >> (bsc::real_p)[storeAU(self._flightDate)]
983 >> ',' >> (bsc::real_p)[storeUPR(self._flightDate)]
984 >> ',' >> (bsc::real_p)[storeBookingCounter(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)]
989 ;
990
991 time =
992 bsc::lexeme_d[
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)])
996 ]
997 ;
998
999 bucket_list = +( ',' >> bucket_details )
1000 ;
1001
1003 (bsc::ureal_p)[storeYieldUpperRange(self._flightDate)]
1004 >> ':' >> (bsc::real_p)[storeBucketAvaibality(self._flightDate)]
1005 >> ':' >> (uint1_3_p)[storeSeatIndex(self._flightDate)];
1006
1007 segment_list = +( '/' >> segment )
1008 ;
1009
1011 ;
1012
1014 >> ';' >> (airport_p)[storeSegmentOffPoint(self._flightDate)]
1015 ;
1016
1018 +( ';' >> segment_cabin_key >> ','
1020 ;
1021
1023 +( ';' >> family_cabin_details)
1024 ;
1025
1028 ;
1029
1031 (bsc::ureal_p)[storeSegmentCabinBookingCounter(self._flightDate)]
1032 ;
1033
1034 class_list = +( ',' >> class_key >> '|' >> class_details )
1035 ;
1036
1038 ;
1039
1043 ;
1044
1046 (bsc::ureal_p)[storeProtection(self._flightDate)]
1047 ;
1048
1049 class_nego =
1050 (bsc::ureal_p)[storeNego(self._flightDate)]
1051 ;
1052
1054 >> ':' >> (bsc::ureal_p)[storeCumulatedProtection(self._flightDate)]
1055 >> ':' >> !( parent_subclass_code )
1056 >> ':' >> !( class_protection )
1057 >> ':' >> (bsc::ureal_p)[storeNoShow(self._flightDate)]
1058 >> ':' >> (bsc::ureal_p)[storeOverbooking(self._flightDate)]
1059 >> ':' >> (bsc::ureal_p)[storeNbOfBkgs(self._flightDate)]
1060 >> ':' >> (bsc::ureal_p)[storeNbOfGroupBkgs(self._flightDate)]
1061 >> ':' >> (bsc::ureal_p)[storeNbOfPendingGroupBkgs(self._flightDate)]
1062 >> ':' >> (bsc::ureal_p)[storeNbOfStaffBkgs(self._flightDate)]
1063 >> ':' >> (bsc::ureal_p)[storeNbOfWLBkgs(self._flightDate)]
1064 >> ':' >> (bsc::ureal_p)[storeClassETB(self._flightDate)]
1065 >> ':' >> !( class_nego )
1066 >> ':' >> (bsc::real_p)[storeClassAvailability(self._flightDate)]
1067 >> ':' >> (bsc::real_p)[storeSegmentAvailability(self._flightDate)]
1068 >> ':' >> (bsc::real_p)[storeRevenueAvailability(self._flightDate)]
1069 ;
1070
1073 >> ';'
1075 ;
1076
1077 // BOOST_SPIRIT_DEBUG_NODE (InventoryParser);
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);
1113 }
1114
1115 // //////////////////////////////////////////////////////////////////
1116 template<typename ScannerT>
1117 bsc::rule<ScannerT> const&
1121 }
1122
1123
1125 //
1126 // Entry class for the file parser
1127 //
1129
1130 // //////////////////////////////////////////////////////////////////////
1132 InventoryFileParser (stdair::BomRoot& ioBomRoot, const std::string& iFilename)
1133 : _filename (iFilename), _bomRoot (ioBomRoot),
1134 _nbOfFlights (0) {
1135 init();
1136 }
1137
1138 // //////////////////////////////////////////////////////////////////////
1139 void InventoryFileParser::init() {
1140 // Open the file
1141 _startIterator = iterator_t (_filename);
1142
1143 // Check the filename exists and can be open
1144 if (!_startIterator) {
1145 std::ostringstream oMessage;
1146 oMessage << "The file " << _filename << " can not be open.";
1147 STDAIR_LOG_ERROR (oMessage.str());
1148 throw InventoryInputFileNotFoundException (oMessage.str());
1149 }
1150
1151 // Create an EOF iterator
1152 _endIterator = _startIterator.make_end();
1153 }
1154
1155 // //////////////////////////////////////////////////////////////////////
1157 bool oResult = false;
1158
1159 STDAIR_LOG_DEBUG ("Parsing inventory input file: " << _filename);
1160
1161 // Initialise the parser (grammar) with the helper/staging structure.
1162 InventoryParserHelper::InventoryParser lInventoryParser (_bomRoot,
1163 _flightDate,
1164 _nbOfFlights);
1165
1166 // Launch the parsing of the file and, thanks to the doEndFlightDate
1167 // call-back structure, the building of the whole Inventory BOM
1168 // (i.e., including Inventory, FlightDate, LegDate, SegmentDate, etc.)
1169 bsc::parse_info<iterator_t> info = bsc::parse (_startIterator, _endIterator,
1170 lInventoryParser,
1171 bsc::space_p - bsc::eol_p);
1172
1173 // Retrieves whether or not the parsing was successful
1174 oResult = info.hit;
1175
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);
1183
1184 } else {
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);
1190 throw InventoryFileParsingFailedException("Parsing of inventory input file"
1191 ": " + _filename + " failed");
1192 }
1193
1194 return oResult;
1195 }
1196
1197}
InventoryFileParser(stdair::BomRoot &, const stdair::Filename_T &iInventoryInputFilename)
bounded2_p_t year_p(uint2_p.derived(), 0u, 99u)
bounded1_2_p_t hours_p(uint1_2_p.derived(), 0u, 24u)
bounded2_p_t month_p(uint2_p.derived(), 1u, 12u)
repeat_p_t dow_p(chset_t("0-1").derived().derived(), 7, 7)
bounded1_3_p_t stay_duration_p(uint1_3_p.derived(), 0u, 999u)
repeat_p_t class_code_list_p(chset_t("A-Z").derived(), 1, 26)
bounded1_4_p_t flight_number_p(uint1_4_p.derived(), 0u, 9999u)
bounded2_p_t minutes_p(uint2_p.derived(), 0u, 59u)
repeat_p_t airport_p(chset_t("0-9A-Z").derived(), 3, 3)
bounded2_p_t seconds_p(uint2_p.derived(), 0u, 59u)
bounded2_p_t day_p(uint2_p.derived(), 1u, 31u)
repeat_p_t airline_code_p(chset_t("0-9A-Z").derived(), 2, 3)
boost::spirit::classic::impl::loop_traits< chset_t, unsignedint, unsignedint >::type repeat_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 3 > uint1_3_p_t
boost::spirit::classic::int_parser< unsigned int, 10, 1, 1 > int1_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 2, 2 > uint2_p_t
boost::spirit::classic::bounded< uint1_4_p_t, unsigned int > bounded1_4_p_t
boost::spirit::classic::bounded< uint2_p_t, unsigned int > bounded2_p_t
boost::spirit::classic::chset< char_t > chset_t
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 2 > uint1_2_p_t
boost::spirit::classic::file_iterator< char_t > iterator_t
boost::spirit::classic::bounded< uint1_3_p_t, unsigned int > bounded1_3_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 4 > uint1_4_p_t
boost::spirit::classic::bounded< uint1_2_p_t, unsigned int > bounded1_2_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 4, 4 > uint4_p_t
EN_FlightTypeCode getCode() const
EN_FlightVisibilityCode getCode() const
boost::spirit::classic::rule< ScannerT > full_segment_cabin_details
boost::spirit::classic::rule< ScannerT > flight_visibility_code
boost::spirit::classic::rule< ScannerT > const & start() const
InventoryParser(stdair::BomRoot &, FlightDateStruct &, unsigned int &)
doEndFlightDate(stdair::BomRoot &, FlightDateStruct &, unsigned int &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const