9 #include <stdair/stdair_exceptions.hpp>
10 #include <stdair/basic/BasConst_TravelSolution.hpp>
11 #include <stdair/basic/BasFileMgr.hpp>
12 #include <stdair/bom/BomRoot.hpp>
13 #include <stdair/service/Logger.hpp>
22 bool hasReadBeenSuccessful =
false;
25 const bool doesExistAndIsReadable =
26 stdair::BasFileMgr::doesExistAndIsReadable (iInputFileName);
27 if (doesExistAndIsReadable ==
false) {
28 std::ostringstream oMessage;
29 oMessage <<
"The input file, '" << iInputFileName
30 <<
"', can not be retrieved on the file-system";
31 throw stdair::FileNotFoundException (oMessage.str());
35 std::ifstream inputFile (iInputFileName.c_str());
37 STDAIR_LOG_ERROR (
"Can not open input file '" << iInputFileName <<
"'");
38 throw new stdair::FileNotFoundException (
"Can not open input file '"
39 + iInputFileName +
"'");
46 bool hasAllPArams =
true;
48 stdair::AirportCode_T dAirport;
49 stdair::AirportCode_T aAirport;
50 stdair::Date_T depDate;
51 stdair::Duration_T depTime;
52 stdair::Duration_T arTime;
53 stdair::Duration_T dur;
55 stdair::AirlineCode_T airline;
56 stdair::CabinCode_T cabin;
63 while (inputFile.getline (buffer, sizeof (buffer),
';')) {
64 std::istringstream iStringStr (buffer);
73 hasRead = (iStringStr >> dvalStr);
77 hasRead = (iStringStr >> dval);
90 depDate = boost::gregorian::from_simple_string (dvalStr);
94 depTime = boost::posix_time::duration_from_string (dvalStr);
97 arTime = boost::posix_time::duration_from_string (dvalStr);
100 dur = boost::posix_time::duration_from_string (dvalStr);
113 }
else if (i == 10) {
116 }
else if (i == 11) {
119 }
else if (i == 12) {
122 }
else if (i == 13) {
127 }
else if (i == 14) {
138 hasAllPArams =
false;
142 if (hasAllPArams && i == 1) {
143 STDAIR_LOG_DEBUG (
"Successfully read");
147 if (!inputFile.eof()) {
148 STDAIR_LOG_ERROR (
"Problem when reading input file '" << iInputFileName
150 return hasReadBeenSuccessful;
154 hasReadBeenSuccessful =
true;
155 return hasReadBeenSuccessful;