AirRAC Logo  0.2.0
C++ Simulated Revenue Accounting (RAC) System Library
YieldParserHelper.hpp
Go to the documentation of this file.
00001 #ifndef __AIRRAC_CMD_YIELDPARSERHELPER_HPP
00002 #define __AIRRAC_CMD_YIELDPARSERHELPER_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <string>
00009 //#define BOOST_SPIRIT_DEBUG
00010 // StdAir
00011 #include <stdair/basic/BasParserTypes.hpp>
00012 #include <stdair/command/CmdAbstract.hpp>
00013 // Airrac
00014 #include <airrac/AIRRAC_Types.hpp>
00015 #include <airrac/bom/YieldRuleStruct.hpp>
00016 
00017 // Forward declarations
00018 namespace stdair {
00019   class BomRoot;
00020 }
00021 
00022 namespace AIRRAC {
00023 
00024   namespace YieldParserHelper {
00025 
00026     // ///////////////////////////////////////////////////////////////////
00027     //  Semantic actions
00028     // ///////////////////////////////////////////////////////////////////
00030     struct ParserSemanticAction {
00032       ParserSemanticAction (YieldRuleStruct&);
00034       YieldRuleStruct& _yieldRule;
00035     };
00036 
00038     struct storeYieldId : public ParserSemanticAction {
00040       storeYieldId (YieldRuleStruct&);
00042       void operator() (unsigned int,
00043                        boost::spirit::qi::unused_type,
00044                        boost::spirit::qi::unused_type) const;
00045     };
00046 
00048     struct storeOrigin : public ParserSemanticAction {
00050       storeOrigin (YieldRuleStruct&);
00052       void operator() (std::vector<char>,
00053                        boost::spirit::qi::unused_type,
00054                        boost::spirit::qi::unused_type) const;
00055     };
00056 
00058     struct storeDestination : public ParserSemanticAction {
00060       storeDestination (YieldRuleStruct&);
00062       void operator() (std::vector<char>,
00063                        boost::spirit::qi::unused_type,
00064                        boost::spirit::qi::unused_type) const;
00065     };   
00066 
00068     struct storeTripType : public ParserSemanticAction {
00070       storeTripType (YieldRuleStruct&);
00072       void operator() (std::vector<char>,
00073                        boost::spirit::qi::unused_type,
00074                        boost::spirit::qi::unused_type) const;
00075     };
00076 
00078     struct storeDateRangeStart : public ParserSemanticAction {
00080       storeDateRangeStart (YieldRuleStruct&);
00082       void operator() (boost::spirit::qi::unused_type,
00083                        boost::spirit::qi::unused_type,
00084                        boost::spirit::qi::unused_type) const;
00085     };
00086 
00088     struct storeDateRangeEnd : public ParserSemanticAction {
00090       storeDateRangeEnd (YieldRuleStruct&);
00092       void operator() (boost::spirit::qi::unused_type,
00093                        boost::spirit::qi::unused_type,
00094                        boost::spirit::qi::unused_type) const;
00095     };
00096 
00098     struct storeStartRangeTime : public ParserSemanticAction {
00100       storeStartRangeTime (YieldRuleStruct&);
00102       void operator() (boost::spirit::qi::unused_type,
00103                        boost::spirit::qi::unused_type,
00104                        boost::spirit::qi::unused_type) const;
00105     };
00106 
00108     struct storeEndRangeTime : public ParserSemanticAction {
00110       storeEndRangeTime (YieldRuleStruct&);
00112       void operator() (boost::spirit::qi::unused_type,
00113                        boost::spirit::qi::unused_type,
00114                        boost::spirit::qi::unused_type) const;
00115     };
00116 
00118     struct storePOS : public ParserSemanticAction {
00120       storePOS (YieldRuleStruct&);
00122       void operator() (std::vector<char>,
00123                        boost::spirit::qi::unused_type,
00124                        boost::spirit::qi::unused_type) const;
00125     };
00126 
00128     struct storeCabinCode : public ParserSemanticAction {
00130       storeCabinCode  (YieldRuleStruct&);
00132       void operator() (char,
00133                        boost::spirit::qi::unused_type,
00134                        boost::spirit::qi::unused_type) const;
00135     };
00136 
00138     struct storeChannel : public ParserSemanticAction {
00140       storeChannel (YieldRuleStruct&);
00142       void operator() (std::vector<char>,
00143                        boost::spirit::qi::unused_type,
00144                        boost::spirit::qi::unused_type) const;
00145     };
00146 
00148     struct storeYield : public ParserSemanticAction {
00150       storeYield (YieldRuleStruct&);
00152       void operator() (double,
00153                        boost::spirit::qi::unused_type,
00154                        boost::spirit::qi::unused_type) const; 
00155     };
00156     
00158     struct storeAirlineCode : public ParserSemanticAction {
00160       storeAirlineCode (YieldRuleStruct&);
00162       void operator() (std::vector<char>,
00163                        boost::spirit::qi::unused_type,
00164                        boost::spirit::qi::unused_type) const;
00165     };
00166 
00168     struct storeClass : public ParserSemanticAction {
00170       storeClass (YieldRuleStruct&);
00172       void operator() (std::vector<char>,
00173                        boost::spirit::qi::unused_type,
00174                        boost::spirit::qi::unused_type) const; 
00175     };
00176     
00178     struct doEndYield : public ParserSemanticAction {
00180       doEndYield (stdair::BomRoot&, YieldRuleStruct&);
00182       void operator() (boost::spirit::qi::unused_type,
00183                        boost::spirit::qi::unused_type,
00184                        boost::spirit::qi::unused_type) const;
00186       stdair::BomRoot& _bomRoot;
00187     };
00188   
00190     //
00191     //  (Boost Spirit) Grammar Definition
00192     //
00194 
00214     struct YieldRuleParser : 
00215       public boost::spirit::qi::grammar<stdair::iterator_t, 
00216                                         boost::spirit::ascii::space_type> {
00217 
00218       YieldRuleParser (stdair::BomRoot&, YieldRuleStruct&);
00219 
00220       // Instantiation of rules
00221       boost::spirit::qi::rule<stdair::iterator_t,
00222                               boost::spirit::ascii::space_type>
00223       start, comments, yield_rule, yield_id, origin, destination, tripType,
00224         dateRangeStart, dateRangeEnd, date, timeRangeStart, timeRangeEnd,
00225         time, point_of_sale, cabinCode, channel, yield, segment,
00226         yield_rule_end;
00227       
00228       // Parser Context
00229       stdair::BomRoot& _bomRoot;
00230       YieldRuleStruct& _yieldRule;
00231     };
00232 
00233   }
00234   
00236   //
00237   //  Entry class for the file parser
00238   //
00240 
00246   class YieldFileParser : public stdair::CmdAbstract {
00247   public:
00249     YieldFileParser (stdair::BomRoot&,
00250                      const stdair::Filename_T& iYieldInputFilename);
00251 
00253     void generateYieldStore ();
00254       
00255   private:
00257     void init();
00258       
00259   private:
00260 
00261     // Attributes
00263     stdair::Filename_T _filename;
00264       
00266     stdair::BomRoot& _bomRoot;
00267 
00269     YieldRuleStruct _yieldRule;
00270   };
00271   
00272 }
00273 #endif // __AIRRAC_CMD_YIELDPARSERHELPER_HPP