$treeview $search $mathjax
00001 #ifndef __AIRINV_CMD_DCPPARSERHELPER_HPP 00002 #define __AIRINV_CMD_DCPPARSERHELPER_HPP 00003 00004 // ////////////////////////////////////////////////////////////////////// 00005 // Import section 00006 // ////////////////////////////////////////////////////////////////////// 00007 // StdAir 00008 // The stdair/basic/BasParserTypes.hpp header includes Boost.Spirit headers 00009 //#define BOOST_SPIRIT_DEBUG 00010 #include <stdair/basic/BasParserTypes.hpp> 00011 #include <stdair/command/CmdAbstract.hpp> 00012 // AirInv 00013 #include <airinv/AIRINV_Types.hpp> 00014 #include <airinv/bom/DCPRuleStruct.hpp> 00015 00016 // Forward declarations 00017 namespace stdair { 00018 class BomRoot; 00019 } 00020 00021 namespace AIRINV { 00022 00023 namespace DCPParserHelper { 00024 00025 // /////////////////////////////////////////////////////////////////// 00026 // Semantic actions 00027 // //////////////////////////////////////////////////// 00029 00030 struct ParserSemanticAction { 00032 ParserSemanticAction (DCPRuleStruct&); 00034 DCPRuleStruct& _DCPRule; 00035 }; 00036 00038 struct storeDCPId : public ParserSemanticAction { 00040 storeDCPId (DCPRuleStruct&); 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 (DCPRuleStruct&); 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 (DCPRuleStruct&); 00062 void operator() (std::vector<char>, 00063 boost::spirit::qi::unused_type, 00064 boost::spirit::qi::unused_type) const; 00065 }; 00066 00068 struct storeDateRangeStart : public ParserSemanticAction { 00070 storeDateRangeStart (DCPRuleStruct&); 00072 void operator() (boost::spirit::qi::unused_type, 00073 boost::spirit::qi::unused_type, 00074 boost::spirit::qi::unused_type) const; 00075 }; 00076 00078 struct storeDateRangeEnd : public ParserSemanticAction { 00080 storeDateRangeEnd (DCPRuleStruct&); 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 storeStartRangeTime : public ParserSemanticAction { 00090 storeStartRangeTime (DCPRuleStruct&); 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 storeEndRangeTime : public ParserSemanticAction { 00100 storeEndRangeTime (DCPRuleStruct&); 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 storePOS : public ParserSemanticAction { 00110 storePOS (DCPRuleStruct&); 00112 void operator() (std::vector<char>, 00113 boost::spirit::qi::unused_type, 00114 boost::spirit::qi::unused_type) const; 00115 }; 00116 00118 struct storeCabinCode : public ParserSemanticAction { 00120 storeCabinCode (DCPRuleStruct&); 00122 void operator() (char, 00123 boost::spirit::qi::unused_type, 00124 boost::spirit::qi::unused_type) const; 00125 }; 00126 00128 struct storeChannel : public ParserSemanticAction { 00130 storeChannel (DCPRuleStruct&); 00132 void operator() (std::vector<char>, 00133 boost::spirit::qi::unused_type, 00134 boost::spirit::qi::unused_type) const; 00135 }; 00136 00138 struct storeAdvancePurchase : public ParserSemanticAction { 00140 storeAdvancePurchase (DCPRuleStruct&); 00142 void operator() (unsigned int, 00143 boost::spirit::qi::unused_type, 00144 boost::spirit::qi::unused_type) const; 00145 }; 00146 00148 struct storeSaturdayStay : public ParserSemanticAction { 00150 storeSaturdayStay (DCPRuleStruct&); 00152 void operator() (char, 00153 boost::spirit::qi::unused_type, 00154 boost::spirit::qi::unused_type) const; 00155 }; 00156 00158 struct storeChangeFees : public ParserSemanticAction { 00160 storeChangeFees (DCPRuleStruct&); 00162 void operator() (char, 00163 boost::spirit::qi::unused_type, 00164 boost::spirit::qi::unused_type) const; 00165 }; 00166 00168 struct storeNonRefundable : public ParserSemanticAction { 00170 storeNonRefundable (DCPRuleStruct&); 00172 void operator() (char, 00173 boost::spirit::qi::unused_type, 00174 boost::spirit::qi::unused_type) const; 00175 }; 00176 00178 struct storeMinimumStay : public ParserSemanticAction { 00180 storeMinimumStay (DCPRuleStruct&); 00182 void operator() (unsigned int, 00183 boost::spirit::qi::unused_type, 00184 boost::spirit::qi::unused_type) const; 00185 }; 00186 00188 struct storeDCP : public ParserSemanticAction { 00190 storeDCP (DCPRuleStruct&); 00192 void operator() (double, 00193 boost::spirit::qi::unused_type, 00194 boost::spirit::qi::unused_type) const; 00195 }; 00196 00198 struct storeAirlineCode : public ParserSemanticAction { 00200 storeAirlineCode (DCPRuleStruct&); 00202 void operator() (std::vector<char>, 00203 boost::spirit::qi::unused_type, 00204 boost::spirit::qi::unused_type) const; 00205 }; 00206 00208 struct storeClass : public ParserSemanticAction { 00210 storeClass (DCPRuleStruct&); 00212 void operator() (std::vector<char>, 00213 boost::spirit::qi::unused_type, 00214 boost::spirit::qi::unused_type) const; 00215 }; 00216 00218 struct doEndDCP : public ParserSemanticAction { 00220 doEndDCP (stdair::BomRoot&, DCPRuleStruct&); 00222 void operator() (boost::spirit::qi::unused_type, 00223 boost::spirit::qi::unused_type, 00224 boost::spirit::qi::unused_type) const; 00226 stdair::BomRoot& _bomRoot; 00227 }; 00228 00229 00231 // 00232 // (Boost Spirit) Grammar Definition 00233 // 00235 00304 struct DCPRuleParser : 00305 public boost::spirit::qi::grammar<stdair::iterator_t, 00306 boost::spirit::ascii::space_type> { 00307 00308 DCPRuleParser (stdair::BomRoot&, DCPRuleStruct&); 00309 00310 // Instantiation of rules 00311 boost::spirit::qi::rule<stdair::iterator_t, 00312 boost::spirit::ascii::space_type> 00313 start, comments, DCP_rule, DCP_rule_end, DCP_key, DCP_id, origin, 00314 destination, dateRangeStart, dateRangeEnd, date, timeRangeStart, 00315 timeRangeEnd, time, position, cabinCode, channel, advancePurchase, 00316 saturdayStay, changeFees, nonRefundable, minimumStay, DCP, 00317 segment, list_class; 00318 00319 // Parser Context 00320 stdair::BomRoot& _bomRoot; 00321 DCPRuleStruct& _DCPRule; 00322 }; 00323 00324 } 00325 00327 // 00328 // Entry class for the file parser 00329 // 00331 00337 class DCPRuleFileParser : public stdair::CmdAbstract { 00338 public: 00340 DCPRuleFileParser (stdair::BomRoot& ioBomRoot, 00341 const stdair::Filename_T& iFilename); 00342 00344 bool generateDCPRules (); 00345 00346 private: 00348 void init(); 00349 00350 private: 00351 // Attributes 00353 stdair::Filename_T _filename; 00354 00356 stdair::BomRoot& _bomRoot; 00357 00359 DCPRuleStruct _DCPRule; 00360 }; 00361 00362 } 00363 #endif // __AIRINV_CMD_DCPPARSERHELPER_HPP