$treeview $search $mathjax
00001 #ifndef __AIRINV_CMD_INVENTORYPARSERHELPER_HPP 00002 #define __AIRINV_CMD_INVENTORYPARSERHELPER_HPP 00003 00004 // ////////////////////////////////////////////////////////////////////// 00005 // Import section 00006 // ////////////////////////////////////////////////////////////////////// 00007 // STL 00008 #include <string> 00009 // StdAir 00010 #include <stdair/command/CmdAbstract.hpp> 00011 // Airinv 00012 #include <airinv/AIRINV_Types.hpp> 00013 #include <airinv/basic/BasParserTypes.hpp> 00014 #include <airinv/bom/FlightDateStruct.hpp> 00015 00016 // Forward declarations 00017 namespace stdair { 00018 class BomRoot; 00019 } 00020 00021 namespace AIRINV { 00022 00023 namespace InventoryParserHelper { 00024 00025 // /////////////////////////////////////////////////////////////////// 00026 // Semantic actions 00027 // /////////////////////////////////////////////////////////////////// 00029 struct ParserSemanticAction { 00031 ParserSemanticAction (FlightDateStruct&); 00033 FlightDateStruct& _flightDate; 00034 }; 00035 00037 struct storeSnapshotDate : public ParserSemanticAction { 00039 storeSnapshotDate (FlightDateStruct&); 00041 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00042 }; 00043 00045 struct storeAirlineCode : public ParserSemanticAction { 00047 storeAirlineCode (FlightDateStruct&); 00049 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00050 }; 00051 00053 struct storeFlightNumber : public ParserSemanticAction { 00055 storeFlightNumber (FlightDateStruct&); 00057 void operator() (unsigned int iNumber) const; 00058 }; 00059 00061 struct storeFlightDate : public ParserSemanticAction { 00063 storeFlightDate (FlightDateStruct&); 00065 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00066 }; 00067 00069 struct storeFlightTypeCode : public ParserSemanticAction { 00071 storeFlightTypeCode (FlightDateStruct&); 00073 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00074 }; 00075 00077 struct storeFlightVisibilityCode : public ParserSemanticAction { 00079 storeFlightVisibilityCode (FlightDateStruct&); 00081 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00082 }; 00083 00085 struct storeLegBoardingPoint : public ParserSemanticAction { 00087 storeLegBoardingPoint (FlightDateStruct&); 00089 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00090 }; 00091 00093 struct storeLegOffPoint : public ParserSemanticAction { 00095 storeLegOffPoint (FlightDateStruct&); 00097 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00098 }; 00099 00101 struct storeOperatingAirlineCode : public ParserSemanticAction { 00103 storeOperatingAirlineCode (FlightDateStruct&); 00105 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00106 }; 00107 00109 struct storeOperatingFlightNumber : public ParserSemanticAction { 00111 storeOperatingFlightNumber (FlightDateStruct&); 00113 void operator() (unsigned int iNumber) const; 00114 }; 00115 00117 struct storeBoardingDate : public ParserSemanticAction { 00119 storeBoardingDate (FlightDateStruct&); 00121 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00122 }; 00123 00125 struct storeBoardingTime : public ParserSemanticAction { 00127 storeBoardingTime (FlightDateStruct&); 00129 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00130 }; 00131 00133 struct storeOffDate : public ParserSemanticAction { 00135 storeOffDate (FlightDateStruct&); 00137 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00138 }; 00139 00141 struct storeOffTime : public ParserSemanticAction { 00143 storeOffTime (FlightDateStruct&); 00145 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00146 }; 00147 00149 struct storeLegCabinCode : public ParserSemanticAction { 00151 storeLegCabinCode (FlightDateStruct&); 00153 void operator() (char iChar) const; 00154 }; 00155 00157 struct storeSaleableCapacity : public ParserSemanticAction { 00159 storeSaleableCapacity (FlightDateStruct&); 00161 void operator() (double iReal) const; 00162 }; 00163 00165 struct storeAU : public ParserSemanticAction { 00167 storeAU (FlightDateStruct&); 00169 void operator() (double iReal) const; 00170 }; 00171 00173 struct storeUPR : public ParserSemanticAction { 00175 storeUPR (FlightDateStruct&); 00177 void operator() (double iReal) const; 00178 }; 00179 00181 struct storeBookingCounter : public ParserSemanticAction { 00183 storeBookingCounter (FlightDateStruct&); 00185 void operator() (double iReal) const; 00186 }; 00187 00189 struct storeNAV : public ParserSemanticAction { 00191 storeNAV (FlightDateStruct&); 00193 void operator() (double iReal) const; 00194 }; 00195 00197 struct storeGAV : public ParserSemanticAction { 00199 storeGAV (FlightDateStruct&); 00201 void operator() (double iReal) const; 00202 }; 00203 00205 struct storeACP : public ParserSemanticAction { 00207 storeACP (FlightDateStruct&); 00209 void operator() (double iReal) const; 00210 }; 00211 00213 struct storeETB : public ParserSemanticAction { 00215 storeETB (FlightDateStruct&); 00217 void operator() (double iReal) const; 00218 }; 00219 00221 struct storeYieldUpperRange : public ParserSemanticAction { 00223 storeYieldUpperRange (FlightDateStruct&); 00225 void operator() (double iReal) const; 00226 }; 00227 00229 struct storeBucketAvaibality : public ParserSemanticAction { 00231 storeBucketAvaibality (FlightDateStruct&); 00233 void operator() (double iReal) const; 00234 }; 00235 00237 struct storeSeatIndex : public ParserSemanticAction { 00239 storeSeatIndex (FlightDateStruct&); 00241 void operator() (double iReal) const; 00242 }; 00243 00245 struct storeSegmentBoardingPoint : public ParserSemanticAction { 00247 storeSegmentBoardingPoint (FlightDateStruct&); 00249 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00250 }; 00251 00253 struct storeSegmentOffPoint : public ParserSemanticAction { 00255 storeSegmentOffPoint (FlightDateStruct&); 00257 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00258 }; 00259 00261 struct storeSegmentCabinCode : public ParserSemanticAction { 00263 storeSegmentCabinCode (FlightDateStruct&); 00265 void operator() (char iChar) const; 00266 }; 00267 00269 struct storeSegmentCabinBookingCounter : public ParserSemanticAction { 00271 storeSegmentCabinBookingCounter (FlightDateStruct&); 00273 void operator() (double iReal) const; 00274 }; 00275 00277 struct storeClassCode : public ParserSemanticAction { 00279 storeClassCode (FlightDateStruct&); 00281 void operator() (char iChar) const; 00282 }; 00283 00285 struct storeSubclassCode : public ParserSemanticAction { 00287 storeSubclassCode (FlightDateStruct&); 00289 void operator() (unsigned int iNumber) const; 00290 }; 00291 00293 struct storeParentClassCode : public ParserSemanticAction { 00295 storeParentClassCode (FlightDateStruct&); 00297 void operator() (char iChar) const; 00298 }; 00299 00301 struct storeParentSubclassCode : public ParserSemanticAction { 00303 storeParentSubclassCode (FlightDateStruct&); 00305 void operator() (unsigned int iNumber) const; 00306 }; 00307 00309 struct storeCumulatedProtection : public ParserSemanticAction { 00311 storeCumulatedProtection (FlightDateStruct&); 00313 void operator() (double iReal) const; 00314 }; 00315 00317 struct storeProtection : public ParserSemanticAction { 00319 storeProtection (FlightDateStruct&); 00321 void operator() (double iReal) const; 00322 }; 00323 00325 struct storeNego : public ParserSemanticAction { 00327 storeNego (FlightDateStruct&); 00329 void operator() (double iReal) const; 00330 }; 00331 00333 struct storeNoShow : public ParserSemanticAction { 00335 storeNoShow (FlightDateStruct&); 00337 void operator() (double iReal) const; 00338 }; 00339 00341 struct storeOverbooking : public ParserSemanticAction { 00343 storeOverbooking (FlightDateStruct&); 00345 void operator() (double iReal) const; 00346 }; 00347 00349 struct storeNbOfBkgs : public ParserSemanticAction { 00351 storeNbOfBkgs (FlightDateStruct&); 00353 void operator() (double iReal) const; 00354 }; 00355 00357 struct storeNbOfGroupBkgs : public ParserSemanticAction { 00359 storeNbOfGroupBkgs (FlightDateStruct&); 00361 void operator() (double iReal) const; 00362 }; 00363 00365 struct storeNbOfPendingGroupBkgs : public ParserSemanticAction { 00367 storeNbOfPendingGroupBkgs (FlightDateStruct&); 00369 void operator() (double iReal) const; 00370 }; 00371 00373 struct storeNbOfStaffBkgs : public ParserSemanticAction { 00375 storeNbOfStaffBkgs (FlightDateStruct&); 00377 void operator() (double iReal) const; 00378 }; 00379 00382 struct storeNbOfWLBkgs : public ParserSemanticAction { 00384 storeNbOfWLBkgs (FlightDateStruct&); 00386 void operator() (double iReal) const; 00387 }; 00388 00390 struct storeClassETB : public ParserSemanticAction { 00392 storeClassETB (FlightDateStruct&); 00394 void operator() (double iReal) const; 00395 }; 00396 00399 struct storeClassAvailability : public ParserSemanticAction { 00401 storeClassAvailability (FlightDateStruct&); 00403 void operator() (double iReal) const; 00404 }; 00405 00408 struct storeSegmentAvailability : public ParserSemanticAction { 00410 storeSegmentAvailability (FlightDateStruct&); 00412 void operator() (double iReal) const; 00413 }; 00414 00417 struct storeRevenueAvailability : public ParserSemanticAction { 00419 storeRevenueAvailability (FlightDateStruct&); 00421 void operator() (double iReal) const; 00422 }; 00423 00425 struct storeFamilyCode : public ParserSemanticAction { 00427 storeFamilyCode (FlightDateStruct&); 00429 void operator() (int iCode) const; 00430 }; 00431 00433 struct storeFClasses : public ParserSemanticAction { 00435 storeFClasses (FlightDateStruct&); 00437 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00438 }; 00439 00441 struct doEndFlightDate : public ParserSemanticAction { 00443 doEndFlightDate (stdair::BomRoot&, FlightDateStruct&, 00444 unsigned int&); 00446 void operator() (iterator_t iStr, iterator_t iStrEnd) const; 00448 stdair::BomRoot& _bomRoot; 00449 unsigned int& _nbOfFlights; 00450 }; 00451 00452 00454 // 00455 // (Boost Spirit) Grammar Definition 00456 // 00458 00470 struct InventoryParser : 00471 public boost::spirit::classic::grammar<InventoryParser> { 00472 00473 InventoryParser (stdair::BomRoot&, FlightDateStruct&, unsigned int&); 00474 00475 template <typename ScannerT> 00476 struct definition { 00477 definition (InventoryParser const& self); 00478 00479 // Instantiation of rules 00480 boost::spirit::classic::rule<ScannerT> flight_date_list, 00481 not_to_be_parsed, 00482 flight_date, flight_date_end, flight_key, airline_code, flight_number, 00483 flight_type_code, flight_visibility_code, 00484 date, leg_list, leg, operating_leg_details, leg_key, leg_details, 00485 leg_cabin_list, leg_cabin_details, 00486 bucket_list, bucket_details, 00487 time, segment_list, segment, segment_key, full_segment_cabin_details, 00488 segment_cabin_list, segment_cabin_key, segment_cabin_details, 00489 class_list, class_key, parent_subclass_code, 00490 class_protection, class_nego, class_details, 00491 family_cabin_list, family_cabin_details; 00492 00494 boost::spirit::classic::rule<ScannerT> const& start() const; 00495 }; 00496 00497 // Parser Context 00498 stdair::BomRoot& _bomRoot; 00499 FlightDateStruct& _flightDate; 00500 unsigned int& _nbOfFlights; 00501 }; 00502 00503 } 00504 00505 00507 // 00508 // Entry class for the file parser 00509 // 00511 00516 class InventoryFileParser : public stdair::CmdAbstract { 00517 public: 00519 InventoryFileParser (stdair::BomRoot&, 00520 const stdair::Filename_T& iInventoryInputFilename); 00521 00523 bool buildInventory (); 00524 00525 private: 00527 void init(); 00528 00529 private: 00530 // Attributes 00532 stdair::Filename_T _filename; 00533 00535 iterator_t _startIterator; 00536 00538 iterator_t _endIterator; 00539 00541 stdair::BomRoot& _bomRoot; 00542 00544 FlightDateStruct _flightDate; 00545 00547 unsigned int _nbOfFlights; 00548 }; 00549 00550 } 00551 #endif // __AIRINV_CMD_INVENTORYPARSERHELPER_HPP