12 #include <boost/program_options.hpp>
13 #include <boost/tokenizer.hpp>
14 #include <boost/regex.hpp>
16 #include <stdair/basic/BasLogParams.hpp>
17 #include <stdair/basic/BasConst_BomDisplay.hpp>
18 #include <stdair/basic/BasDBParams.hpp>
19 #include <stdair/basic/BasConst_DefaultObject.hpp>
20 #include <stdair/basic/BasConst_Inventory.hpp>
21 #include <stdair/basic/BasConst_Request.hpp>
22 #include <stdair/service/Logger.hpp>
23 #include <stdair/stdair_exceptions.hpp>
24 #include <stdair/stdair_basic_types.hpp>
25 #include <stdair/stdair_date_time_types.hpp>
26 #include <stdair/bom/TravelSolutionStruct.hpp>
27 #include <stdair/bom/BookingRequestStruct.hpp>
28 #include <stdair/bom/ParsedKey.hpp>
29 #include <stdair/bom/BomKeyManager.hpp>
30 #include <stdair/command/CmdBomManager.hpp>
32 #include <stdair/ui/cmdline/SReadline.hpp>
35 #include <simfqt/config/simfqt-paths.hpp>
65 typedef std::vector<std::string> TokenList_T;
84 template<
class T> std::ostream&
operator<< (std::ostream& os,
85 const std::vector<T>& v) {
86 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
94 stdair::Filename_T& ioFareInputFilename,
95 std::string& ioLogFilename) {
101 boost::program_options::options_description
generic (
"Generic options");
102 generic.add_options()
103 (
"prefix",
"print installation prefix")
104 (
"version,v",
"print version string")
105 (
"help,h",
"produce help message");
109 boost::program_options::options_description config (
"Configuration");
112 "The sample BOM tree can be either built-in or parsed from an input file. That latter must then be given with the -f/--fare option")
115 "(CSV) input file for the fare rules")
118 "Filename for the logs")
123 boost::program_options::options_description hidden (
"Hidden options");
126 boost::program_options::value< std::vector<std::string> >(),
127 "Show the copyright (license)");
129 boost::program_options::options_description cmdline_options;
130 cmdline_options.add(
generic).add(config).add(hidden);
132 boost::program_options::options_description config_file_options;
133 config_file_options.add(config).add(hidden);
135 boost::program_options::options_description visible (
"Allowed options");
136 visible.add(
generic).add(config);
138 boost::program_options::positional_options_description p;
139 p.add (
"copyright", -1);
141 boost::program_options::variables_map vm;
142 boost::program_options::
143 store (boost::program_options::command_line_parser (argc, argv).
144 options (cmdline_options).positional(p).run(), vm);
146 std::ifstream ifs (
"simfqt.cfg");
147 boost::program_options::store (parse_config_file (ifs, config_file_options),
149 boost::program_options::notify (vm);
if (vm.count (
"help")) {
150 std::cout << visible << std::endl;
154 if (vm.count (
"version")) {
155 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
159 if (vm.count (
"prefix")) {
160 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
164 if (vm.count (
"builtin")) {
167 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
168 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
170 if (ioIsBuiltin ==
false) {
173 if (vm.count (
"fare")) {
174 ioFareInputFilename = vm[
"fare"].as< std::string >();
175 std::cout <<
"Input fare filename is: " << ioFareInputFilename
181 std::cerr <<
"Either one among the -b/--builtin and -f/--fare "
182 <<
"options must be specified" << std::endl;
186 if (vm.count (
"log")) {
187 ioLogFilename = vm[
"log"].as< std::string >();
188 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
196 void initReadline (swift::SReadline& ioInputReader) {
199 std::vector<std::string> Completers;
204 Completers.push_back (
"help");
205 Completers.push_back (
"list");
206 Completers.push_back (
"display %airport_code %airport_code %departure_date");
207 Completers.push_back (
"price %airline_code %flight_number %departure_date %airport_code %airport_code %departure_time %booking_date %booking_time %POS %channel% %trip_type %stay_duration");
208 Completers.push_back (
"quit");
212 ioInputReader.RegisterCompletions (Completers);
216 Command_T::Type_T extractCommand (TokenList_T& ioTokenList) {
217 Command_T::Type_T oCommandType = Command_T::LAST_VALUE;
220 if (ioTokenList.empty() ==
false) {
221 TokenList_T::iterator itTok = ioTokenList.begin();
222 std::string& lCommand (*itTok);
223 boost::algorithm::to_lower (lCommand);
225 if (lCommand ==
"help") {
226 oCommandType = Command_T::HELP;
228 }
else if (lCommand ==
"list") {
229 oCommandType = Command_T::LIST;
231 }
else if (lCommand ==
"display") {
232 oCommandType = Command_T::DISPLAY;
234 }
else if (lCommand ==
"price") {
235 oCommandType = Command_T::PRICE;
237 }
else if (lCommand ==
"quit") {
238 oCommandType = Command_T::QUIT;
244 ioTokenList.erase (itTok);
247 oCommandType = Command_T::NOP;
256 bool retrieveDate (std::string iYearString,
257 std::string iMonthString,
258 std::string iDayString,
259 stdair::Date_T& ioDate) {
261 const std::string kMonthStr[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
262 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
265 unsigned short lDateYear;
268 lDateYear = boost::lexical_cast<
unsigned short> (iYearString);
269 if (lDateYear < 100) {
273 }
catch (boost::bad_lexical_cast& eCast) {
274 std::cerr <<
"The year ('" << iYearString
275 <<
"') cannot be understood." << std::endl;
280 std::string lDateMonthStr;
283 const boost::regex lMonthRegex (
"^(\\d{1,2})$");
284 const bool isMonthANumber = regex_match (iMonthString, lMonthRegex);
286 if (isMonthANumber ==
true) {
287 const unsigned short lMonth =
288 boost::lexical_cast<
unsigned short> (iMonthString);
290 throw boost::bad_lexical_cast();
293 lDateMonthStr = kMonthStr[lMonth-1];
295 std::cerr <<
"The month ('" << iMonthString
296 <<
"') cannot be understood." << std::endl;
301 if (iMonthString.size() < 3) {
302 throw boost::bad_lexical_cast();
304 std::string lMonthStr1 (iMonthString.substr (0, 1));
305 boost::algorithm::to_upper (lMonthStr1);
306 std::string lMonthStr23 (iMonthString.substr (1, 2));
307 boost::algorithm::to_lower (lMonthStr23);
308 lDateMonthStr = lMonthStr1 + lMonthStr23;
311 }
catch (boost::bad_lexical_cast& eCast) {
312 std::cerr <<
"The month ('" << iMonthString
313 <<
"') cannot be understood." << std::endl;
318 unsigned short lDateDay;
321 lDateDay = boost::lexical_cast<
unsigned short> (iDayString);
323 }
catch (boost::bad_lexical_cast& eCast) {
324 std::cerr <<
"The day ('" << iDayString
325 <<
"') cannot be understood." << std::endl;
330 std::ostringstream lDateStr;
331 lDateStr << lDateYear <<
"-" << lDateMonthStr
336 boost::gregorian::from_simple_string (lDateStr.str());
338 }
catch (boost::gregorian::bad_month& eCast) {
339 std::cerr <<
"The month of the date ('" << lDateStr.str()
340 <<
"') cannot be understood." << std::endl;
342 }
catch (boost::gregorian::bad_day_of_month& eCast) {
343 std::cerr <<
"The date ('" << lDateStr.str()
344 <<
"') is not correct: the day of month does not exist."
347 }
catch (boost::gregorian::bad_year& eCast) {
348 std::cerr <<
"The year ('" << lDateStr.str()
349 <<
"') is not correct."
360 bool retrieveTime (std::string iHourString,
361 std::string iMinuteString,
362 stdair::Duration_T& oTime) {
365 unsigned short lTimeHour;
368 lTimeHour = boost::lexical_cast<
unsigned short> (iHourString);
370 }
catch (boost::bad_lexical_cast& eCast) {
371 std::cerr <<
"The hour of the time ('" << iHourString
372 <<
"') cannot be understood." << std::endl;
377 unsigned short lTimeMinute;
380 lTimeMinute = boost::lexical_cast<
unsigned short> (iMinuteString);
382 }
catch (boost::bad_lexical_cast& eCast) {
383 std::cerr <<
"The minute of the time ('" << iMinuteString
384 <<
"') cannot be understood." << std::endl;
390 std::ostringstream lTimeStr;
391 lTimeStr << lTimeHour <<
":" << lTimeMinute;
393 boost::posix_time::duration_from_string (lTimeStr.str());
401 const stdair::BookingRequestStruct parseTravelSolutionAndBookingRequestKey
402 (
const TokenList_T& iTokenList,
403 stdair::TravelSolutionList_T& ioInteractiveTravelSolutionList,
404 const stdair::BookingRequestStruct& ioBookingRequestStruct) {
406 TokenList_T::const_iterator itTok = iTokenList.begin();
408 if (itTok->empty() ==
true) {
410 std::cerr <<
"Wrong list of parameters. "
411 <<
"The default booking request and travel solution list are kept."
413 return ioBookingRequestStruct;
420 stdair::AirlineCode_T lAirlineCode;
421 stdair::FlightNumber_T lflightNumber;
422 stdair::Date_T lDepartureDate;
423 stdair::Duration_T lDepartureTime;
424 stdair::AirportCode_T lOriginAirport;
425 stdair::AirportCode_T lDestinationAirport;
426 stdair::Date_T lRequestDate;
427 stdair::Duration_T lRequestTime;
428 stdair::CityCode_T lPOS;
429 stdair::ChannelLabel_T lChannel;
430 stdair::TripType_T lTripType;
431 unsigned short lStayDuration;
434 lAirlineCode = *itTok;
435 boost::algorithm::to_upper (lAirlineCode);
439 if (itTok->empty() ==
false) {
442 lflightNumber = boost::lexical_cast<stdair::FlightNumber_T> (*itTok);
444 }
catch (boost::bad_lexical_cast& eCast) {
445 std::cerr <<
"The flight number ('" << *itTok
446 <<
"') cannot be understood."
448 return ioBookingRequestStruct;
454 if (itTok->empty() ==
true) {
455 return ioBookingRequestStruct;
457 const std::string lDepartureYearString = *itTok;
459 if (itTok->empty() ==
true) {
460 return ioBookingRequestStruct;
462 const std::string lDepartureMonthString = *itTok;
464 if (itTok->empty() ==
true) {
465 return ioBookingRequestStruct;
467 const std::string lDepartureDayString = *itTok;
468 const bool IsDepartureDateReadable =
469 retrieveDate (lDepartureYearString, lDepartureMonthString,
470 lDepartureDayString, lDepartureDate);
472 if (IsDepartureDateReadable ==
false) {
473 std::cerr <<
"The default booking request and travel solution list are kept."
475 return ioBookingRequestStruct;
480 if (itTok->empty() ==
false) {
481 lOriginAirport = *itTok;
482 boost::algorithm::to_upper (lOriginAirport);
487 if (itTok->empty() ==
false) {
488 lDestinationAirport = *itTok;
489 boost::algorithm::to_upper (lDestinationAirport);
494 if (itTok->empty() ==
true) {
495 return ioBookingRequestStruct;
497 const std::string lDepartureHourString = *itTok;
499 if (itTok->empty() ==
true) {
500 return ioBookingRequestStruct;
502 const std::string lDepartureMinuteString = *itTok;
503 const bool IsDepartureTimeReadable =
504 retrieveTime (lDepartureHourString, lDepartureMinuteString,
507 if (IsDepartureTimeReadable ==
false) {
508 std::cerr <<
"The default booking request and travel solution list are kept."
510 return ioBookingRequestStruct;
515 if (itTok->empty() ==
true) {
516 return ioBookingRequestStruct;
518 const std::string lRequestYearString = *itTok;
520 if (itTok->empty() ==
true) {
521 return ioBookingRequestStruct;
523 const std::string lRequestMonthString = *itTok;
525 if (itTok->empty() ==
true) {
526 return ioBookingRequestStruct;
528 const std::string lRequestDayString = *itTok;
529 const bool IsRequestDateReadable =
530 retrieveDate (lRequestYearString, lRequestMonthString,
531 lRequestDayString, lRequestDate);
533 if (IsRequestDateReadable ==
false) {
534 std::cerr <<
"The default booking request and travel solution list are kept."
536 return ioBookingRequestStruct;
541 if (itTok->empty() ==
true) {
542 return ioBookingRequestStruct;
544 const std::string lRequestHourString = *itTok;
546 if (itTok->empty() ==
true) {
547 return ioBookingRequestStruct;
549 const std::string lRequestMinuteString = *itTok;
550 const bool IsRequestTimeReadable =
551 retrieveTime (lRequestHourString, lRequestMinuteString,
554 if (IsRequestTimeReadable ==
false) {
555 std::cerr <<
"The default booking request and travel solution list are kept."
557 return ioBookingRequestStruct;
562 if (itTok->empty() ==
false) {
564 boost::algorithm::to_upper (lPOS);
569 if (itTok->empty() ==
false) {
571 boost::algorithm::to_upper (lChannel);
576 if (itTok->empty() ==
false) {
578 boost::algorithm::to_upper (lTripType);
583 if (itTok->empty() ==
false) {
586 lStayDuration = boost::lexical_cast<
unsigned short> (*itTok);
588 }
catch (boost::bad_lexical_cast& eCast) {
589 std::cerr <<
"The stay duration ('" << *itTok
590 <<
"') cannot be understood." << std::endl;
591 return ioBookingRequestStruct;
599 ioInteractiveTravelSolutionList.pop_front();
601 stdair::TravelSolutionStruct lTravelSolution;
602 std::ostringstream oStr;
604 << stdair::DEFAULT_KEY_FLD_DELIMITER
606 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
608 << stdair::DEFAULT_KEY_FLD_DELIMITER
610 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
611 << lDestinationAirport
612 << stdair::DEFAULT_KEY_FLD_DELIMITER
614 lTravelSolution.addSegment (oStr.str());
615 ioInteractiveTravelSolutionList.push_front(lTravelSolution);
618 stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
619 const stdair::BookingRequestStruct &lBookingRequestStruct =
620 stdair::BookingRequestStruct(lOriginAirport,
626 stdair::DEFAULT_PARTY_SIZE,
630 stdair::FREQUENT_FLYER_MEMBER,
633 stdair::DEFAULT_VALUE_OF_TIME,
636 return lBookingRequestStruct;
643 void parseFlightDateKey (
const TokenList_T& iTokenList,
644 stdair::AirportCode_T& ioOrigin,
645 stdair::AirportCode_T& ioDestination,
646 stdair::Date_T& ioDepartureDate) {
648 TokenList_T::const_iterator itTok = iTokenList.begin();
651 if (itTok->empty() ==
true) {
653 std::cerr <<
"Wrong parameters specified. Default paramaters '"
654 << ioOrigin <<
"-" << ioDestination
655 <<
"/" << ioDepartureDate
663 boost::algorithm::to_upper (ioOrigin);
667 if (itTok->empty() ==
false) {
668 ioDestination = *itTok;
669 boost::algorithm::to_upper (ioDestination);
674 if (itTok->empty() ==
true) {
677 std::string lYearString = *itTok;
679 if (itTok->empty() ==
true) {
682 std::string lMonthString = *itTok;
684 if (itTok->empty() ==
true) {
687 std::string lDayString = *itTok;
688 const bool IsDepartureDateReadable =
689 retrieveDate (lYearString, lMonthString, lDayString,
691 if (IsDepartureDateReadable ==
false) {
692 std::cerr <<
"Default paramaters '"
693 << ioOrigin <<
"-" << ioDestination
694 <<
"/" << ioDepartureDate
703 std::string toString (
const TokenList_T& iTokenList) {
704 std::ostringstream oStr;
707 unsigned short idx = 0;
708 for (TokenList_T::const_iterator itTok = iTokenList.begin();
709 itTok != iTokenList.end(); ++itTok, ++idx) {
720 TokenList_T extractTokenList (
const TokenList_T& iTokenList,
721 const std::string& iRegularExpression) {
722 TokenList_T oTokenList;
726 const std::string lFullLine = toString (iTokenList);
729 boost::regex expression (iRegularExpression);
731 std::string::const_iterator start = lFullLine.begin();
732 std::string::const_iterator end = lFullLine.end();
734 boost::match_results<std::string::const_iterator> what;
735 boost::match_flag_type flags = boost::match_default | boost::format_sed;
736 regex_search (start, end, what, expression, flags);
740 const unsigned short lMatchSetSize = what.size();
741 for (
unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
742 const std::string lMatchedString (std::string (what[matchIdx].first,
743 what[matchIdx].second));
745 oTokenList.push_back (lMatchedString);
757 TokenList_T extractTokenListForTSAndBR (
const TokenList_T& iTokenList) {
779 const std::string lRegEx(
"^([[:alpha:]]{2,3})"
780 "[[:space:]]+([[:digit:]]{1,4})"
782 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
783 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
784 "[[:space:]]*([[:digit:]]{1,2})[[:space:]]*"
785 "[[:space:]]+([[:alpha:]]{3})"
786 "[[:space:]]+([[:alpha:]]{3})"
787 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
788 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
789 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
790 "[[:space:]]*([[:digit:]]{1,2})"
791 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
792 "[[:space:]]+([[:alpha:]]{3})"
793 "[[:space:]]+([[:alpha:]]{2})"
794 "[[:space:]]+([[:alpha:]]{2})"
795 "[[:space:]]+([[:digit:]]{1})$");
798 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
804 TokenList_T extractTokenListForOriDestDate (
const TokenList_T& iTokenList) {
814 const std::string lRegEx(
"^([[:alpha:]]{3})"
816 "[[:space:]]*([[:alpha:]]{3})"
818 "[[:space:]]*([[:digit:]]{2,4})"
820 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})"
822 "[[:space:]]*([[:digit:]]{1,2})$");
825 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
830 int main (
int argc,
char* argv[]) {
837 stdair::Filename_T lFareInputFilename;
840 const unsigned int lHistorySize (100);
841 const std::string lHistoryFilename (
"simfqt.hist");
842 const std::string lHistoryBackupFilename (
"simfqt.hist.bak");
845 stdair::AirportCode_T lInteractiveOrigin;
846 stdair::AirportCode_T lInteractiveDestination;
847 stdair::Date_T lInteractiveDepartureDate;
850 stdair::Filename_T lLogFilename;
853 const int lOptionParserStatus =
861 std::ofstream logOutputFile;
863 logOutputFile.open (lLogFilename.c_str());
864 logOutputFile.clear();
867 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
871 STDAIR_LOG_DEBUG (
"Welcome to SimFQT display");
874 if (isBuiltin ==
true) {
876 simfqtService.buildSampleBom();
880 simfqtService.parseAndLoad (lFareFilePath);
884 const std::string& lCSVDump = simfqtService.csvDisplay();
885 STDAIR_LOG_DEBUG (lCSVDump);
888 STDAIR_LOG_DEBUG (
"====================================================");
889 STDAIR_LOG_DEBUG (
"= Beginning of the interactive session =");
890 STDAIR_LOG_DEBUG (
"====================================================");
893 swift::SReadline lReader (lHistoryFilename, lHistorySize);
894 initReadline (lReader);
897 std::string lUserInput;
898 bool EndOfInput (
false);
899 Command_T::Type_T lCommandType (Command_T::NOP);
901 while (lCommandType != Command_T::QUIT && EndOfInput ==
false) {
903 stdair::TravelSolutionList_T lInteractiveTravelSolutionList;
904 stdair::TravelSolutionStruct lInteractiveTravelSolution;
909 const bool isCRSBookingRequest = !isBuiltin;
910 const stdair::BookingRequestStruct& lInteractiveBookingRequest =
911 simfqtService.buildBookingRequest (isCRSBookingRequest);
914 if (isBuiltin ==
true) {
915 lInteractiveOrigin =
"LHR";
916 lInteractiveDestination =
"SYD";
917 lInteractiveDepartureDate = stdair::Date_T(2011,06,10);
918 simfqtService.buildSampleTravelSolutions (lInteractiveTravelSolutionList);
920 lInteractiveOrigin =
"SIN";
921 lInteractiveDestination =
"BKK";
922 lInteractiveDepartureDate = stdair::Date_T(2010,01,30);
924 const std::string lBA9_SegmentDateKey (
"SQ, 970, 2010-01-30, SIN, BKK, 07:10");
927 lInteractiveTravelSolution.addSegment (lBA9_SegmentDateKey);
930 lInteractiveTravelSolutionList.push_back (lInteractiveTravelSolution);
934 std::ostringstream oPromptStr;
935 oPromptStr <<
"simfqt "
938 TokenList_T lTokenListByReadline;
939 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
943 lReader.SaveHistory (lHistoryBackupFilename);
946 std::cout << std::endl;
951 lCommandType = extractCommand (lTokenListByReadline);
953 switch (lCommandType) {
956 case Command_T::HELP: {
959 stdair::TravelSolutionStruct& lTravelSolutionStruct =
960 lInteractiveTravelSolutionList.front();
962 const stdair::SegmentPath_T& lSegmentPath =
963 lTravelSolutionStruct.getSegmentPath();
965 const std::string& lSegmentDateKey = lSegmentPath.front();
967 const stdair::ParsedKey& lParsedKey =
968 stdair::BomKeyManager::extractKeys (lSegmentDateKey);
970 const stdair::DateTime_T& lRequestDateTime =
971 lInteractiveBookingRequest.getRequestDateTime();
972 const stdair::Time_T lRequestTime =
973 lRequestDateTime.time_of_day();
974 std::cout << std::endl;
976 std::cout <<
"Commands: " << std::endl;
977 std::cout <<
" help" <<
"\t\t" <<
"Display this help" << std::endl;
978 std::cout <<
" quit" <<
"\t\t" <<
"Quit the application" << std::endl;
979 std::cout <<
" list" <<
"\t\t"
980 <<
"List all the fare rule O&Ds and the corresponding date ranges" << std::endl;
981 std::cout <<
" display" <<
"\t"
982 <<
"Display all fare rules for an O&D and a departure date. \n" <<
"\t\t"
983 <<
"If no parameters specified or wrong list of parameters, default values are used: \n"<<
"\t\t"
984 <<
" display " << lInteractiveOrigin <<
" "
985 << lInteractiveDestination <<
" "
986 << lInteractiveDepartureDate << std::endl;
987 std::cout <<
" price" <<
"\t\t"
988 <<
"Price the travel solution corresponding to a booking request. \n" <<
"\t\t"
989 <<
"If no parameters specified or wrong list of parameters, default value are used: \n" <<
"\t\t"
991 << lParsedKey._airlineCode <<
" "
992 << lParsedKey._flightNumber <<
" "
993 << lParsedKey._departureDate <<
" "
994 << lParsedKey._boardingPoint <<
" "
995 << lParsedKey._offPoint <<
" "
996 << lParsedKey._boardingTime <<
" "
997 << lRequestDateTime.date() <<
" "
998 << lRequestTime.hours() <<
":" << lRequestTime.minutes() <<
" "
999 << lInteractiveBookingRequest.getPOS() <<
" "
1000 << lInteractiveBookingRequest.getBookingChannel() <<
" "
1001 << lInteractiveBookingRequest.getTripType() <<
" "
1002 << lInteractiveBookingRequest.getStayDuration() << std::endl;
1003 std::cout << std::endl;
1008 case Command_T::QUIT: {
1013 case Command_T::LIST: {
1017 const std::string& lAirportPairDateListStr =
1018 simfqtService.list ();
1020 if (lAirportPairDateListStr.empty() ==
false) {
1021 std::cout << lAirportPairDateListStr << std::endl;
1022 STDAIR_LOG_DEBUG (lAirportPairDateListStr);
1025 std::cerr <<
"There is no result for airport pairs and date ranges."
1026 <<
"Make sure your input file is not empty."
1034 case Command_T::DISPLAY: {
1037 if (lTokenListByReadline.empty() ==
true) {
1039 std::cout <<
"No parameters specified. Default paramaters '"
1040 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1041 <<
"/" << lInteractiveDepartureDate
1048 TokenList_T lTokenList =
1049 extractTokenListForOriDestDate (lTokenListByReadline);
1054 parseFlightDateKey (lTokenList, lInteractiveOrigin,
1055 lInteractiveDestination, lInteractiveDepartureDate);
1061 const bool isAirportPairDateValid =
1062 simfqtService.check (lInteractiveOrigin, lInteractiveDestination,
1063 lInteractiveDepartureDate);
1065 if (isAirportPairDateValid ==
false) {
1066 std::ostringstream oFDKStr;
1067 oFDKStr <<
"The airport pair/departure date: "
1068 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1069 <<
"/" << lInteractiveDepartureDate
1070 <<
" does not correpond to any fare rule.\n"
1071 <<
"Make sure it exists with the 'list' command.";
1072 std::cout << oFDKStr.str() << std::endl;
1073 STDAIR_LOG_ERROR (oFDKStr.str());
1079 std::cout <<
"List of fare rules for "
1080 << lInteractiveOrigin <<
"-"
1081 << lInteractiveDestination <<
"/"
1082 << lInteractiveDepartureDate
1085 const std::string& lFareRuleListStr =
1086 simfqtService.csvDisplay (lInteractiveOrigin,
1087 lInteractiveDestination,
1088 lInteractiveDepartureDate);
1090 assert (lFareRuleListStr.empty() ==
false);
1091 std::cout << lFareRuleListStr << std::endl;
1092 STDAIR_LOG_DEBUG (lFareRuleListStr);
1098 case Command_T::PRICE: {
1101 if (lTokenListByReadline.empty() ==
true) {
1103 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1105 std::cout <<
"No parameters specified. Default booking request and default travel solution list are kept.\n"
1106 <<
"Booking request: << "
1107 << lInteractiveBookingRequest.display() <<
" >>"
1108 <<
"\nTravel Solution: << "
1109 << lInteractiveTravelSolution.display() <<
" >>"
1110 <<
"\n********** \n"
1117 simfqtService.quotePrices (lInteractiveBookingRequest,
1118 lInteractiveTravelSolutionList);
1119 }
catch (stdair::ObjectNotFoundException& E) {
1120 std::cerr <<
"The given travel solution corresponding to the given booking request can not be priced.\n"
1128 TokenList_T lTokenList =
1129 extractTokenListForTSAndBR (lTokenListByReadline);
1134 stdair::BookingRequestStruct lFinalBookingRequest
1135 = parseTravelSolutionAndBookingRequestKey (lTokenList,
1136 lInteractiveTravelSolutionList,
1137 lInteractiveBookingRequest);
1140 assert (lInteractiveTravelSolutionList.size() >= 1);
1141 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1145 std::cout <<
"Booking request: << "
1146 << lFinalBookingRequest.display() <<
" >>"
1147 <<
"\nTravel Solution: << "
1148 << lInteractiveTravelSolution.display() <<
" >>"
1149 <<
"\n********** \n"
1156 simfqtService.quotePrices (lFinalBookingRequest,
1157 lInteractiveTravelSolutionList);
1158 }
catch (stdair::ObjectNotFoundException& E) {
1159 std::cerr <<
"The given travel solution corresponding to the given booking request can not be priced.\n"
1168 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1169 std::cout <<
"Travel Solution: << "
1170 << lInteractiveTravelSolution.display() <<
" >>\n"
1177 case Command_T::NOP: {
1180 case Command_T::LAST_VALUE:
1183 std::ostringstream oStr;
1184 oStr <<
"The '" << lUserInput <<
"' command is not yet understood.\n"
1185 <<
"Type help to have more information." << std::endl;
1187 STDAIR_LOG_DEBUG (oStr.str());
1188 std::cout << oStr.str() << std::endl;
1194 STDAIR_LOG_DEBUG (
"End of the session. Exiting.");
1195 std::cout <<
"End of the session. Exiting." << std::endl;
1198 logOutputFile.close();