AirInv Logo  1.00.3
C++ Simulated Airline Inventory Management System library
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
AIRINV::DCPParserHelper::DCPRuleParser::_DCPRule
DCPRuleStruct & _DCPRule
Definition: DCPParserHelper.hpp:321
AIRINV::DCPParserHelper::DCPRuleParser::advancePurchase
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > advancePurchase
Definition: DCPParserHelper.hpp:315
AIRINV::DCPParserHelper::storeChangeFees::storeChangeFees
storeChangeFees(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:248
AIRINV::DCPParserHelper::storeAdvancePurchase::operator()
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:213
AIRINV::DCPParserHelper::storeStartRangeTime::operator()
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:121
AIRINV::DCPParserHelper::DCPRuleParser::DCP_key
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_key
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::storePOS
Definition: DCPParserHelper.hpp:108
AIRINV::DCPParserHelper::DCPRuleParser::segment
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > segment
Definition: DCPParserHelper.hpp:317
AIRINV::DCPParserHelper::storeDCP::storeDCP
storeDCP(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:314
AIRINV::DCPParserHelper::storeNonRefundable
Definition: DCPParserHelper.hpp:168
AIRINV::DCPParserHelper::storeCabinCode::storeCabinCode
storeCabinCode(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:166
AIRINV::DCPRuleFileParser::generateDCPRules
bool generateDCPRules()
Definition: DCPParserHelper.cpp:593
AIRINV::DCPParserHelper::storeCabinCode
Definition: DCPParserHelper.hpp:118
AIRINV::DCPParserHelper::DCPRuleParser::DCP
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP
Definition: DCPParserHelper.hpp:316
AIRINV::DCPParserHelper::storeChangeFees::operator()
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:253
AIRINV::DCPParserHelper::DCPRuleParser::time
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > time
Definition: DCPParserHelper.hpp:315
AIRINV::DCPParserHelper::storeAdvancePurchase::storeAdvancePurchase
storeAdvancePurchase(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:208
AIRINV::DCPParserHelper::storeDestination::storeDestination
storeDestination(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:70
AIRINV::DCPParserHelper::doEndDCP::_bomRoot
stdair::BomRoot & _bomRoot
Definition: DCPParserHelper.hpp:226
AIRINV::DCPParserHelper::doEndDCP::operator()
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:406
AIRINV::DCPParserHelper::storeDCPId::storeDCPId
storeDCPId(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:30
AIRINV::DCPParserHelper::DCPRuleParser::timeRangeStart
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > timeRangeStart
Definition: DCPParserHelper.hpp:314
AIRINV::DCPParserHelper::storeAirlineCode::storeAirlineCode
storeAirlineCode(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:329
AIRINV::DCPParserHelper::storeChannel
Definition: DCPParserHelper.hpp:128
AIRINV::iterator_t
boost::spirit::classic::file_iterator< char_t > iterator_t
Definition: BasParserTypes.hpp:35
AIRINV::DCPParserHelper::storeClass::storeClass
storeClass(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:376
AIRINV::DCPParserHelper::storeClass
Definition: DCPParserHelper.hpp:208
AIRINV::DCPParserHelper::storeStartRangeTime
Definition: DCPParserHelper.hpp:88
AIRINV::DCPParserHelper::DCPRuleParser::DCPRuleParser
DCPRuleParser(stdair::BomRoot &, DCPRuleStruct &)
Definition: DCPParserHelper.cpp:453
AIRINV::DCPParserHelper::ParserSemanticAction
Definition: DCPParserHelper.hpp:30
AIRINV::DCPParserHelper::storeSaturdayStay::storeSaturdayStay
storeSaturdayStay(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:223
AIRINV::DCPParserHelper::DCPRuleParser::minimumStay
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > minimumStay
Definition: DCPParserHelper.hpp:316
AIRINV::DCPParserHelper::storePOS::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:155
AIRINV::DCPParserHelper::storeSaturdayStay::operator()
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:228
AIRINV::DCPParserHelper::storeMinimumStay::operator()
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:304
AIRINV::DCPParserHelper::DCPRuleParser::dateRangeEnd
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > dateRangeEnd
Definition: DCPParserHelper.hpp:314
AIRINV::DCPParserHelper::DCPRuleParser::changeFees
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > changeFees
Definition: DCPParserHelper.hpp:316
AIRINV::DCPParserHelper::storeEndRangeTime
Definition: DCPParserHelper.hpp:98
AIRINV::DCPParserHelper::doEndDCP
Definition: DCPParserHelper.hpp:218
stdair
Forward declarations.
Definition: AIRINV_Master_Service.hpp:25
AIRINV::DCPParserHelper::DCPRuleParser::cabinCode
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > cabinCode
Definition: DCPParserHelper.hpp:315
AIRINV::DCPParserHelper::doEndDCP::doEndDCP
doEndDCP(stdair::BomRoot &, DCPRuleStruct &)
Definition: DCPParserHelper.cpp:399
AIRINV::DCPParserHelper::storeCabinCode::operator()
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:171
AIRINV::DCPParserHelper::storeSaturdayStay
Definition: DCPParserHelper.hpp:148
AIRINV::DCPParserHelper::storeOrigin::storeOrigin
storeOrigin(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:54
AIRINV::DCPParserHelper::DCPRuleParser::saturdayStay
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > saturdayStay
Definition: DCPParserHelper.hpp:316
AIRINV::DCPParserHelper::storeEndRangeTime::storeEndRangeTime
storeEndRangeTime(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:133
AIRINV::DCPParserHelper::storeMinimumStay
Definition: DCPParserHelper.hpp:178
AIRINV::DCPParserHelper::storeOrigin
Definition: DCPParserHelper.hpp:48
AIRINV::DCPParserHelper::storeDestination::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:75
AIRINV::DCPParserHelper::storeChannel::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:192
AIRINV::DCPParserHelper::ParserSemanticAction::_DCPRule
DCPRuleStruct & _DCPRule
Definition: DCPParserHelper.hpp:34
AIRINV::DCPParserHelper::storePOS::storePOS
storePOS(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:150
AIRINV::DCPParserHelper::DCPRuleParser::comments
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > comments
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::storeAirlineCode::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:334
AIRINV_Types.hpp
AIRINV::DCPParserHelper::DCPRuleParser::list_class
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > list_class
Definition: DCPParserHelper.hpp:317
AIRINV::DCPParserHelper::storeClass::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:381
AIRINV::DCPParserHelper::DCPRuleParser::destination
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > destination
Definition: DCPParserHelper.hpp:314
AIRINV::DCPParserHelper::storeDateRangeStart
Definition: DCPParserHelper.hpp:68
AIRINV::DCPRuleFileParser::DCPRuleFileParser
DCPRuleFileParser(stdair::BomRoot &ioBomRoot, const stdair::Filename_T &iFilename)
Definition: DCPParserHelper.cpp:572
AIRINV::DCPParserHelper::storeDCP::operator()
void operator()(double, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:319
AIRINV::DCPParserHelper::storeDateRangeStart::storeDateRangeStart
storeDateRangeStart(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:86
AIRINV::DCPParserHelper::DCPRuleParser::DCP_rule
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_rule
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::storeOrigin::operator()
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:59
AIRINV::DCPParserHelper::storeAdvancePurchase
Definition: DCPParserHelper.hpp:138
AIRINV::DCPParserHelper::DCPRuleParser::DCP_id
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_id
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::storeDateRangeStart::operator()
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:91
AIRINV::DCPParserHelper::storeDateRangeEnd::storeDateRangeEnd
storeDateRangeEnd(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:101
AIRINV
Definition: AIRINV_Master_Service.hpp:38
AIRINV::DCPParserHelper::DCPRuleParser::position
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > position
Definition: DCPParserHelper.hpp:315
AIRINV::DCPParserHelper::DCPRuleParser::timeRangeEnd
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > timeRangeEnd
Definition: DCPParserHelper.hpp:315
AIRINV::DCPParserHelper::DCPRuleParser
Definition: DCPParserHelper.hpp:304
AIRINV::DCPParserHelper::storeNonRefundable::operator()
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:279
AIRINV::DCPParserHelper::storeDCPId
Definition: DCPParserHelper.hpp:38
AIRINV::DCPParserHelper::DCPRuleParser::nonRefundable
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > nonRefundable
Definition: DCPParserHelper.hpp:316
AIRINV::DCPParserHelper::DCPRuleParser::date
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > date
Definition: DCPParserHelper.hpp:314
AIRINV::DCPParserHelper::DCPRuleParser::dateRangeStart
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > dateRangeStart
Definition: DCPParserHelper.hpp:314
AIRINV::DCPParserHelper::storeDateRangeEnd
Definition: DCPParserHelper.hpp:78
AIRINV::DCPParserHelper::storeDCPId::operator()
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:35
AIRINV::DCPParserHelper::storeAirlineCode
Definition: DCPParserHelper.hpp:198
AIRINV::DCPParserHelper::DCPRuleParser::_bomRoot
stdair::BomRoot & _bomRoot
Definition: DCPParserHelper.hpp:320
AIRINV::DCPParserHelper::storeDestination
Definition: DCPParserHelper.hpp:58
AIRINV::DCPParserHelper::storeEndRangeTime::operator()
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:138
AIRINV::DCPParserHelper::storeNonRefundable::storeNonRefundable
storeNonRefundable(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:274
AIRINV::DCPRuleFileParser
Definition: DCPParserHelper.hpp:337
AIRINV::DCPParserHelper::ParserSemanticAction::ParserSemanticAction
ParserSemanticAction(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:25
AIRINV::DCPParserHelper::storeChangeFees
Definition: DCPParserHelper.hpp:158
AIRINV::DCPParserHelper::storeChannel::storeChannel
storeChannel(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:187
AIRINV::DCPParserHelper::storeDCP
Definition: DCPParserHelper.hpp:188
AIRINV::DCPParserHelper::storeMinimumStay::storeMinimumStay
storeMinimumStay(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:299
AIRINV::DCPParserHelper::storeStartRangeTime::storeStartRangeTime
storeStartRangeTime(DCPRuleStruct &)
Definition: DCPParserHelper.cpp:116
AIRINV::DCPParserHelper::DCPRuleParser::DCP_rule_end
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_rule_end
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::DCPRuleParser::start
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > start
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::storeDateRangeEnd::operator()
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
Definition: DCPParserHelper.cpp:106
AIRINV::DCPParserHelper::DCPRuleParser::origin
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > origin
Definition: DCPParserHelper.hpp:313
AIRINV::DCPParserHelper::DCPRuleParser::channel
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > channel
Definition: DCPParserHelper.hpp:315