13 #include <boost/date_time/gregorian/gregorian.hpp>
14 #include <boost/date_time/posix_time/posix_time.hpp>
15 #include <boost/program_options.hpp>
16 #include <boost/tokenizer.hpp>
17 #include <boost/regex.hpp>
19 #include <stdair/stdair_exceptions.hpp>
20 #include <stdair/stdair_basic_types.hpp>
21 #include <stdair/stdair_date_time_types.hpp>
22 #include <stdair/basic/BasConst_DefaultObject.hpp>
23 #include <stdair/basic/BasConst_Inventory.hpp>
24 #include <stdair/basic/BasConst_Request.hpp>
25 #include <stdair/basic/BasLogParams.hpp>
26 #include <stdair/basic/BasConst_BomDisplay.hpp>
27 #include <stdair/basic/BasDBParams.hpp>
28 #include <stdair/bom/TravelSolutionStruct.hpp>
29 #include <stdair/bom/BookingRequestStruct.hpp>
30 #include <stdair/bom/ParsedKey.hpp>
31 #include <stdair/bom/BomKeyManager.hpp>
32 #include <stdair/command/CmdBomManager.hpp>
33 #include <stdair/service/Logger.hpp>
35 #include <stdair/ui/cmdline/SReadline.hpp>
38 #include <simfqt/config/simfqt-paths.hpp>
67 typedef std::vector<std::string> TokenList_T;
86 template<
class T> std::ostream&
operator<< (std::ostream& os,
87 const std::vector<T>& v) {
88 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
96 stdair::Filename_T& ioFareInputFilename,
97 std::string& ioLogFilename) {
103 boost::program_options::options_description
generic (
"Generic options");
104 generic.add_options()
105 (
"prefix",
"print installation prefix")
106 (
"version,v",
"print version string")
107 (
"help,h",
"produce help message");
111 boost::program_options::options_description config (
"Configuration");
114 "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")
117 "(CSV) input file for the fare rules")
120 "Filename for the logs")
125 boost::program_options::options_description hidden (
"Hidden options");
128 boost::program_options::value< std::vector<std::string> >(),
129 "Show the copyright (license)");
131 boost::program_options::options_description cmdline_options;
132 cmdline_options.add(
generic).add(config).add(hidden);
134 boost::program_options::options_description config_file_options;
135 config_file_options.add(config).add(hidden);
137 boost::program_options::options_description visible (
"Allowed options");
138 visible.add(
generic).add(config);
140 boost::program_options::positional_options_description p;
141 p.add (
"copyright", -1);
143 boost::program_options::variables_map vm;
144 boost::program_options::
145 store (boost::program_options::command_line_parser (argc, argv).
146 options (cmdline_options).positional(p).run(), vm);
148 std::ifstream ifs (
"simfqt.cfg");
149 boost::program_options::store (parse_config_file (ifs, config_file_options),
151 boost::program_options::notify (vm);
if (vm.count (
"help")) {
152 std::cout << visible << std::endl;
156 if (vm.count (
"version")) {
157 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
161 if (vm.count (
"prefix")) {
162 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
166 if (vm.count (
"builtin")) {
169 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
170 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
172 if (ioIsBuiltin ==
false) {
175 if (vm.count (
"fare")) {
176 ioFareInputFilename = vm[
"fare"].as< std::string >();
177 std::cout <<
"Input fare filename is: " << ioFareInputFilename
183 std::cerr <<
"Either one among the -b/--builtin and -f/--fare "
184 <<
"options must be specified" << std::endl;
188 if (vm.count (
"log")) {
189 ioLogFilename = vm[
"log"].as< std::string >();
190 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
198 void initReadline (swift::SReadline& ioInputReader) {
201 std::vector<std::string> Completers;
206 Completers.push_back (
"help");
207 Completers.push_back (
"list");
208 Completers.push_back (
"display %airport_code %airport_code %departure_date");
209 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");
210 Completers.push_back (
"quit");
214 ioInputReader.RegisterCompletions (Completers);
218 Command_T::Type_T extractCommand (TokenList_T& ioTokenList) {
219 Command_T::Type_T oCommandType = Command_T::LAST_VALUE;
222 if (ioTokenList.empty() ==
false) {
223 TokenList_T::iterator itTok = ioTokenList.begin();
224 std::string& lCommand (*itTok);
225 boost::algorithm::to_lower (lCommand);
227 if (lCommand ==
"help") {
228 oCommandType = Command_T::HELP;
230 }
else if (lCommand ==
"list") {
231 oCommandType = Command_T::LIST;
233 }
else if (lCommand ==
"display") {
234 oCommandType = Command_T::DISPLAY;
236 }
else if (lCommand ==
"price") {
237 oCommandType = Command_T::PRICE;
239 }
else if (lCommand ==
"quit") {
240 oCommandType = Command_T::QUIT;
246 ioTokenList.erase (itTok);
249 oCommandType = Command_T::NOP;
258 bool retrieveDate (std::string iYearString,
259 std::string iMonthString,
260 std::string iDayString,
261 stdair::Date_T& ioDate) {
263 const std::string kMonthStr[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
264 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
267 unsigned short lDateYear;
270 lDateYear = boost::lexical_cast<unsigned short> (iYearString);
271 if (lDateYear < 100) {
275 }
catch (boost::bad_lexical_cast& eCast) {
276 std::cerr <<
"The year ('" << iYearString
277 <<
"') cannot be understood." << std::endl;
282 std::string lDateMonthStr;
285 const boost::regex lMonthRegex (
"^(\\d{1,2})$");
286 const bool isMonthANumber = regex_match (iMonthString, lMonthRegex);
288 if (isMonthANumber ==
true) {
289 const unsigned short lMonth =
290 boost::lexical_cast<unsigned short> (iMonthString);
292 throw boost::bad_lexical_cast();
295 lDateMonthStr = kMonthStr[lMonth-1];
297 std::cerr <<
"The month ('" << iMonthString
298 <<
"') cannot be understood." << std::endl;
303 if (iMonthString.size() < 3) {
304 throw boost::bad_lexical_cast();
306 std::string lMonthStr1 (iMonthString.substr (0, 1));
307 boost::algorithm::to_upper (lMonthStr1);
308 std::string lMonthStr23 (iMonthString.substr (1, 2));
309 boost::algorithm::to_lower (lMonthStr23);
310 lDateMonthStr = lMonthStr1 + lMonthStr23;
313 }
catch (boost::bad_lexical_cast& eCast) {
314 std::cerr <<
"The month ('" << iMonthString
315 <<
"') cannot be understood." << std::endl;
320 unsigned short lDateDay;
323 lDateDay = boost::lexical_cast<unsigned short> (iDayString);
325 }
catch (boost::bad_lexical_cast& eCast) {
326 std::cerr <<
"The day ('" << iDayString
327 <<
"') cannot be understood." << std::endl;
332 std::ostringstream lDateStr;
333 lDateStr << lDateYear <<
"-" << lDateMonthStr
338 boost::gregorian::from_simple_string (lDateStr.str());
340 }
catch (boost::gregorian::bad_month& eCast) {
341 std::cerr <<
"The month of the date ('" << lDateStr.str()
342 <<
"') cannot be understood." << std::endl;
344 }
catch (boost::gregorian::bad_day_of_month& eCast) {
345 std::cerr <<
"The date ('" << lDateStr.str()
346 <<
"') is not correct: the day of month does not exist."
349 }
catch (boost::gregorian::bad_year& eCast) {
350 std::cerr <<
"The year ('" << lDateStr.str()
351 <<
"') is not correct."
362 bool retrieveTime (std::string iHourString,
363 std::string iMinuteString,
364 stdair::Duration_T& oTime) {
367 unsigned short lTimeHour;
370 lTimeHour = boost::lexical_cast<unsigned short> (iHourString);
372 }
catch (boost::bad_lexical_cast& eCast) {
373 std::cerr <<
"The hour of the time ('" << iHourString
374 <<
"') cannot be understood." << std::endl;
379 unsigned short lTimeMinute;
382 lTimeMinute = boost::lexical_cast<unsigned short> (iMinuteString);
384 }
catch (boost::bad_lexical_cast& eCast) {
385 std::cerr <<
"The minute of the time ('" << iMinuteString
386 <<
"') cannot be understood." << std::endl;
392 std::ostringstream lTimeStr;
393 lTimeStr << lTimeHour <<
":" << lTimeMinute;
395 boost::posix_time::duration_from_string (lTimeStr.str());
403 const stdair::BookingRequestStruct parseTravelSolutionAndBookingRequestKey
404 (
const TokenList_T& iTokenList,
405 stdair::TravelSolutionList_T& ioInteractiveTravelSolutionList,
406 const stdair::BookingRequestStruct& ioBookingRequestStruct) {
408 TokenList_T::const_iterator itTok = iTokenList.begin();
410 if (itTok->empty() ==
true) {
412 std::cerr <<
"Wrong list of parameters. "
413 <<
"The default booking request and travel solution list are kept."
415 return ioBookingRequestStruct;
422 stdair::AirlineCode_T lAirlineCode;
423 stdair::FlightNumber_T lflightNumber;
424 stdair::Date_T lDepartureDate;
425 stdair::Duration_T lDepartureTime;
426 stdair::AirportCode_T lOriginAirport;
427 stdair::AirportCode_T lDestinationAirport;
428 stdair::Date_T lRequestDate;
429 stdair::Duration_T lRequestTime;
430 stdair::CityCode_T lPOS;
431 stdair::ChannelLabel_T lChannel;
432 stdair::TripType_T lTripType;
433 unsigned short lStayDuration (stdair::DEFAULT_STAY_DURATION);
436 lAirlineCode = *itTok;
437 boost::algorithm::to_upper (lAirlineCode);
441 if (itTok->empty() ==
false) {
444 lflightNumber = boost::lexical_cast<stdair::FlightNumber_T> (*itTok);
446 }
catch (boost::bad_lexical_cast& eCast) {
447 std::cerr <<
"The flight number ('" << *itTok
448 <<
"') cannot be understood."
450 return ioBookingRequestStruct;
456 if (itTok->empty() ==
true) {
457 return ioBookingRequestStruct;
459 const std::string lDepartureYearString = *itTok;
461 if (itTok->empty() ==
true) {
462 return ioBookingRequestStruct;
464 const std::string lDepartureMonthString = *itTok;
466 if (itTok->empty() ==
true) {
467 return ioBookingRequestStruct;
469 const std::string lDepartureDayString = *itTok;
470 const bool IsDepartureDateReadable =
471 retrieveDate (lDepartureYearString, lDepartureMonthString,
472 lDepartureDayString, lDepartureDate);
474 if (IsDepartureDateReadable ==
false) {
475 std::cerr <<
"The default booking request and travel solution list are kept."
477 return ioBookingRequestStruct;
482 if (itTok->empty() ==
false) {
483 lOriginAirport = *itTok;
484 boost::algorithm::to_upper (lOriginAirport);
489 if (itTok->empty() ==
false) {
490 lDestinationAirport = *itTok;
491 boost::algorithm::to_upper (lDestinationAirport);
496 if (itTok->empty() ==
true) {
497 return ioBookingRequestStruct;
499 const std::string lDepartureHourString = *itTok;
501 if (itTok->empty() ==
true) {
502 return ioBookingRequestStruct;
504 const std::string lDepartureMinuteString = *itTok;
505 const bool IsDepartureTimeReadable =
506 retrieveTime (lDepartureHourString, lDepartureMinuteString,
509 if (IsDepartureTimeReadable ==
false) {
510 std::cerr <<
"The default booking request and travel solution list are kept."
512 return ioBookingRequestStruct;
517 if (itTok->empty() ==
true) {
518 return ioBookingRequestStruct;
520 const std::string lRequestYearString = *itTok;
522 if (itTok->empty() ==
true) {
523 return ioBookingRequestStruct;
525 const std::string lRequestMonthString = *itTok;
527 if (itTok->empty() ==
true) {
528 return ioBookingRequestStruct;
530 const std::string lRequestDayString = *itTok;
531 const bool IsRequestDateReadable =
532 retrieveDate (lRequestYearString, lRequestMonthString,
533 lRequestDayString, lRequestDate);
535 if (IsRequestDateReadable ==
false) {
536 std::cerr <<
"The default booking request and travel solution list are kept."
538 return ioBookingRequestStruct;
543 if (itTok->empty() ==
true) {
544 return ioBookingRequestStruct;
546 const std::string lRequestHourString = *itTok;
548 if (itTok->empty() ==
true) {
549 return ioBookingRequestStruct;
551 const std::string lRequestMinuteString = *itTok;
552 const bool IsRequestTimeReadable =
553 retrieveTime (lRequestHourString, lRequestMinuteString,
556 if (IsRequestTimeReadable ==
false) {
557 std::cerr <<
"The default booking request and travel solution list are kept."
559 return ioBookingRequestStruct;
564 if (itTok->empty() ==
false) {
566 boost::algorithm::to_upper (lPOS);
571 if (itTok->empty() ==
false) {
573 boost::algorithm::to_upper (lChannel);
578 if (itTok->empty() ==
false) {
580 boost::algorithm::to_upper (lTripType);
585 if (itTok->empty() ==
false) {
588 lStayDuration = boost::lexical_cast<unsigned short> (*itTok);
590 }
catch (boost::bad_lexical_cast& eCast) {
591 std::cerr <<
"The stay duration ('" << *itTok
592 <<
"') cannot be understood." << std::endl;
593 return ioBookingRequestStruct;
601 ioInteractiveTravelSolutionList.clear();
604 stdair::TravelSolutionStruct lTravelSolution;
605 std::ostringstream oStr;
607 << stdair::DEFAULT_KEY_FLD_DELIMITER
609 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
611 << stdair::DEFAULT_KEY_FLD_DELIMITER
613 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
614 << lDestinationAirport
615 << stdair::DEFAULT_KEY_FLD_DELIMITER
617 lTravelSolution.addSegment (oStr.str());
618 ioInteractiveTravelSolutionList.push_front (lTravelSolution);
621 stdair::DateTime_T lRequestDateTime (lRequestDate, lRequestTime);
622 const stdair::BookingRequestStruct& lBookingRequestStruct =
623 stdair::BookingRequestStruct(lOriginAirport,
629 stdair::DEFAULT_PARTY_SIZE,
633 stdair::FREQUENT_FLYER_MEMBER,
636 stdair::DEFAULT_VALUE_OF_TIME,
639 return lBookingRequestStruct;
646 void parseFlightDateKey (
const TokenList_T& iTokenList,
647 stdair::AirportCode_T& ioOrigin,
648 stdair::AirportCode_T& ioDestination,
649 stdair::Date_T& ioDepartureDate) {
651 TokenList_T::const_iterator itTok = iTokenList.begin();
654 if (itTok->empty() ==
true) {
656 std::cerr <<
"Wrong parameters specified. Default paramaters '"
657 << ioOrigin <<
"-" << ioDestination
658 <<
"/" << ioDepartureDate
666 boost::algorithm::to_upper (ioOrigin);
670 if (itTok->empty() ==
false) {
671 ioDestination = *itTok;
672 boost::algorithm::to_upper (ioDestination);
677 if (itTok->empty() ==
true) {
680 std::string lYearString = *itTok;
682 if (itTok->empty() ==
true) {
685 std::string lMonthString = *itTok;
687 if (itTok->empty() ==
true) {
690 std::string lDayString = *itTok;
691 const bool IsDepartureDateReadable =
692 retrieveDate (lYearString, lMonthString, lDayString,
694 if (IsDepartureDateReadable ==
false) {
695 std::cerr <<
"Default paramaters '"
696 << ioOrigin <<
"-" << ioDestination
697 <<
"/" << ioDepartureDate
706 std::string toString (
const TokenList_T& iTokenList) {
707 std::ostringstream oStr;
710 unsigned short idx = 0;
711 for (TokenList_T::const_iterator itTok = iTokenList.begin();
712 itTok != iTokenList.end(); ++itTok, ++idx) {
723 TokenList_T extractTokenList (
const TokenList_T& iTokenList,
724 const std::string& iRegularExpression) {
725 TokenList_T oTokenList;
729 const std::string lFullLine = toString (iTokenList);
732 boost::regex expression (iRegularExpression);
734 std::string::const_iterator start = lFullLine.begin();
735 std::string::const_iterator end = lFullLine.end();
737 boost::match_results<std::string::const_iterator> what;
738 boost::match_flag_type flags = boost::match_default | boost::format_sed;
739 regex_search (start, end, what, expression, flags);
743 const unsigned short lMatchSetSize = what.size();
744 for (
unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
745 const std::string lMatchedString (std::string (what[matchIdx].first,
746 what[matchIdx].second));
748 oTokenList.push_back (lMatchedString);
760 TokenList_T extractTokenListForTSAndBR (
const TokenList_T& iTokenList) {
782 const std::string lRegEx(
"^([[:alpha:]]{2,3})"
783 "[[:space:]]+([[:digit:]]{1,4})"
785 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
786 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
787 "[[:space:]]*([[:digit:]]{1,2})[[:space:]]*"
788 "[[:space:]]+([[:alpha:]]{3})"
789 "[[:space:]]+([[:alpha:]]{3})"
790 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
791 "[[:space:]]+([[:digit:]]{2,4})[/-]?"
792 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})[/-]?"
793 "[[:space:]]*([[:digit:]]{1,2})"
794 "[[:space:]]+([[:digit:]]{1,2})[:]?([[:digit:]]{1,2})"
795 "[[:space:]]+([[:alpha:]]{3})"
796 "[[:space:]]+([[:alpha:]]{2})"
797 "[[:space:]]+([[:alpha:]]{2})"
798 "[[:space:]]+([[:digit:]]{1})$");
801 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
807 TokenList_T extractTokenListForOriDestDate (
const TokenList_T& iTokenList) {
817 const std::string lRegEx(
"^([[:alpha:]]{3})"
819 "[[:space:]]*([[:alpha:]]{3})"
821 "[[:space:]]*([[:digit:]]{2,4})"
823 "[[:space:]]*([[:alpha:]]{3}|[[:digit:]]{1,2})"
825 "[[:space:]]*([[:digit:]]{1,2})$");
828 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
834 int main (
int argc,
char* argv[]) {
841 stdair::Filename_T lFareInputFilename;
844 const unsigned int lHistorySize (100);
845 const std::string lHistoryFilename (
"simfqt.hist");
846 const std::string lHistoryBackupFilename (
"simfqt.hist.bak");
849 stdair::AirportCode_T lInteractiveOrigin;
850 stdair::AirportCode_T lInteractiveDestination;
851 stdair::Date_T lInteractiveDepartureDate;
854 stdair::Filename_T lLogFilename;
857 const int lOptionParserStatus =
865 std::ofstream logOutputFile;
867 logOutputFile.open (lLogFilename.c_str());
868 logOutputFile.clear();
871 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
875 STDAIR_LOG_DEBUG (
"Welcome to SimFQT display");
878 if (isBuiltin ==
true) {
880 simfqtService.buildSampleBom();
884 simfqtService.parseAndLoad (lFareFilePath);
888 const std::string& lCSVDump = simfqtService.csvDisplay();
889 STDAIR_LOG_DEBUG (lCSVDump);
892 STDAIR_LOG_DEBUG (
"====================================================");
893 STDAIR_LOG_DEBUG (
"= Beginning of the interactive session =");
894 STDAIR_LOG_DEBUG (
"====================================================");
897 swift::SReadline lReader (lHistoryFilename, lHistorySize);
898 initReadline (lReader);
901 std::string lUserInput;
902 bool EndOfInput (
false);
903 Command_T::Type_T lCommandType (Command_T::NOP);
905 while (lCommandType != Command_T::QUIT && EndOfInput ==
false) {
906 stdair::TravelSolutionList_T lInteractiveTravelSolutionList;
912 const bool isCRSBookingRequest = !isBuiltin;
913 const stdair::BookingRequestStruct& lInteractiveBookingRequest =
914 simfqtService.buildBookingRequest (isCRSBookingRequest);
917 if (isBuiltin ==
true) {
918 lInteractiveOrigin =
"LHR";
919 lInteractiveDestination =
"SYD";
920 lInteractiveDepartureDate = stdair::Date_T(2011,06,10);
921 simfqtService.buildSampleTravelSolutions (lInteractiveTravelSolutionList);
924 lInteractiveOrigin =
"SIN";
925 lInteractiveDestination =
"BKK";
926 lInteractiveDepartureDate = stdair::Date_T(2010,01,30);
929 lBA9_SegmentDateKey (
"SQ, 970, 2010-01-30, SIN, BKK, 07:10");
932 stdair::TravelSolutionStruct lInteractiveTravelSolution;
933 lInteractiveTravelSolution.addSegment (lBA9_SegmentDateKey);
936 lInteractiveTravelSolutionList.push_back (lInteractiveTravelSolution);
940 std::ostringstream oPromptStr;
941 oPromptStr <<
"simfqt "
944 TokenList_T lTokenListByReadline;
945 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
949 lReader.SaveHistory (lHistoryBackupFilename);
952 std::cout << std::endl;
957 lCommandType = extractCommand (lTokenListByReadline);
959 switch (lCommandType) {
962 case Command_T::HELP: {
965 const stdair::TravelSolutionStruct& lInteractiveTravelSolution =
966 lInteractiveTravelSolutionList.front();
968 const stdair::SegmentPath_T& lSegmentPath =
969 lInteractiveTravelSolution.getSegmentPath();
971 const std::string& lSegmentDateKey = lSegmentPath.front();
973 const stdair::ParsedKey& lParsedKey =
974 stdair::BomKeyManager::extractKeys (lSegmentDateKey);
976 const stdair::DateTime_T& lRequestDateTime =
977 lInteractiveBookingRequest.getRequestDateTime();
978 const stdair::Time_T lRequestTime =
979 lRequestDateTime.time_of_day();
980 std::cout << std::endl;
982 std::cout <<
"Commands: " << std::endl;
983 std::cout <<
" help" <<
"\t\t" <<
"Display this help" << std::endl;
984 std::cout <<
" quit" <<
"\t\t" <<
"Quit the application" << std::endl;
985 std::cout <<
" list" <<
"\t\t"
986 <<
"List all the fare rule O&Ds and the corresponding date ranges" << std::endl;
987 std::cout <<
" display" <<
"\t"
988 <<
"Display all fare rules for an O&D and a departure date. \n" <<
"\t\t"
989 <<
"If no parameters specified or wrong list of parameters, default values are used: \n"<<
"\t\t"
990 <<
" display " << lInteractiveOrigin <<
" "
991 << lInteractiveDestination <<
" "
992 << lInteractiveDepartureDate << std::endl;
993 std::cout <<
" price" <<
"\t\t"
994 <<
"Price the travel solution corresponding to a booking request. \n" <<
"\t\t"
995 <<
"If no parameters specified or wrong list of parameters, default value are used: \n" <<
"\t\t"
997 << lParsedKey._airlineCode <<
" "
998 << lParsedKey._flightNumber <<
" "
999 << lParsedKey._departureDate <<
" "
1000 << lParsedKey._boardingPoint <<
" "
1001 << lParsedKey._offPoint <<
" "
1002 << lParsedKey._boardingTime <<
" "
1003 << lRequestDateTime.date() <<
" "
1004 << lRequestTime.hours() <<
":" << lRequestTime.minutes() <<
" "
1005 << lInteractiveBookingRequest.getPOS() <<
" "
1006 << lInteractiveBookingRequest.getBookingChannel() <<
" "
1007 << lInteractiveBookingRequest.getTripType() <<
" "
1008 << lInteractiveBookingRequest.getStayDuration() << std::endl;
1009 std::cout << std::endl;
1014 case Command_T::QUIT: {
1019 case Command_T::LIST: {
1023 const std::string& lAirportPairDateListStr =
1024 simfqtService.list ();
1026 if (lAirportPairDateListStr.empty() ==
false) {
1027 std::cout << lAirportPairDateListStr << std::endl;
1028 STDAIR_LOG_DEBUG (lAirportPairDateListStr);
1031 std::cerr <<
"There is no result for airport pairs and date ranges."
1032 <<
"Make sure your input file is not empty."
1040 case Command_T::DISPLAY: {
1043 if (lTokenListByReadline.empty() ==
true) {
1045 std::cout <<
"No parameters specified. Default paramaters '"
1046 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1047 <<
"/" << lInteractiveDepartureDate
1054 TokenList_T lTokenList =
1055 extractTokenListForOriDestDate (lTokenListByReadline);
1060 parseFlightDateKey (lTokenList, lInteractiveOrigin,
1061 lInteractiveDestination, lInteractiveDepartureDate);
1067 const bool isAirportPairDateValid =
1068 simfqtService.check (lInteractiveOrigin, lInteractiveDestination,
1069 lInteractiveDepartureDate);
1071 if (isAirportPairDateValid ==
false) {
1072 std::ostringstream oFDKStr;
1073 oFDKStr <<
"The airport pair/departure date: "
1074 << lInteractiveOrigin <<
"-" << lInteractiveDestination
1075 <<
"/" << lInteractiveDepartureDate
1076 <<
" does not correpond to any fare rule.\n"
1077 <<
"Make sure it exists with the 'list' command.";
1078 std::cout << oFDKStr.str() << std::endl;
1079 STDAIR_LOG_ERROR (oFDKStr.str());
1085 std::cout <<
"List of fare rules for "
1086 << lInteractiveOrigin <<
"-"
1087 << lInteractiveDestination <<
"/"
1088 << lInteractiveDepartureDate
1091 const std::string& lFareRuleListStr =
1092 simfqtService.csvDisplay (lInteractiveOrigin,
1093 lInteractiveDestination,
1094 lInteractiveDepartureDate);
1096 assert (lFareRuleListStr.empty() ==
false);
1097 std::cout << lFareRuleListStr << std::endl;
1098 STDAIR_LOG_DEBUG (lFareRuleListStr);
1104 case Command_T::PRICE: {
1107 if (lTokenListByReadline.empty() ==
true) {
1108 const stdair::TravelSolutionStruct& lInteractiveTravelSolution =
1109 lInteractiveTravelSolutionList.front();
1111 std::cout <<
"No parameters specified. Default booking request "
1112 <<
"and default travel solution list are kept.\n"
1113 <<
"Booking request: << "
1114 << lInteractiveBookingRequest.display() <<
" >>"
1115 <<
"\nTravel Solution: << "
1116 << lInteractiveTravelSolution.display() <<
" >>"
1117 <<
"\n********** \n"
1125 simfqtService.quotePrices (lInteractiveBookingRequest,
1126 lInteractiveTravelSolutionList);
1128 }
catch (stdair::ObjectNotFoundException& E) {
1129 std::cerr <<
"The given travel solution corresponding to the given"
1130 <<
"booking request can not be priced.\n"
1138 TokenList_T lTokenList =
1139 extractTokenListForTSAndBR (lTokenListByReadline);
1144 stdair::BookingRequestStruct lFinalBookingRequest =
1145 parseTravelSolutionAndBookingRequestKey(lTokenList,
1146 lInteractiveTravelSolutionList,
1147 lInteractiveBookingRequest);
1150 assert (lInteractiveTravelSolutionList.size() >= 1);
1151 const stdair::TravelSolutionStruct& lInteractiveTravelSolution =
1152 lInteractiveTravelSolutionList.front();
1156 std::cout <<
"Booking request: << "
1157 << lFinalBookingRequest.display() <<
" >>"
1158 <<
"\nTravel Solution: << "
1159 << lInteractiveTravelSolution.display() <<
" >>"
1160 <<
"\n********** \n"
1168 simfqtService.quotePrices (lFinalBookingRequest,
1169 lInteractiveTravelSolutionList);
1171 }
catch (stdair::ObjectNotFoundException& E) {
1172 std::cerr <<
"The given travel solution corresponding to the given"
1173 <<
"booking request can not be priced.\n"
1182 const stdair::TravelSolutionStruct& lInteractiveTravelSolution =
1183 lInteractiveTravelSolutionList.front();
1184 std::cout <<
"Travel Solution: << "
1185 << lInteractiveTravelSolution.display() <<
" >>\n"
1191 case Command_T::NOP: {
1194 case Command_T::LAST_VALUE:
1197 std::ostringstream oStr;
1198 oStr <<
"The '" << lUserInput <<
"' command is not yet understood.\n"
1199 <<
"Type help to have more information." << std::endl;
1201 STDAIR_LOG_DEBUG (oStr.str());
1202 std::cout << oStr.str() << std::endl;