7 #include <stdair/basic/BasFileMgr.hpp>
8 #include <stdair/bom/BomRoot.hpp>
9 #include <stdair/service/Logger.hpp>
16 namespace OnDParserHelper {
26 : _onDPeriod (ioOnDPeriod) {
37 std::string lOrigin (iStr, iStrEnd);
57 std::string lDestination (iStr, iStrEnd);
93 const stdair::DateOffset_T oneDay (1);
146 const std::string lAirlineCodeStr (iStr, iStrEnd);
147 const stdair::AirlineCode_T lAirlineCode(lAirlineCodeStr);
151 std::ostringstream ostr;
155 const stdair::AirlineCode_T lPreviousAirlineCode =
157 if (lPreviousAirlineCode != lAirlineCode) {
178 std::ostringstream ostr;
180 std::string classCodeStr = ostr.str();
181 const stdair::ClassCode_T lClassCode (classCodeStr);
186 std::ostringstream ostrr;
195 _bomRoot (ioBomRoot) {
262 : _bomRoot (ioBomRoot), _onDPeriod (ioOnDPeriod) {
266 template<
typename ScannerT>
269 ond_list = *( boost::spirit::classic::comment_p(
"//")
270 | boost::spirit::classic::comment_p(
"/*",
"*/")
275 >> +(
';' >> segment )
276 >> ond_end[
doEndOnD(
self._bomRoot,
self._onDPeriod)]
279 ond_end = boost::spirit::classic::ch_p(
';')
290 date = boost::spirit::classic::
291 lexeme_d[(
year_p)[boost::spirit::classic::
292 assign_a(
self._onDPeriod._itYear)]
294 >> (
month_p)[boost::spirit::classic::
295 assign_a(
self._onDPeriod._itMonth)]
297 >> (
day_p)[boost::spirit::classic::
298 assign_a(
self._onDPeriod._itDay)]]
301 time = boost::spirit::classic::
302 lexeme_d[(
hours_p)[boost::spirit::classic::
303 assign_a(
self._onDPeriod._itHours)]
306 assign_a(
self._onDPeriod._itMinutes)]
307 >> !(
':' >> (
seconds_p)[boost::spirit::classic::
308 assign_a(
self._onDPeriod._itSeconds)])]
311 segment = boost::spirit::classic::
317 BOOST_SPIRIT_DEBUG_NODE (ond_list);
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);