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>
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")) {
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);
635 return lBookingRequestStruct;
642 void parseFlightDateKey (
const TokenList_T& iTokenList,
643 stdair::AirportCode_T& ioOrigin,
644 stdair::AirportCode_T& ioDestination,
645 stdair::Date_T& ioDepartureDate) {
647 TokenList_T::const_iterator itTok = iTokenList.begin();
650 if (itTok->empty() ==
true) {
652 std::cerr <<
"Wrong parameters specified. Default paramaters '"
653 << ioOrigin <<
"-" << ioDestination
654 <<
"/" << ioDepartureDate
662 boost::algorithm::to_upper (ioOrigin);
666 if (itTok->empty() ==
false) {
667 ioDestination = *itTok;
668 boost::algorithm::to_upper (ioDestination);
673 if (itTok->empty() ==
true) {
676 std::string lYearString = *itTok;
678 if (itTok->empty() ==
true) {
681 std::string lMonthString = *itTok;
683 if (itTok->empty() ==
true) {
686 std::string lDayString = *itTok;
687 const bool IsDepartureDateReadable =
688 retrieveDate (lYearString, lMonthString, lDayString,
690 if (IsDepartureDateReadable ==
false) {
691 std::cerr <<
"Default paramaters '"
692 << ioOrigin <<
"-" << ioDestination
693 <<
"/" << ioDepartureDate
702 std::string toString (
const TokenList_T& iTokenList) {
703 std::ostringstream oStr;
706 unsigned short idx = 0;
707 for (TokenList_T::const_iterator itTok = iTokenList.begin();
708 itTok != iTokenList.end(); ++itTok, ++idx) {
719 TokenList_T extractTokenList (
const TokenList_T& iTokenList,
720 const std::string& iRegularExpression) {
721 TokenList_T oTokenList;
725 const std::string lFullLine = toString (iTokenList);
728 boost::regex expression (iRegularExpression);
730 std::string::const_iterator start = lFullLine.begin();
731 std::string::const_iterator end = lFullLine.end();
733 boost::match_results<std::string::const_iterator> what;
734 boost::match_flag_type flags = boost::match_default | boost::format_sed;
735 regex_search (start, end, what, expression, flags);
739 const unsigned short lMatchSetSize = what.size();
740 for (
unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
741 const std::string lMatchedString (std::string (what[matchIdx].first,
742 what[matchIdx].second));
744 oTokenList.push_back (lMatchedString);
756 TokenList_T extractTokenListForTSAndBR (
const TokenList_T& iTokenList) {
778 const std::string lRegEx(
"^([[:alpha:]]{2,3})"
779 "[[:space:]]+([[:digit:]]{1,4})"
781 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
782 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
783 "[[:space:]]*([[:digit:]]{1,2})[[:space:]]*"
784 "[[:space:]]+([[:alpha:]]{3})"
785 "[[:space:]]+([[:alpha:]]{3})"
786 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
787 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
788 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
789 "[[:space:]]*([[:digit:]]{1,2})"
790 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
791 "[[:space:]]+([[:alpha:]]{3})"
792 "[[:space:]]+([[:alpha:]]{2})"
793 "[[:space:]]+([[:alpha:]]{2})"
794 "[[:space:]]+([[:digit:]]{1})$");
797 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
803 TokenList_T extractTokenListForOriDestDate (
const TokenList_T& iTokenList) {
813 const std::string lRegEx(
"^([[:alpha:]]{3})"
815 "[[:space:]]*([[:alpha:]]{3})"
817 "[[:space:]]*([[:digit:]]{2,4})"
819 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})"
821 "[[:space:]]*([[:digit:]]{1,2})$");
824 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
829 int main (
int argc,
char* argv[]) {
836 stdair::Filename_T lFareInputFilename;
839 const unsigned int lHistorySize (100);
840 const std::string lHistoryFilename (
"simfqt.hist");
841 const std::string lHistoryBackupFilename (
"simfqt.hist.bak");
844 stdair::AirportCode_T lInteractiveOrigin;
845 stdair::AirportCode_T lInteractiveDestination;
846 stdair::Date_T lInteractiveDepartureDate;
849 stdair::Filename_T lLogFilename;
852 const int lOptionParserStatus =
860 std::ofstream logOutputFile;
862 logOutputFile.open (lLogFilename.c_str());
863 logOutputFile.clear();
866 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
870 STDAIR_LOG_DEBUG (
"Welcome to SimFQT display");
873 if (isBuiltin ==
true) {
875 simfqtService.buildSampleBom();
879 simfqtService.parseAndLoad (lFareFilePath);
883 const std::string& lCSVDump = simfqtService.csvDisplay();
884 STDAIR_LOG_DEBUG (lCSVDump);
887 STDAIR_LOG_DEBUG (
"====================================================");
888 STDAIR_LOG_DEBUG (
"= Beginning of the interactive session =");
889 STDAIR_LOG_DEBUG (
"====================================================");
892 swift::SReadline lReader (lHistoryFilename, lHistorySize);
893 initReadline (lReader);
896 std::string lUserInput;
897 bool EndOfInput (
false);
898 Command_T::Type_T lCommandType (Command_T::NOP);
900 while (lCommandType != Command_T::QUIT && EndOfInput ==
false) {
902 stdair::TravelSolutionList_T lInteractiveTravelSolutionList;
903 stdair::TravelSolutionStruct lInteractiveTravelSolution;
908 const bool isCRSBookingRequest = !isBuiltin;
909 const stdair::BookingRequestStruct& lInteractiveBookingRequest =
910 simfqtService.buildBookingRequest (isCRSBookingRequest);
913 if (isBuiltin ==
true) {
914 lInteractiveOrigin =
"LHR";
915 lInteractiveDestination =
"SYD";
916 lInteractiveDepartureDate = stdair::Date_T(2011,06,10);
917 simfqtService.buildSampleTravelSolutions (lInteractiveTravelSolutionList);
919 lInteractiveOrigin =
"SIN";
920 lInteractiveDestination =
"BKK";
921 lInteractiveDepartureDate = stdair::Date_T(2010,01,30);
923 const std::string lBA9_SegmentDateKey (
"SQ, 970, 2010-01-30, SIN, BKK, 07:10");
926 lInteractiveTravelSolution.addSegment (lBA9_SegmentDateKey);
929 lInteractiveTravelSolutionList.push_back (lInteractiveTravelSolution);
933 std::ostringstream oPromptStr;
934 oPromptStr <<
"simfqt "
937 TokenList_T lTokenListByReadline;
938 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
942 lReader.SaveHistory (lHistoryBackupFilename);
945 std::cout << std::endl;
950 lCommandType = extractCommand (lTokenListByReadline);
952 switch (lCommandType) {
955 case Command_T::HELP: {
958 stdair::TravelSolutionStruct& lTravelSolutionStruct =
959 lInteractiveTravelSolutionList.front();
961 const stdair::SegmentPath_T& lSegmentPath =
962 lTravelSolutionStruct.getSegmentPath();
964 const std::string& lSegmentDateKey = lSegmentPath.front();
966 const stdair::ParsedKey& lParsedKey =
967 stdair::BomKeyManager::extractKeys (lSegmentDateKey);
969 const stdair::DateTime_T& lRequestDateTime =
970 lInteractiveBookingRequest.getRequestDateTime();
971 const stdair::Time_T lRequestTime =
972 lRequestDateTime.time_of_day();
973 std::cout << std::endl;
975 std::cout <<
"Commands: " << std::endl;
976 std::cout <<
" help" <<
"\t\t" <<
"Display this help" << std::endl;
977 std::cout <<
" quit" <<
"\t\t" <<
"Quit the application" << std::endl;
978 std::cout <<
" list" <<
"\t\t"
979 <<
"List all the fare rule O&Ds and the corresponding date ranges" << std::endl;
980 std::cout <<
" display" <<
"\t"
981 <<
"Display all fare rules for an O&D and a departure date. \n" <<
"\t\t"
982 <<
"If no parameters specified or wrong list of parameters, default values are used: \n"<<
"\t\t"
983 <<
" display " << lInteractiveOrigin <<
" "
984 << lInteractiveDestination <<
" "
985 << lInteractiveDepartureDate << std::endl;
986 std::cout <<
" price" <<
"\t\t"
987 <<
"Price the travel solution corresponding to a booking request. \n" <<
"\t\t"
988 <<
"If no parameters specified or wrong list of parameters, default value are used: \n" <<
"\t\t"
990 << lParsedKey._airlineCode <<
" "
991 << lParsedKey._flightNumber <<
" "
992 << lParsedKey._departureDate <<
" "
993 << lParsedKey._boardingPoint <<
" "
994 << lParsedKey._offPoint <<
" "
995 << lParsedKey._boardingTime <<
" "
996 << lRequestDateTime.date() <<
" "
997 << lRequestTime.hours() <<
":" << lRequestTime.minutes() <<
" "
998 << lInteractiveBookingRequest.getPOS() <<
" "
999 << lInteractiveBookingRequest.getBookingChannel() <<
" "
1000 << lInteractiveBookingRequest.getTripType() <<
" "
1001 << lInteractiveBookingRequest.getStayDuration() << std::endl;
1002 std::cout << std::endl;
1007 case Command_T::QUIT: {
1012 case Command_T::LIST: {
1016 const std::string& lAirportPairDateListStr =
1017 simfqtService.list ();
1019 if (lAirportPairDateListStr.empty() ==
false) {
1020 std::cout << lAirportPairDateListStr << std::endl;
1021 STDAIR_LOG_DEBUG (lAirportPairDateListStr);
1024 std::cerr <<
"There is no result for airport pairs and date ranges."
1025 <<
"Make sure your input file is not empty."
1033 case Command_T::DISPLAY: {
1036 if (lTokenListByReadline.empty() ==
true) {
1038 std::cout <<
"No parameters specified. Default paramaters '"
1039 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1040 <<
"/" << lInteractiveDepartureDate
1047 TokenList_T lTokenList =
1048 extractTokenListForOriDestDate (lTokenListByReadline);
1053 parseFlightDateKey (lTokenList, lInteractiveOrigin,
1054 lInteractiveDestination, lInteractiveDepartureDate);
1060 const bool isAirportPairDateValid =
1061 simfqtService.check (lInteractiveOrigin, lInteractiveDestination,
1062 lInteractiveDepartureDate);
1064 if (isAirportPairDateValid ==
false) {
1065 std::ostringstream oFDKStr;
1066 oFDKStr <<
"The airport pair/departure date: "
1067 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1068 <<
"/" << lInteractiveDepartureDate
1069 <<
" does not correpond to any fare rule.\n"
1070 <<
"Make sure it exists with the 'list' command.";
1071 std::cout << oFDKStr.str() << std::endl;
1072 STDAIR_LOG_ERROR (oFDKStr.str());
1078 std::cout <<
"List of fare rules for "
1079 << lInteractiveOrigin <<
"-"
1080 << lInteractiveDestination <<
"/"
1081 << lInteractiveDepartureDate
1084 const std::string& lFareRuleListStr =
1085 simfqtService.csvDisplay (lInteractiveOrigin,
1086 lInteractiveDestination,
1087 lInteractiveDepartureDate);
1089 assert (lFareRuleListStr.empty() ==
false);
1090 std::cout << lFareRuleListStr << std::endl;
1091 STDAIR_LOG_DEBUG (lFareRuleListStr);
1097 case Command_T::PRICE: {
1100 if (lTokenListByReadline.empty() ==
true) {
1102 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1104 std::cout <<
"No parameters specified. Default booking request and default travel solution list are kept.\n"
1105 <<
"Booking request: << "
1106 << lInteractiveBookingRequest.display() <<
" >>"
1107 <<
"\nTravel Solution: << "
1108 << lInteractiveTravelSolution.display() <<
" >>"
1109 <<
"\n********** \n"
1116 simfqtService.quotePrices (lInteractiveBookingRequest,
1117 lInteractiveTravelSolutionList);
1118 }
catch (stdair::ObjectNotFoundException& E) {
1119 std::cerr <<
"The given travel solution corresponding to the given booking request can not be priced.\n"
1127 TokenList_T lTokenList =
1128 extractTokenListForTSAndBR (lTokenListByReadline);
1133 stdair::BookingRequestStruct lFinalBookingRequest
1134 = parseTravelSolutionAndBookingRequestKey (lTokenList,
1135 lInteractiveTravelSolutionList,
1136 lInteractiveBookingRequest);
1139 assert (lInteractiveTravelSolutionList.size() >= 1);
1140 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1144 std::cout <<
"Booking request: << "
1145 << lFinalBookingRequest.display() <<
" >>"
1146 <<
"\nTravel Solution: << "
1147 << lInteractiveTravelSolution.display() <<
" >>"
1148 <<
"\n********** \n"
1155 simfqtService.quotePrices (lFinalBookingRequest,
1156 lInteractiveTravelSolutionList);
1157 }
catch (stdair::ObjectNotFoundException& E) {
1158 std::cerr <<
"The given travel solution corresponding to the given booking request can not be priced.\n"
1167 lInteractiveTravelSolution = lInteractiveTravelSolutionList.front();
1168 std::cout <<
"Travel Solution: << "
1169 << lInteractiveTravelSolution.display() <<
" >>\n"
1176 case Command_T::NOP: {
1179 case Command_T::LAST_VALUE:
1182 std::ostringstream oStr;
1183 oStr <<
"The '" << lUserInput <<
"' command is not yet understood.\n"
1184 <<
"Type help to have more information." << std::endl;
1186 STDAIR_LOG_DEBUG (oStr.str());
1187 std::cout << oStr.str() << std::endl;
1193 STDAIR_LOG_DEBUG (
"End of the session. Exiting.");
1194 std::cout <<
"End of the session. Exiting." << std::endl;
1197 logOutputFile.close();