7#include <stdair/basic/BasFileMgr.hpp>
8#include <stdair/bom/BomRoot.hpp>
9#include <stdair/service/Logger.hpp>
37 std::string lOrigin (iStr, iStrEnd);
57 std::string lDestination (iStr, iStrEnd);
93 const stdair::DateOffset_T oneDay (1);
100 stdair::DatePeriod_T (
_onDPeriod._dateRangeStart,
146 const std::string lAirlineCodeStr (iStr, iStrEnd);
147 const stdair::AirlineCode_T lAirlineCode(lAirlineCodeStr);
151 std::ostringstream ostr;
152 ostr <<
_onDPeriod._airlineCode << lAirlineCode;
155 const stdair::AirlineCode_T lPreviousAirlineCode =
157 if (lPreviousAirlineCode != lAirlineCode) {
165 _onDPeriod._airlineCodeList.push_back (lAirlineCode);
178 std::ostringstream ostr;
180 std::string classCodeStr = ostr.str();
181 const stdair::ClassCode_T lClassCode (classCodeStr);
182 _onDPeriod._classCodeList.push_back(lClassCode);
186 std::ostringstream ostrr;
187 ostrr <<
_onDPeriod._classCode << classCodeStr;
266 template<
typename ScannerT>
269 ond_list = *( boost::spirit::classic::comment_p(
"//")
270 | boost::spirit::classic::comment_p(
"/*",
"*/")
279 ond_end = boost::spirit::classic::ch_p(
';')
290 date = boost::spirit::classic::
291 lexeme_d[(
year_p)[boost::spirit::classic::
294 >> (
month_p)[boost::spirit::classic::
297 >> (
day_p)[boost::spirit::classic::
301 time = boost::spirit::classic::
302 lexeme_d[(
hours_p)[boost::spirit::classic::
307 >> !(
':' >> (
seconds_p)[boost::spirit::classic::
311 segment = boost::spirit::classic::
318 BOOST_SPIRIT_DEBUG_NODE (
ond);
319 BOOST_SPIRIT_DEBUG_NODE (
segment);
320 BOOST_SPIRIT_DEBUG_NODE (
ond_key);
321 BOOST_SPIRIT_DEBUG_NODE (
ond_end);
322 BOOST_SPIRIT_DEBUG_NODE (
date);
323 BOOST_SPIRIT_DEBUG_NODE (
time);
328 template<
typename ScannerT>
329 boost::spirit::classic::rule<ScannerT>
const&
343 stdair::BomRoot& ioBomRoot)
344 : _filename (iFilename), _bomRoot (ioBomRoot) {
349 void OnDPeriodFileParser::init() {
351 const bool doesExistAndIsReadable =
352 stdair::BasFileMgr::doesExistAndIsReadable (_filename);
354 if (doesExistAndIsReadable ==
false) {
355 STDAIR_LOG_ERROR (
"The O&D file " << _filename
356 <<
" does not exist or can not be read.");
359 +
" does not exist or can not be read");
366 if (!_startIterator) {
367 STDAIR_LOG_DEBUG (
"The O&D file " << _filename <<
" can not be open."
369 throw OnDInputFileNotFoundException (
"The file " + _filename
370 +
" does not exist or can not be read");
374 _endIterator = _startIterator.make_end();
379 bool oResult =
false;
381 STDAIR_LOG_DEBUG (
"Parsing O&D input file: " << _filename);
388 boost::spirit::classic::parse_info<iterator_t> info =
389 boost::spirit::classic::parse (_startIterator, _endIterator, lODParser,
390 boost::spirit::classic::space_p);
395 const std::string hasBeenFullyReadStr = (info.full ==
true)?
"":
"not ";
396 if (oResult ==
true) {
397 STDAIR_LOG_DEBUG (
"Parsing of O&D input file: " << _filename
398 <<
" succeeded: read " << info.length
399 <<
" characters. The input file has "
400 << hasBeenFullyReadStr
401 <<
"been fully read. Stop point: " << info.stop);
405 STDAIR_LOG_ERROR (
"Parsing of O&D input file: " << _filename
406 <<
" failed: read " << info.length
407 <<
" characters. The input file has "
408 << hasBeenFullyReadStr
409 <<
"been fully read. Stop point: " << info.stop);
OnDPeriodFileParser(const stdair::Filename_T &iFilename, stdair::BomRoot &ioBomRoot)
bool generateOnDPeriods()
bounded2_p_t seconds_p(uint2_p.derived(), 0u, 59u)
repeat_p_t airline_code_p(alpha_cap_set_p.derived(), 2, 3)
bounded2_p_t hours_p(uint2_p.derived(), 0u, 23u)
repeat_p_t airport_p(chset_t("0-9A-Z").derived(), 3, 3)
bounded2_p_t day_p(uint2_p.derived(), 1u, 31u)
chset_t alpha_cap_set_p("A-Z")
chset_t class_code_p("A-Z")
bounded4_p_t year_p(uint4_p.derived(), 2000u, 2099u)
bounded2_p_t minutes_p(uint2_p.derived(), 0u, 59u)
bounded2_p_t month_p(uint2_p.derived(), 1u, 12u)
boost::spirit::classic::uint_parser< unsigned int, 10, 1, 4 > uint1_4_p_t
boost::spirit::classic::impl::loop_traits< chset_t, unsignedint, unsignedint >::type repeat_p_t
boost::spirit::classic::bounded< uint4_p_t, unsigned int > bounded4_p_t
boost::spirit::classic::uint_parser< unsigned int, 10, 4, 4 > uint4_p_t
boost::spirit::classic::file_iterator< char_t > iterator_t
boost::spirit::classic::uint_parser< unsigned int, 10, 2, 2 > uint2_p_t
boost::spirit::classic::chset< char_t > chset_t
boost::spirit::classic::bounded< uint2_p_t, unsigned int > bounded2_p_t
boost::spirit::classic::rule< ScannerT > ond_list
definition(OnDParser const &self)
boost::spirit::classic::rule< ScannerT > date
boost::spirit::classic::rule< ScannerT > time
boost::spirit::classic::rule< ScannerT > ond_end
boost::spirit::classic::rule< ScannerT > const & start() const
boost::spirit::classic::rule< ScannerT > ond
boost::spirit::classic::rule< ScannerT > ond_key
boost::spirit::classic::rule< ScannerT > segment
stdair::BomRoot & _bomRoot
OnDPeriodStruct & _onDPeriod
OnDParser(stdair::BomRoot &, OnDPeriodStruct &)
OnDPeriodStruct & _onDPeriod
ParserSemanticAction(OnDPeriodStruct &)
doEndOnD(stdair::BomRoot &, OnDPeriodStruct &)
stdair::BomRoot & _bomRoot
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeAirlineCode(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeClassCode(OnDPeriodStruct &)
void operator()(char iChar) const
storeDateRangeEnd(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeDateRangeStart(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeDestination(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeEndRangeTime(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const
storeOrigin(OnDPeriodStruct &)
storeStartRangeTime(OnDPeriodStruct &)
void operator()(iterator_t iStr, iterator_t iStrEnd) const