AirInv Logo  1.00.0
C++ Simulated Airline Inventory Management System library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DCPParserHelper.hpp
Go to the documentation of this file.
1 #ifndef __AIRINV_CMD_DCPPARSERHELPER_HPP
2 #define __AIRINV_CMD_DCPPARSERHELPER_HPP
3 
4 // //////////////////////////////////////////////////////////////////////
5 // Import section
6 // //////////////////////////////////////////////////////////////////////
7 // StdAir
8 // The stdair/basic/BasParserTypes.hpp header includes Boost.Spirit headers
9 //#define BOOST_SPIRIT_DEBUG
10 #include <stdair/basic/BasParserTypes.hpp>
11 #include <stdair/command/CmdAbstract.hpp>
12 // AirInv
13 #include <airinv/AIRINV_Types.hpp>
14 #include <airinv/bom/DCPRuleStruct.hpp>
15 
16 // Forward declarations
17 namespace stdair {
18  class BomRoot;
19 }
20 
21 namespace AIRINV {
22 
23  namespace DCPParserHelper {
24 
25  // ///////////////////////////////////////////////////////////////////
26  // Semantic actions
27  // ////////////////////////////////////////////////////
29 
32  ParserSemanticAction (DCPRuleStruct&);
34  DCPRuleStruct& _DCPRule;
35  };
36 
38  struct storeDCPId : public ParserSemanticAction {
40  storeDCPId (DCPRuleStruct&);
42  void operator() (unsigned int,
43  boost::spirit::qi::unused_type,
44  boost::spirit::qi::unused_type) const;
45  };
46 
50  storeOrigin (DCPRuleStruct&);
52  void operator() (std::vector<char>,
53  boost::spirit::qi::unused_type,
54  boost::spirit::qi::unused_type) const;
55  };
56 
60  storeDestination (DCPRuleStruct&);
62  void operator() (std::vector<char>,
63  boost::spirit::qi::unused_type,
64  boost::spirit::qi::unused_type) const;
65  };
66 
70  storeDateRangeStart (DCPRuleStruct&);
72  void operator() (boost::spirit::qi::unused_type,
73  boost::spirit::qi::unused_type,
74  boost::spirit::qi::unused_type) const;
75  };
76 
80  storeDateRangeEnd (DCPRuleStruct&);
82  void operator() (boost::spirit::qi::unused_type,
83  boost::spirit::qi::unused_type,
84  boost::spirit::qi::unused_type) const;
85  };
86 
90  storeStartRangeTime (DCPRuleStruct&);
92  void operator() (boost::spirit::qi::unused_type,
93  boost::spirit::qi::unused_type,
94  boost::spirit::qi::unused_type) const;
95  };
96 
100  storeEndRangeTime (DCPRuleStruct&);
102  void operator() (boost::spirit::qi::unused_type,
103  boost::spirit::qi::unused_type,
104  boost::spirit::qi::unused_type) const;
105  };
106 
108  struct storePOS : public ParserSemanticAction {
110  storePOS (DCPRuleStruct&);
112  void operator() (std::vector<char>,
113  boost::spirit::qi::unused_type,
114  boost::spirit::qi::unused_type) const;
115  };
116 
120  storeCabinCode (DCPRuleStruct&);
122  void operator() (char,
123  boost::spirit::qi::unused_type,
124  boost::spirit::qi::unused_type) const;
125  };
126 
130  storeChannel (DCPRuleStruct&);
132  void operator() (std::vector<char>,
133  boost::spirit::qi::unused_type,
134  boost::spirit::qi::unused_type) const;
135  };
136 
140  storeAdvancePurchase (DCPRuleStruct&);
142  void operator() (unsigned int,
143  boost::spirit::qi::unused_type,
144  boost::spirit::qi::unused_type) const;
145  };
146 
150  storeSaturdayStay (DCPRuleStruct&);
152  void operator() (char,
153  boost::spirit::qi::unused_type,
154  boost::spirit::qi::unused_type) const;
155  };
156 
160  storeChangeFees (DCPRuleStruct&);
162  void operator() (char,
163  boost::spirit::qi::unused_type,
164  boost::spirit::qi::unused_type) const;
165  };
166 
170  storeNonRefundable (DCPRuleStruct&);
172  void operator() (char,
173  boost::spirit::qi::unused_type,
174  boost::spirit::qi::unused_type) const;
175  };
176 
180  storeMinimumStay (DCPRuleStruct&);
182  void operator() (unsigned int,
183  boost::spirit::qi::unused_type,
184  boost::spirit::qi::unused_type) const;
185  };
186 
188  struct storeDCP : public ParserSemanticAction {
190  storeDCP (DCPRuleStruct&);
192  void operator() (double,
193  boost::spirit::qi::unused_type,
194  boost::spirit::qi::unused_type) const;
195  };
196 
200  storeAirlineCode (DCPRuleStruct&);
202  void operator() (std::vector<char>,
203  boost::spirit::qi::unused_type,
204  boost::spirit::qi::unused_type) const;
205  };
206 
210  storeClass (DCPRuleStruct&);
212  void operator() (std::vector<char>,
213  boost::spirit::qi::unused_type,
214  boost::spirit::qi::unused_type) const;
215  };
216 
218  struct doEndDCP : public ParserSemanticAction {
220  doEndDCP (stdair::BomRoot&, DCPRuleStruct&);
222  void operator() (boost::spirit::qi::unused_type,
223  boost::spirit::qi::unused_type,
224  boost::spirit::qi::unused_type) const;
226  stdair::BomRoot& _bomRoot;
227  };
228 
229 
231  //
232  // (Boost Spirit) Grammar Definition
233  //
235 
304  struct DCPRuleParser :
305  public boost::spirit::qi::grammar<stdair::iterator_t,
306  boost::spirit::ascii::space_type> {
307 
308  DCPRuleParser (stdair::BomRoot&, DCPRuleStruct&);
309 
310  // Instantiation of rules
311  boost::spirit::qi::rule<stdair::iterator_t,
312  boost::spirit::ascii::space_type>
318 
319  // Parser Context
320  stdair::BomRoot& _bomRoot;
321  DCPRuleStruct& _DCPRule;
322  };
323 
324  }
325 
327  //
328  // Entry class for the file parser
329  //
331 
337  class DCPRuleFileParser : public stdair::CmdAbstract {
338  public:
340  DCPRuleFileParser (stdair::BomRoot& ioBomRoot,
341  const stdair::Filename_T& iFilename);
342 
344  bool generateDCPRules ();
345 
346  private:
348  void init();
349 
350  private:
351  // Attributes
353  stdair::Filename_T _filename;
354 
356  stdair::BomRoot& _bomRoot;
357 
359  DCPRuleStruct _DCPRule;
360  };
361 
362 }
363 #endif // __AIRINV_CMD_DCPPARSERHELPER_HPP