AirInv Logo  1.00.10
C++ Simulated Airline Inventory Management System Library
Loading...
Searching...
No Matches
DCPParserHelper.cpp
Go to the documentation of this file.
1 // //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <string>
7#include <vector>
8#include <fstream>
9// StdAir
10#include <stdair/basic/BasFileMgr.hpp>
11#include <stdair/bom/BomRoot.hpp>
12#include <stdair/service/Logger.hpp>
13// AirInv
14#include <airinv/command/DCPParserHelper.hpp>
15#include <airinv/command/DCPRuleGenerator.hpp>
16
17namespace AIRINV {
18
19 namespace DCPParserHelper {
20
21 // //////////////////////////////////////////////////////////////////
22 // Semantic actions
23 // //////////////////////////////////////////////////////////////////
24
26 : _DCPRule (ioDCPRule) {
27 }
28
29 // //////////////////////////////////////////////////////////////////
30 storeDCPId::storeDCPId (DCPRuleStruct& ioDCPRule)
31 : ParserSemanticAction (ioDCPRule) {
32 }
33
34 // //////////////////////////////////////////////////////////////////
35 void storeDCPId::operator() (unsigned int iDCPId,
36 boost::spirit::qi::unused_type,
37 boost::spirit::qi::unused_type) const {
38 _DCPRule._DCPId = iDCPId;
39
40 // DEBUG
41 //STDAIR_LOG_DEBUG ( "DCP Id: " << _DCPRule._DCPId);
42
43 _DCPRule._nbOfAirlines = 0;
44 _DCPRule._airlineCode = "";
45 _DCPRule._classCode = "";
46 _DCPRule._airlineCodeList.clear();
47 _DCPRule._classCodeList.clear();
48 _DCPRule._classCodeListOfList.clear();
49 _DCPRule._itSeconds = 0;
50 }
51
52 // //////////////////////////////////////////////////////////////////
53 storeOrigin ::
54 storeOrigin (DCPRuleStruct& ioDCPRule)
55 : ParserSemanticAction (ioDCPRule) {
56 }
57
58 // //////////////////////////////////////////////////////////////////
59 void storeOrigin::operator() (std::vector<char> iChar,
60 boost::spirit::qi::unused_type,
61 boost::spirit::qi::unused_type) const {
62 stdair::AirportCode_T lOrigin (iChar.begin(), iChar.end());
63 // DEBUG
64 //STDAIR_LOG_DEBUG ( "Origin: " << lOrigin);
65 _DCPRule._origin = lOrigin;
66 }
67
68 // //////////////////////////////////////////////////////////////////
69 storeDestination ::
70 storeDestination (DCPRuleStruct& ioDCPRule)
71 : ParserSemanticAction (ioDCPRule) {
72 }
73
74 // //////////////////////////////////////////////////////////////////
75 void storeDestination::operator() (std::vector<char> iChar,
76 boost::spirit::qi::unused_type,
77 boost::spirit::qi::unused_type) const {
78 stdair::AirportCode_T lDestination (iChar.begin(), iChar.end());
79 // DEBUG
80 //STDAIR_LOG_DEBUG ( "Destination: " << lDestination);
81 _DCPRule._destination = lDestination;
82 }
83
84 // //////////////////////////////////////////////////////////////////
86 storeDateRangeStart (DCPRuleStruct& ioDCPRule)
87 : ParserSemanticAction (ioDCPRule) {
88 }
89
90 // //////////////////////////////////////////////////////////////////
91 void storeDateRangeStart::operator() (boost::spirit::qi::unused_type,
92 boost::spirit::qi::unused_type,
93 boost::spirit::qi::unused_type) const {
94 _DCPRule._dateRangeStart = _DCPRule.getDate();
95 // DEBUG
96 //STDAIR_LOG_DEBUG ("Date Range Start: "<< _DCPRule._dateRangeStart);
97 }
98
99 // //////////////////////////////////////////////////////////////////
101 storeDateRangeEnd(DCPRuleStruct& ioDCPRule)
102 : ParserSemanticAction (ioDCPRule) {
103 }
104
105 // //////////////////////////////////////////////////////////////////
106 void storeDateRangeEnd::operator() (boost::spirit::qi::unused_type,
107 boost::spirit::qi::unused_type,
108 boost::spirit::qi::unused_type) const {
109 _DCPRule._dateRangeEnd = _DCPRule.getDate();
110 // DEBUG
111 //STDAIR_LOG_DEBUG ("Date Range End: " << _DCPRule._dateRangeEnd);
112 }
113
114 // //////////////////////////////////////////////////////////////////
116 storeStartRangeTime (DCPRuleStruct& ioDCPRule)
117 : ParserSemanticAction (ioDCPRule) {
118 }
119
120 // //////////////////////////////////////////////////////////////////
121 void storeStartRangeTime::operator() (boost::spirit::qi::unused_type,
122 boost::spirit::qi::unused_type,
123 boost::spirit::qi::unused_type) const {
124 _DCPRule._timeRangeStart = _DCPRule.getTime();
125 // DEBUG
126 //STDAIR_LOG_DEBUG ("Time Range Start: " << _DCPRule._timeRangeStart);
127 // Reset the number of seconds
128 _DCPRule._itSeconds = 0;
129 }
130
131 // //////////////////////////////////////////////////////////////////
133 storeEndRangeTime (DCPRuleStruct& ioDCPRule)
134 : ParserSemanticAction (ioDCPRule) {
135 }
136
137 // //////////////////////////////////////////////////////////////////
138 void storeEndRangeTime::operator() (boost::spirit::qi::unused_type,
139 boost::spirit::qi::unused_type,
140 boost::spirit::qi::unused_type) const {
141 _DCPRule._timeRangeEnd = _DCPRule.getTime();
142 // DEBUG
143 //STDAIR_LOG_DEBUG ("Time Range End: " << _DCPRule._timeRangeEnd);
144 // Reset the number of seconds
145 _DCPRule._itSeconds = 0;
146 }
147
148 // //////////////////////////////////////////////////////////////////
149 storePOS ::
150 storePOS (DCPRuleStruct& ioDCPRule)
151 : ParserSemanticAction (ioDCPRule) {
152 }
153
154 // //////////////////////////////////////////////////////////////////
155 void storePOS::operator() (std::vector<char> iChar,
156 boost::spirit::qi::unused_type,
157 boost::spirit::qi::unused_type) const {
158 stdair::AirlineCode_T lPOS (iChar.begin(), iChar.end());
159 _DCPRule._pos = lPOS;
160 // DEBUG
161 //STDAIR_LOG_DEBUG ("POS: " << _DCPRule._pos);
162 }
163
164 // //////////////////////////////////////////////////////////////////
165 storeCabinCode ::
166 storeCabinCode (DCPRuleStruct& ioDCPRule)
167 : ParserSemanticAction (ioDCPRule) {
168 }
169
170 // //////////////////////////////////////////////////////////////////
172 boost::spirit::qi::unused_type,
173 boost::spirit::qi::unused_type) const {
174 std::ostringstream ostr;
175 ostr << iChar;
176 std::string cabinCodeStr = ostr.str();
177 const stdair::CabinCode_T lCabinCode (cabinCodeStr);
178 _DCPRule._cabinCode = lCabinCode;
179
180 // DEBUG
181 //STDAIR_LOG_DEBUG ("Cabin Code: " << lCabinCode);
182
183 }
184
185 // //////////////////////////////////////////////////////////////////
186 storeChannel ::
187 storeChannel (DCPRuleStruct& ioDCPRule)
188 : ParserSemanticAction (ioDCPRule) {
189 }
190
191 // //////////////////////////////////////////////////////////////////
192 void storeChannel::operator() (std::vector<char> iChar,
193 boost::spirit::qi::unused_type,
194 boost::spirit::qi::unused_type) const {
195 stdair::ChannelLabel_T lChannel (iChar.begin(), iChar.end());
196 if (lChannel != "IN" && lChannel != "IF"
197 && lChannel != "DN" && lChannel != "DF") {
198 // DEBUG
199 STDAIR_LOG_DEBUG ("Invalid channel " << lChannel);
200 }
201 _DCPRule._channel = lChannel;
202 // DEBUG
203 //STDAIR_LOG_DEBUG ("Channel: " << _DCPRule._channel);
204 }
205
206 // //////////////////////////////////////////////////////////////////
207 storeAdvancePurchase ::
208 storeAdvancePurchase (DCPRuleStruct& ioDCPRule)
209 : ParserSemanticAction (ioDCPRule) {
210 }
211
212 // //////////////////////////////////////////////////////////////////
213 void storeAdvancePurchase::operator() (unsigned int iAdancePurchase,
214 boost::spirit::qi::unused_type,
215 boost::spirit::qi::unused_type) const {
216 _DCPRule._advancePurchase = iAdancePurchase;
217 // DEBUG
218 //STDAIR_LOG_DEBUG ( "Advance Purchase: " << _DCPRule._advancePurchase);
219 }
220
221 // //////////////////////////////////////////////////////////////////
222 storeSaturdayStay ::
223 storeSaturdayStay (DCPRuleStruct& ioDCPRule)
224 : ParserSemanticAction (ioDCPRule) {
225 }
226
227 // //////////////////////////////////////////////////////////////////
228 void storeSaturdayStay::operator() (char iSaturdayStay,
229 boost::spirit::qi::unused_type,
230 boost::spirit::qi::unused_type) const {
231 bool lBool = false;
232 if (iSaturdayStay == 'T') {
233 lBool = true;
234 } else {
235 if (iSaturdayStay != 'F') {
236 // DEBUG
237 STDAIR_LOG_DEBUG ("Invalid saturdayStay char " << iSaturdayStay);
238 }
239 }
240 stdair::SaturdayStay_T lSaturdayStay (lBool);
241 _DCPRule._saturdayStay = lSaturdayStay;
242 // DEBUG
243 //STDAIR_LOG_DEBUG ("Saturday Stay: " << _DCPRule._saturdayStay);
244 }
245
246 // //////////////////////////////////////////////////////////////////
247 storeChangeFees ::
248 storeChangeFees (DCPRuleStruct& ioDCPRule)
249 : ParserSemanticAction (ioDCPRule) {
250 }
251
252 // //////////////////////////////////////////////////////////////////
253 void storeChangeFees::operator() (char iChangefees,
254 boost::spirit::qi::unused_type,
255 boost::spirit::qi::unused_type) const {
256
257 bool lBool = false;
258 if (iChangefees == 'T') {
259 lBool = true;
260 } else {
261 if (iChangefees != 'F') {
262 // DEBUG
263 STDAIR_LOG_DEBUG ("Invalid change fees char " << iChangefees);
264 }
265 }
266 stdair::ChangeFees_T lChangefees (lBool);
267 _DCPRule._changeFees = lChangefees;
268 // DEBUG
269 //STDAIR_LOG_DEBUG ("Change fees: " << _DCPRule._changeFees);
270 }
271
272 // //////////////////////////////////////////////////////////////////
273 storeNonRefundable ::
274 storeNonRefundable (DCPRuleStruct& ioDCPRule)
275 : ParserSemanticAction (ioDCPRule) {
276 }
277
278 // //////////////////////////////////////////////////////////////////
279 void storeNonRefundable::operator() (char iNonRefundable,
280 boost::spirit::qi::unused_type,
281 boost::spirit::qi::unused_type) const {
282 bool lBool = false;
283 if (iNonRefundable == 'T') {
284 lBool = true;
285 } else {
286 if (iNonRefundable != 'F') {
287 // DEBUG
288 STDAIR_LOG_DEBUG ("Invalid non refundable char " << iNonRefundable);
289 }
290 }
291 stdair::NonRefundable_T lNonRefundable (lBool);
292 _DCPRule._nonRefundable = lNonRefundable;
293 // DEBUG
294 //STDAIR_LOG_DEBUG ("Non refundable: " << _DCPRule._nonRefundable);
295 }
296
297 // //////////////////////////////////////////////////////////////////
298 storeMinimumStay ::
299 storeMinimumStay (DCPRuleStruct& ioDCPRule)
300 : ParserSemanticAction (ioDCPRule) {
301 }
302
303 // //////////////////////////////////////////////////////////////////
304 void storeMinimumStay::operator() (unsigned int iMinStay,
305 boost::spirit::qi::unused_type,
306 boost::spirit::qi::unused_type) const {
307 _DCPRule._minimumStay = iMinStay;
308 // DEBUG
309 //STDAIR_LOG_DEBUG ("Minimum Stay: " << _DCPRule._minimumStay );
310 }
311
312 // //////////////////////////////////////////////////////////////////
313 storeDCP ::
314 storeDCP (DCPRuleStruct& ioDCPRule)
315 : ParserSemanticAction (ioDCPRule) {
316 }
317
318 // //////////////////////////////////////////////////////////////////
319 void storeDCP::operator() (double iDCP,
320 boost::spirit::qi::unused_type,
321 boost::spirit::qi::unused_type) const {
322 _DCPRule._DCP = iDCP;
323 // DEBUG
324 //STDAIR_LOG_DEBUG ("DCP: " << _DCPRule._DCP);
325 }
326
327 // //////////////////////////////////////////////////////////////////
328 storeAirlineCode ::
329 storeAirlineCode (DCPRuleStruct& ioDCPRule)
330 : ParserSemanticAction (ioDCPRule) {
331 }
332
333 // //////////////////////////////////////////////////////////////////
334 void storeAirlineCode::operator() (std::vector<char> iChar,
335 boost::spirit::qi::unused_type,
336 boost::spirit::qi::unused_type) const {
337
338 bool lAlreadyInTheList = false;
339 stdair::AirlineCode_T lAirlineCode (iChar.begin(), iChar.end());
340 // Update the airline code
341 _DCPRule._airlineCode = lAirlineCode;
342 // Test if the DCPRule Struct stands for interline products
343 if (_DCPRule._airlineCodeList.size() > 0) {
344 _DCPRule._classCodeListOfList.push_back(_DCPRule._classCodeList);
345 _DCPRule._classCodeList.clear();
346 // Update the number of airlines if necessary
347 std::vector<stdair::AirlineCode_T>::iterator Airline_iterator;
348 for (Airline_iterator = _DCPRule._airlineCodeList.begin();
349 Airline_iterator != _DCPRule._airlineCodeList.end();
350 ++Airline_iterator) {
351 stdair::AirlineCode_T lPreviousAirlineCode =
352 *Airline_iterator;
353 if (lPreviousAirlineCode == lAirlineCode) {
354 lAlreadyInTheList = true;
355 /*STDAIR_LOG_DEBUG ("Airline Code Already Existing: "
356 << lAirlineCode);*/
357 }
358 }
359 if (lAlreadyInTheList == false) {
360 /*STDAIR_LOG_DEBUG ("New Airline Code: "
361 << lAirlineCode);*/
362 _DCPRule._airlineCodeList.push_back(lAirlineCode);
363 _DCPRule._classCodeList.clear();
364 }
365 } else {
366 /*STDAIR_LOG_DEBUG ("First Airline Code: "
367 << lAirlineCode);*/
368 _DCPRule._airlineCodeList.push_back (lAirlineCode);
369 }
370 // DEBUG
371 //STDAIR_LOG_DEBUG ( "Airline code: " << lAirlineCode);
372 }
373
374 // //////////////////////////////////////////////////////////////////
375 storeClass ::
376 storeClass (DCPRuleStruct& ioDCPRule)
377 : ParserSemanticAction (ioDCPRule) {
378 }
379
380 // //////////////////////////////////////////////////////////////////
381 void storeClass::operator() (std::vector<char> iChar,
382 boost::spirit::qi::unused_type,
383 boost::spirit::qi::unused_type) const {
384 std::ostringstream ostr;
385 for (std::vector<char>::const_iterator lItVector = iChar.begin();
386 lItVector != iChar.end();
387 lItVector++) {
388 ostr << *lItVector;
389 }
390 std::string classCodeStr = ostr.str();
391 // Insertion of this class Code list in the whole classCode name
392 _DCPRule._classCodeList.push_back(classCodeStr);
393 // DEBUG
394 // STDAIR_LOG_DEBUG ("Class Code: " << classCodeStr);
395 }
396
397 // //////////////////////////////////////////////////////////////////
399 doEndDCP (stdair::BomRoot& ioBomRoot,
400 DCPRuleStruct& ioDCPRule)
401 : ParserSemanticAction (ioDCPRule),
402 _bomRoot (ioBomRoot) {
403 }
404
405 // //////////////////////////////////////////////////////////////////
406 void doEndDCP::operator() (boost::spirit::qi::unused_type,
407 boost::spirit::qi::unused_type,
408 boost::spirit::qi::unused_type) const {
409 // DEBUG
410 // STDAIR_LOG_DEBUG ("Do End");
411 // Generation of the DCP rule object.
412 _DCPRule._classCodeListOfList.push_back(_DCPRule._classCodeList);
413 DCPRuleGenerator::createDCPRule (_bomRoot, _DCPRule);
414 STDAIR_LOG_DEBUG(_DCPRule.describe());
415 }
416
417 // ///////////////////////////////////////////////////////////////////
418 //
419 // Utility Parsers
420 //
421 // ///////////////////////////////////////////////////////////////////
423 namespace bsq = boost::spirit::qi;
424 namespace bsa = boost::spirit::ascii;
425
427 stdair::int1_p_t int1_p;
428
430 stdair::uint2_p_t uint2_p;
431
433 stdair::uint4_p_t uint4_p;
434
436 stdair::uint1_4_p_t uint1_4_p;
437
439 stdair::hour_p_t hour_p;
440 stdair::minute_p_t minute_p;
441 stdair::second_p_t second_p;
442
444 stdair::year_p_t year_p;
445 stdair::month_p_t month_p;
446 stdair::day_p_t day_p;
447
448 // //////////////////////////////////////////////////////////////////
449 // (Boost Spirit) Grammar Definition
450 // //////////////////////////////////////////////////////////////////
451
452 // //////////////////////////////////////////////////////////////////
453 DCPRuleParser::DCPRuleParser (stdair::BomRoot& ioBomRoot,
454 DCPRuleStruct& ioDCPRule) :
455 DCPRuleParser::base_type(start),
456 _bomRoot(ioBomRoot), _DCPRule(ioDCPRule) {
457
458 start = *(comments | DCP_rule);
459
460 comments = (bsq::lexeme[bsq::repeat(2)[bsa::char_('/')]
461 >> +(bsa::char_ - bsq::eol)
462 >> bsq::eol]
463 | bsq::lexeme[bsa::char_('/') >>bsa::char_('*')
464 >> +(bsa::char_ - bsa::char_('*'))
465 >> bsa::char_('*') >> bsa::char_('/')]);
466
468 >> +( ';' >> segment )
470
471 DCP_rule_end = bsa::char_(';');
472
474 >> ';' >> origin >> ';' >> destination
475 >> ';' >> dateRangeStart >> ';' >> dateRangeEnd
476 >> ';' >> timeRangeStart >> ';' >> timeRangeEnd
477 >> ';' >> position >> ';' >> cabinCode >> ';' >> channel
478 >> ';' >> advancePurchase >> ';' >> saturdayStay
479 >> ';' >> changeFees >> ';' >> nonRefundable
480 >> ';' >> minimumStay >> ';' >> DCP;
481
483
484 origin = bsq::repeat(3)[bsa::char_("A-Z")][storeOrigin(_DCPRule)];
485
486 destination =
487 bsq::repeat(3)[bsa::char_("A-Z")][storeDestination(_DCPRule)];
488
490
492
493 date = bsq::lexeme
494 [year_p[boost::phoenix::ref(_DCPRule._itYear) = bsq::labels::_1]
495 >> '-'
496 >> month_p[boost::phoenix::ref(_DCPRule._itMonth) = bsq::labels::_1]
497 >> '-'
498 >> day_p[boost::phoenix::ref(_DCPRule._itDay) = bsq::labels::_1] ];
499
501
503
504 time = bsq::lexeme
505 [hour_p[boost::phoenix::ref(_DCPRule._itHours) = bsq::labels::_1]
506 >> ':'
507 >> minute_p[boost::phoenix::ref(_DCPRule._itMinutes) = bsq::labels::_1]
508 >> - (':' >> second_p[boost::phoenix::ref(_DCPRule._itSeconds) = bsq::labels::_1]) ];
509
510 position = bsq::repeat(3)[bsa::char_("A-Z")][storePOS(_DCPRule)];
511
512 cabinCode = bsa::char_("A-Z")[storeCabinCode(_DCPRule)];
513
514 channel = bsq::repeat(2)[bsa::char_("A-Z")][storeChannel(_DCPRule)];
515
517
518 saturdayStay = bsa::char_("A-Z")[storeSaturdayStay(_DCPRule)];
519
520 changeFees = bsa::char_("A-Z")[storeChangeFees(_DCPRule)];
521
522 nonRefundable = bsa::char_("A-Z")[storeNonRefundable(_DCPRule)];
523
525
526 DCP = bsq::double_[storeDCP(_DCPRule)];
527
528 segment = bsq::repeat(2)[bsa::char_("A-Z")][storeAirlineCode(_DCPRule)]
529 //>> ';'
530 //>> bsa::char_("A-Z")[storeClass(_DCPRule)]
531 >> +(';' >> list_class);
532
533 list_class = bsq::repeat(1,bsq::inf)[bsa::char_("A-Z")][storeClass(_DCPRule)];
534
535 //BOOST_SPIRIT_DEBUG_NODE (DCPRuleParser);
536 BOOST_SPIRIT_DEBUG_NODE (start);
537 BOOST_SPIRIT_DEBUG_NODE (comments);
538 BOOST_SPIRIT_DEBUG_NODE (DCP_rule);
539 BOOST_SPIRIT_DEBUG_NODE (DCP_rule_end);
540 BOOST_SPIRIT_DEBUG_NODE (DCP_key);
541 BOOST_SPIRIT_DEBUG_NODE (DCP_id);
542 BOOST_SPIRIT_DEBUG_NODE (origin);
543 BOOST_SPIRIT_DEBUG_NODE (destination);
544 BOOST_SPIRIT_DEBUG_NODE (dateRangeStart);
545 BOOST_SPIRIT_DEBUG_NODE (dateRangeEnd);
546 BOOST_SPIRIT_DEBUG_NODE (date);
547 BOOST_SPIRIT_DEBUG_NODE (timeRangeStart);
548 BOOST_SPIRIT_DEBUG_NODE (timeRangeEnd);
549 BOOST_SPIRIT_DEBUG_NODE (time);
550 BOOST_SPIRIT_DEBUG_NODE (position);
551 BOOST_SPIRIT_DEBUG_NODE (cabinCode);
552 BOOST_SPIRIT_DEBUG_NODE (channel);
553 BOOST_SPIRIT_DEBUG_NODE (advancePurchase);
554 BOOST_SPIRIT_DEBUG_NODE (saturdayStay);
555 BOOST_SPIRIT_DEBUG_NODE (changeFees);
556 BOOST_SPIRIT_DEBUG_NODE (nonRefundable);
557 BOOST_SPIRIT_DEBUG_NODE (minimumStay);
558 BOOST_SPIRIT_DEBUG_NODE (DCP);
559 BOOST_SPIRIT_DEBUG_NODE (segment);
560 BOOST_SPIRIT_DEBUG_NODE (list_class);
561 }
562 }
563
565 //
566 // Entry class for the file parser
567 //
569
570 // //////////////////////////////////////////////////////////////////////
572 DCPRuleFileParser (stdair::BomRoot& ioBomRoot,
573 const stdair::Filename_T& iFilename)
574 : _filename (iFilename), _bomRoot (ioBomRoot) {
575 init();
576 }
577
578 // //////////////////////////////////////////////////////////////////////
579 void DCPRuleFileParser::init() {
580 // Check that the file exists and is readable
581 const bool doesExistAndIsReadable =
582 stdair::BasFileMgr::doesExistAndIsReadable (_filename);
583
584 if (doesExistAndIsReadable == false) {
585 STDAIR_LOG_ERROR ("The DCP schedule file " << _filename
586 << " does not exist or can not be read.");
587
588 throw DCPInputFileNotFoundException ("The DCP file " + _filename + " does not exist or can not be read");
589 }
590 }
591
592 // //////////////////////////////////////////////////////////////////////
594
595 STDAIR_LOG_DEBUG ("Parsing DCP input file: " << _filename);
596
597 // File to be parsed
598 const std::string* lFileName = &_filename;
599 const char *lChar = (*lFileName).c_str();
600 std::ifstream fileToBeParsed(lChar, std::ios_base::in);
601
602 // Check the filename exists and can be open
603 if (fileToBeParsed == false) {
604 STDAIR_LOG_ERROR ("The DCP file " << _filename << " can not be open."
605 << std::endl);
606
607 throw DCPInputFileNotFoundException ("The file " + _filename + " does not exist or can not be read");
608 }
609
610 // Create an input iterator
611 stdair::base_iterator_t inputBegin (fileToBeParsed);
612
613 // Convert input iterator to an iterator usable by spirit parser
614 stdair::iterator_t
615 start (boost::spirit::make_default_multi_pass (inputBegin));
616 stdair::iterator_t end;
617
618 // Initialise the parser (grammar) with the helper/staging structure.
619 DCPParserHelper::DCPRuleParser lFPParser(_bomRoot, _DCPRule);
620
621 // Launch the parsing of the file and, thanks to the doEndDCP
622 // call-back structure, the building of the whole BomRoot BOM
623
624 const bool hasParsingBeenSuccesful =
625 boost::spirit::qi::phrase_parse (start, end, lFPParser,
626 boost::spirit::ascii::space);
627
628 if (hasParsingBeenSuccesful == false) {
629 // TODO: decide whether to throw an exceqption
630 STDAIR_LOG_ERROR ("Parsing of DCP input file: " << _filename
631 << " failed");
632 }
633 if (start != end) {
634 // TODO: decide whether to throw an exception
635 STDAIR_LOG_ERROR ("Parsing of DCP input file: " << _filename
636 << " failed");
637 }
638 if (hasParsingBeenSuccesful == true && start == end) {
639 STDAIR_LOG_DEBUG ("Parsing of DCP input file: " << _filename
640 << " succeeded");
641 }
642 return hasParsingBeenSuccesful;
643 }
644
645}
DCPRuleFileParser(stdair::BomRoot &ioBomRoot, const stdair::Filename_T &iFilename)
stdair::minute_p_t minute_p
stdair::second_p_t second_p
stdair::uint1_4_p_t uint1_4_p
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_id
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > timeRangeStart
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > list_class
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > changeFees
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_rule_end
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > start
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > advancePurchase
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > time
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_key
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > dateRangeStart
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > channel
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > dateRangeEnd
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > comments
DCPRuleParser(stdair::BomRoot &, DCPRuleStruct &)
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > cabinCode
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > segment
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > position
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > minimumStay
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > saturdayStay
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > timeRangeEnd
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > nonRefundable
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > DCP_rule
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > destination
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > origin
boost::spirit::qi::rule< stdair::iterator_t, boost::spirit::ascii::space_type > date
doEndDCP(stdair::BomRoot &, DCPRuleStruct &)
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(double, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(unsigned int, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(std::vector< char >, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(char, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const
void operator()(boost::spirit::qi::unused_type, boost::spirit::qi::unused_type, boost::spirit::qi::unused_type) const