SimFQT Logo  0.1.3
C++ Simulated Fare Quote System Library
FareParserHelper.hpp
Go to the documentation of this file.
00001 #ifndef __SIMFQT_CMD_FAREPARSERHELPER_HPP
00002 #define __SIMFQT_CMD_FAREPARSERHELPER_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <string>
00009 // Boost
00010 #include <boost/spirit/include/qi.hpp>
00011 // StdAir
00012 #include <stdair/command/CmdAbstract.hpp>
00013 // Simfqt
00014 #include <simfqt/SIMFQT_Types.hpp>
00015 #include <simfqt/bom/FareRuleStruct.hpp>
00016 
00017 // Forward declarations
00018 namespace stdair {
00019   class BomRoot;
00020 }
00021 
00022 namespace SIMFQT {
00023 
00024   namespace FareParserHelper {
00025     
00026     // ///////////////////////////////////////////////////////////////////
00027     //  Semantic actions
00028     // ////////////////////////////////////////////////////
00030 
00031     struct ParserSemanticAction {
00033       ParserSemanticAction (FareRuleStruct&);
00035       FareRuleStruct& _fareRule;
00036     };
00037 
00039     struct storeFareId : public ParserSemanticAction {
00041       storeFareId (FareRuleStruct&);
00043       void operator() (unsigned int,
00044                        boost::spirit::qi::unused_type,
00045                        boost::spirit::qi::unused_type) const;
00046     };
00047 
00049     struct storeOrigin : public ParserSemanticAction {
00051       storeOrigin (FareRuleStruct&);
00053       void operator() (std::vector<char>,
00054                        boost::spirit::qi::unused_type,
00055                        boost::spirit::qi::unused_type) const;
00056     };
00057 
00059     struct storeDestination : public ParserSemanticAction {
00061       storeDestination (FareRuleStruct&);
00063       void operator() (std::vector<char>,
00064                        boost::spirit::qi::unused_type,
00065                        boost::spirit::qi::unused_type) const;
00066     };
00067     
00069     struct storeTripType : public ParserSemanticAction {
00071       storeTripType (FareRuleStruct&);
00073       void operator() (std::vector<char>,
00074                        boost::spirit::qi::unused_type,
00075                        boost::spirit::qi::unused_type) const;
00076     };
00077 
00078 
00080     struct storeDateRangeStart : public ParserSemanticAction {
00082       storeDateRangeStart (FareRuleStruct&);
00084       void operator() (boost::spirit::qi::unused_type,
00085                        boost::spirit::qi::unused_type,
00086                        boost::spirit::qi::unused_type) const;
00087     };
00088 
00090     struct storeDateRangeEnd : public ParserSemanticAction {
00092       storeDateRangeEnd (FareRuleStruct&);
00094       void operator() (boost::spirit::qi::unused_type,
00095                        boost::spirit::qi::unused_type,
00096                        boost::spirit::qi::unused_type) const;
00097     };
00098 
00100     struct storeStartRangeTime : public ParserSemanticAction {
00102       storeStartRangeTime (FareRuleStruct&);
00104       void operator() (boost::spirit::qi::unused_type,
00105                        boost::spirit::qi::unused_type,
00106                        boost::spirit::qi::unused_type) const;
00107     };
00108 
00110     struct storeEndRangeTime : public ParserSemanticAction {
00112       storeEndRangeTime (FareRuleStruct&);
00114       void operator() (boost::spirit::qi::unused_type,
00115                        boost::spirit::qi::unused_type,
00116                        boost::spirit::qi::unused_type) const;
00117     };
00118 
00120     struct storePOS : public ParserSemanticAction {
00122       storePOS (FareRuleStruct&);
00124       void operator() (std::vector<char>,
00125                        boost::spirit::qi::unused_type,
00126                        boost::spirit::qi::unused_type) const;
00127     };
00128 
00130     struct storeCabinCode : public ParserSemanticAction {
00132       storeCabinCode  (FareRuleStruct&);
00134       void operator() (char,
00135                        boost::spirit::qi::unused_type,
00136                        boost::spirit::qi::unused_type) const;
00137     };
00138 
00140     struct storeChannel : public ParserSemanticAction {
00142       storeChannel (FareRuleStruct&);
00144       void operator() (std::vector<char>,
00145                        boost::spirit::qi::unused_type,
00146                        boost::spirit::qi::unused_type) const;
00147     };
00148 
00150     struct storeAdvancePurchase : public ParserSemanticAction {
00152       storeAdvancePurchase (FareRuleStruct&);
00154       void operator() (unsigned int,
00155                        boost::spirit::qi::unused_type,
00156                        boost::spirit::qi::unused_type) const;
00157     };
00158 
00160     struct storeSaturdayStay : public ParserSemanticAction {
00162       storeSaturdayStay (FareRuleStruct&);
00164       void operator() (char,
00165                        boost::spirit::qi::unused_type,
00166                        boost::spirit::qi::unused_type) const;
00167     };
00168     
00170     struct storeChangeFees : public ParserSemanticAction {
00172       storeChangeFees (FareRuleStruct&);
00174       void operator() (char,
00175                        boost::spirit::qi::unused_type,
00176                        boost::spirit::qi::unused_type) const;
00177     };
00178 
00180     struct storeNonRefundable : public ParserSemanticAction {
00182       storeNonRefundable (FareRuleStruct&);
00184       void operator() (char,
00185                        boost::spirit::qi::unused_type,
00186                        boost::spirit::qi::unused_type) const;
00187     };
00188     
00190     struct storeMinimumStay : public ParserSemanticAction {
00192       storeMinimumStay (FareRuleStruct&);
00194       void operator() (unsigned int,
00195                        boost::spirit::qi::unused_type,
00196                        boost::spirit::qi::unused_type) const;
00197     };
00198 
00200     struct storeFare : public ParserSemanticAction {
00202       storeFare (FareRuleStruct&);
00204       void operator() (double,
00205                        boost::spirit::qi::unused_type,
00206                        boost::spirit::qi::unused_type) const; 
00207     };
00208     
00210     struct storeAirlineCode : public ParserSemanticAction {
00212       storeAirlineCode (FareRuleStruct&);
00214       void operator() (std::vector<char>,
00215                        boost::spirit::qi::unused_type,
00216                        boost::spirit::qi::unused_type) const;
00217     };
00218 
00220     struct storeClass : public ParserSemanticAction {
00222       storeClass (FareRuleStruct&);
00224       void operator() (std::vector<char>,
00225                        boost::spirit::qi::unused_type,
00226                        boost::spirit::qi::unused_type) const; 
00227     };
00228     
00230     struct doEndFare : public ParserSemanticAction {
00232       doEndFare (stdair::BomRoot&, FareRuleStruct&);
00234       void operator() (boost::spirit::qi::unused_type,
00235                        boost::spirit::qi::unused_type,
00236                        boost::spirit::qi::unused_type) const;
00238       stdair::BomRoot& _bomRoot;
00239     };
00240   
00241   }
00242   
00244   //
00245   //  Entry class for the file parser
00246   //
00248 
00254   class FareRuleFileParser : public stdair::CmdAbstract {
00255   public:
00257     FareRuleFileParser (stdair::BomRoot& ioBomRoot,
00258                         const stdair::Filename_T& iFilename);
00259 
00261     void generateFareRules ();
00262       
00263   private:
00265     void init();
00266       
00267   private:
00268     // Attributes
00270     stdair::Filename_T _filename;
00271 
00273     stdair::BomRoot& _bomRoot;
00274 
00276     FareRuleStruct _fareRule;
00277   };
00278     
00279 }
00280 #endif // __SIMFQT_CMD_FAREPARSERHELPER_HPP