12 #include <boost/program_options.hpp>
13 #include <boost/tokenizer.hpp>
14 #include <boost/regex.hpp>
15 #include <boost/swap.hpp>
16 #include <boost/algorithm/string/case_conv.hpp>
18 #include <stdair/basic/BasLogParams.hpp>
19 #include <stdair/basic/BasDBParams.hpp>
20 #include <stdair/service/Logger.hpp>
31 const std::string K_AIRINV_DEFAULT_LOG_FILENAME (
"airinv.log");
59 const bool K_AIRINV_DEFAULT_BUILT_IN_INPUT =
false;
65 const bool K_AIRINV_DEFAULT_FOR_SCHEDULE =
false;
70 const int K_AIRINV_EARLY_RETURN_STATUS = 99;
76 typedef std::vector<std::string> TokenList_T;
96 template<
class T> std::ostream&
operator<< (std::ostream& os,
97 const std::vector<T>& v) {
98 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout,
" "));
105 int readConfiguration (
int argc,
char* argv[],
106 bool& ioIsBuiltin,
bool& ioIsForSchedule,
107 stdair::Filename_T& ioInventoryFilename,
108 stdair::Filename_T& ioScheduleInputFilename,
109 stdair::Filename_T& ioODInputFilename,
110 stdair::Filename_T& ioYieldInputFilename,
111 std::string& ioLogFilename) {
113 ioIsBuiltin = K_AIRINV_DEFAULT_BUILT_IN_INPUT;
116 ioIsForSchedule = K_AIRINV_DEFAULT_FOR_SCHEDULE;
119 boost::program_options::options_description
generic (
"Generic options");
120 generic.add_options()
121 (
"prefix",
"print installation prefix")
122 (
"version,v",
"print version string")
123 (
"help,h",
"produce help message");
128 boost::program_options::options_description config (
"Configuration");
131 "The sample BOM tree can be either built-in or parsed from an input file. That latter must then be given with the -i/--inventory or -s/--schedule option")
133 "The BOM tree should be built from a schedule file (instead of from an inventory dump)")
135 boost::program_options::value< std::string >(&ioInventoryFilename)->default_value(K_AIRINV_DEFAULT_INVENTORY_FILENAME),
136 "(CSV) input file for the inventory")
138 boost::program_options::value< std::string >(&ioScheduleInputFilename)->default_value(K_AIRINV_DEFAULT_SCHEDULE_FILENAME),
139 "(CSV) input file for the schedule")
141 boost::program_options::value< std::string >(&ioODInputFilename)->default_value(K_AIRINV_DEFAULT_OND_FILENAME),
142 "(CSV) input file for the O&D")
144 boost::program_options::value< std::string >(&ioYieldInputFilename)->default_value(K_AIRINV_DEFAULT_YIELD_FILENAME),
145 "(CSV) input file for the yield")
147 boost::program_options::value< std::string >(&ioLogFilename)->default_value(K_AIRINV_DEFAULT_LOG_FILENAME),
148 "Filename for the logs")
153 boost::program_options::options_description hidden (
"Hidden options");
156 boost::program_options::value< std::vector<std::string> >(),
157 "Show the copyright (license)");
159 boost::program_options::options_description cmdline_options;
160 cmdline_options.add(
generic).add(config).add(hidden);
162 boost::program_options::options_description config_file_options;
163 config_file_options.add(config).add(hidden);
164 boost::program_options::options_description visible (
"Allowed options");
165 visible.add(
generic).add(config);
167 boost::program_options::positional_options_description p;
168 p.add (
"copyright", -1);
170 boost::program_options::variables_map vm;
171 boost::program_options::
172 store (boost::program_options::command_line_parser (argc, argv).
173 options (cmdline_options).positional(p).run(), vm);
175 std::ifstream ifs (
"airinv.cfg");
176 boost::program_options::store (parse_config_file (ifs, config_file_options),
178 boost::program_options::notify (vm);
180 if (vm.count (
"help")) {
181 std::cout << visible << std::endl;
182 return K_AIRINV_EARLY_RETURN_STATUS;
185 if (vm.count (
"version")) {
187 return K_AIRINV_EARLY_RETURN_STATUS;
190 if (vm.count (
"prefix")) {
191 std::cout <<
"Installation prefix: " <<
PREFIXDIR << std::endl;
192 return K_AIRINV_EARLY_RETURN_STATUS;
195 if (vm.count (
"builtin")) {
198 const std::string isBuiltinStr = (ioIsBuiltin ==
true)?
"yes":
"no";
199 std::cout <<
"The BOM should be built-in? " << isBuiltinStr << std::endl;
201 if (vm.count (
"for_schedule")) {
202 ioIsForSchedule =
true;
204 const std::string isForScheduleStr = (ioIsForSchedule ==
true)?
"yes":
"no";
205 std::cout <<
"The BOM should be built from schedule? " << isForScheduleStr
208 if (ioIsBuiltin ==
false) {
210 if (ioIsForSchedule ==
false) {
212 if (vm.count (
"inventory")) {
213 ioInventoryFilename = vm[
"inventory"].as< std::string >();
214 std::cout <<
"Input inventory filename is: " << ioInventoryFilename
220 std::cerr <<
"Either one among the -b/--builtin, -i/--inventory or "
221 <<
" -f/--for_schedule and -s/--schedule options "
222 <<
"must be specified" << std::endl;
227 if (vm.count (
"schedule")) {
228 ioScheduleInputFilename = vm[
"schedule"].as< std::string >();
229 std::cout <<
"Input schedule filename is: " << ioScheduleInputFilename
235 std::cerr <<
"Either one among the -b/--builtin, -i/--inventory or "
236 <<
" -f/--for_schedule and -s/--schedule options "
237 <<
"must be specified" << std::endl;
240 if (vm.count (
"ond")) {
241 ioODInputFilename = vm[
"ond"].as< std::string >();
242 std::cout <<
"Input O&D filename is: " << ioODInputFilename << std::endl;
245 if (vm.count (
"yield")) {
246 ioYieldInputFilename = vm[
"yield"].as< std::string >();
247 std::cout <<
"Input yield filename is: " << ioYieldInputFilename << std::endl;
252 if (vm.count (
"log")) {
253 ioLogFilename = vm[
"log"].as< std::string >();
254 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
264 std::vector<std::string> Completers;
269 Completers.push_back (
"help");
270 Completers.push_back (
"list %airline_code %flight_number");
271 Completers.push_back (
"select %airline_code %flight_number %flight_date");
272 Completers.push_back (
"display");
273 Completers.push_back (
"sell %booking_class %party_size %origin %destination");
274 Completers.push_back (
"quit");
283 Command_T::Type_T extractCommand (TokenList_T& ioTokenList) {
284 Command_T::Type_T oCommandType = Command_T::LAST_VALUE;
287 if (ioTokenList.empty() ==
false) {
288 TokenList_T::iterator itTok = ioTokenList.begin();
289 std::string lCommand (*itTok);
290 boost::algorithm::to_lower (lCommand);
292 if (lCommand ==
"help") {
293 oCommandType = Command_T::HELP;
295 }
else if (lCommand ==
"list") {
296 oCommandType = Command_T::LIST;
298 }
else if (lCommand ==
"display") {
299 oCommandType = Command_T::DISPLAY;
301 }
else if (lCommand ==
"select") {
302 oCommandType = Command_T::SELECT;
304 }
else if (lCommand ==
"sell") {
305 oCommandType = Command_T::SELL;
307 }
else if (lCommand ==
"quit") {
308 oCommandType = Command_T::QUIT;
313 ioTokenList.erase (itTok);
316 oCommandType = Command_T::NOP;
323 void parseFlightKey (
const TokenList_T& iTokenList,
324 stdair::AirlineCode_T& ioAirlineCode,
325 stdair::FlightNumber_T& ioFlightNumber) {
327 if (iTokenList.empty() ==
false) {
330 TokenList_T::const_iterator itTok = iTokenList.begin();
331 if (itTok->empty() ==
false) {
332 ioAirlineCode = *itTok;
333 boost::algorithm::to_upper (ioAirlineCode);
338 if (itTok != iTokenList.end()) {
340 if (itTok->empty() ==
false) {
343 ioFlightNumber = boost::lexical_cast<stdair::FlightNumber_T> (*itTok);
345 }
catch (boost::bad_lexical_cast& eCast) {
346 std::cerr <<
"The flight number ('" << *itTok
347 <<
"') cannot be understood. "
348 <<
"The default value (all) is kept."
361 void parseFlightDateKey (
const TokenList_T& iTokenList,
362 stdair::AirlineCode_T& ioAirlineCode,
363 stdair::FlightNumber_T& ioFlightNumber,
364 stdair::Date_T& ioDepartureDate) {
366 const std::string kMonthStr[12] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
367 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
369 unsigned short ioDepartureDateYear = ioDepartureDate.year();
370 unsigned short ioDepartureDateMonth = ioDepartureDate.month();
371 std::string ioDepartureDateMonthStr = kMonthStr[ioDepartureDateMonth-1];
372 unsigned short ioDepartureDateDay = ioDepartureDate.day();
375 if (iTokenList.empty() ==
false) {
378 TokenList_T::const_iterator itTok = iTokenList.begin();
379 if (itTok->empty() ==
false) {
380 ioAirlineCode = *itTok;
381 boost::algorithm::to_upper (ioAirlineCode);
386 if (itTok != iTokenList.end()) {
388 if (itTok->empty() ==
false) {
391 ioFlightNumber = boost::lexical_cast<stdair::FlightNumber_T> (*itTok);
393 }
catch (boost::bad_lexical_cast& eCast) {
394 std::cerr <<
"The flight number ('" << *itTok
395 <<
"') cannot be understood. "
396 <<
"The default value (all) is kept."
408 if (itTok != iTokenList.end()) {
410 if (itTok->empty() ==
false) {
413 ioDepartureDateYear = boost::lexical_cast<
unsigned short> (*itTok);
414 if (ioDepartureDateYear < 100) {
415 ioDepartureDateYear += 2000;
418 }
catch (boost::bad_lexical_cast& eCast) {
419 std::cerr <<
"The year of the flight departure date ('" << *itTok
420 <<
"') cannot be understood. The default value ("
421 << ioDepartureDateYear <<
") is kept. " << std::endl;
432 if (itTok != iTokenList.end()) {
434 if (itTok->empty() ==
false) {
437 const boost::regex lMonthRegex (
"^(\\d{1,2})$");
438 const bool isMonthANumber = regex_match (*itTok, lMonthRegex);
440 if (isMonthANumber ==
true) {
441 const unsigned short lMonth =
442 boost::lexical_cast<
unsigned short> (*itTok);
444 throw boost::bad_lexical_cast();
446 ioDepartureDateMonthStr = kMonthStr[lMonth-1];
449 const std::string lMonthStr (*itTok);
450 if (lMonthStr.size() < 3) {
451 throw boost::bad_lexical_cast();
453 std::string lMonthStr1 (lMonthStr.substr (0, 1));
454 boost::algorithm::to_upper (lMonthStr1);
455 std::string lMonthStr23 (lMonthStr.substr (1, 2));
456 boost::algorithm::to_lower (lMonthStr23);
457 ioDepartureDateMonthStr = lMonthStr1 + lMonthStr23;
460 }
catch (boost::bad_lexical_cast& eCast) {
461 std::cerr <<
"The month of the flight departure date ('" << *itTok
462 <<
"') cannot be understood. The default value ("
463 << ioDepartureDateMonthStr <<
") is kept. " << std::endl;
474 if (itTok != iTokenList.end()) {
476 if (itTok->empty() ==
false) {
479 ioDepartureDateDay = boost::lexical_cast<
unsigned short> (*itTok);
481 }
catch (boost::bad_lexical_cast& eCast) {
482 std::cerr <<
"The day of the flight departure date ('" << *itTok
483 <<
"') cannot be understood. The default value ("
484 << ioDepartureDateDay <<
") is kept. " << std::endl;
494 std::ostringstream lDepartureDateStr;
495 lDepartureDateStr << ioDepartureDateYear <<
"-" << ioDepartureDateMonthStr
496 <<
"-" << ioDepartureDateDay;
501 boost::gregorian::from_simple_string (lDepartureDateStr.str());
503 }
catch (boost::gregorian::bad_month& eCast) {
504 std::cerr <<
"The flight departure date ('" << lDepartureDateStr.str()
505 <<
"') cannot be understood. The default value ("
506 << ioDepartureDate <<
") is kept. " << std::endl;
514 void parseBookingClassKey (
const TokenList_T& iTokenList,
515 stdair::ClassCode_T& ioBookingClass,
516 stdair::PartySize_T& ioPartySize,
517 stdair::AirportCode_T& ioOrigin,
518 stdair::AirportCode_T& ioDestination) {
520 if (iTokenList.empty() ==
false) {
523 TokenList_T::const_iterator itTok = iTokenList.begin();
524 if (itTok->empty() ==
false) {
525 ioBookingClass = *itTok;
526 boost::algorithm::to_upper (ioBookingClass);
531 if (itTok != iTokenList.end()) {
533 if (itTok->empty() ==
false) {
536 ioPartySize = boost::lexical_cast<stdair::PartySize_T> (*itTok);
538 }
catch (boost::bad_lexical_cast& eCast) {
539 std::cerr <<
"The party size ('" << *itTok
540 <<
"') cannot be understood. The default value ("
541 << ioPartySize <<
") is kept." << std::endl;
552 if (itTok != iTokenList.end()) {
554 if (itTok->empty() ==
false) {
556 boost::algorithm::to_upper (ioOrigin);
565 if (itTok != iTokenList.end()) {
567 if (itTok->empty() ==
false) {
568 ioDestination = *itTok;
569 boost::algorithm::to_upper (ioDestination);
579 std::string toString (
const TokenList_T& iTokenList) {
580 std::ostringstream oStr;
583 unsigned short idx = 0;
584 for (TokenList_T::const_iterator itTok = iTokenList.begin();
585 itTok != iTokenList.end(); ++itTok, ++idx) {
596 TokenList_T extractTokenList (
const TokenList_T& iTokenList,
597 const std::string& iRegularExpression) {
598 TokenList_T oTokenList;
602 const std::string lFullLine = toString (iTokenList);
605 boost::regex expression (iRegularExpression);
607 std::string::const_iterator start = lFullLine.begin();
608 std::string::const_iterator end = lFullLine.end();
610 boost::match_results<std::string::const_iterator> what;
611 boost::match_flag_type flags = boost::match_default | boost::format_sed;
612 regex_search (start, end, what, expression, flags);
616 const unsigned short lMatchSetSize = what.size();
617 for (
unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
618 const std::string lMatchedString (std::string (what[matchIdx].first,
619 what[matchIdx].second));
621 oTokenList.push_back (lMatchedString);
632 TokenList_T extractTokenListForFlight (
const TokenList_T& iTokenList) {
639 const std::string lRegEx (
"^([[:alpha:]]{2,3})?"
640 "[[:space:]]*([[:digit:]]{1,4})?$");
643 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
648 TokenList_T extractTokenListForFlightDate (
const TokenList_T& iTokenList) {
659 const std::string lRegEx(
"^([[:alpha:]]{2,3})?"
660 "[[:space:]]*([[:digit:]]{1,4})?"
662 "([[:digit:]]{2,4})?[/-]?[[:space:]]*"
663 "([[:alpha:]]{3}|[[:digit:]]{1,2})?[/-]?[[:space:]]*"
664 "([[:digit:]]{1,2})?$");
667 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
672 TokenList_T extractTokenListForClass (
const TokenList_T& iTokenList) {
681 const std::string lRegEx (
"^([[:alpha:]])?"
682 "[[:space:]]*([[:digit:]]{1,3})?"
683 "[[:space:]]*([[:alpha:]]{3})?"
684 "[[:space:]]*([[:alpha:]]{3})?$");
687 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
693 int main (
int argc,
char* argv[]) {
701 stdair::Filename_T lInventoryFilename;
702 stdair::Filename_T lScheduleInputFilename;
703 stdair::Filename_T lODInputFilename;
704 stdair::Filename_T lYieldInputFilename;
707 const unsigned int lHistorySize (100);
708 const std::string lHistoryFilename (
"airinv.hist");
709 const std::string lHistoryBackupFilename (
"airinv.hist.bak");
712 stdair::AirlineCode_T lLastInteractiveAirlineCode;
713 stdair::FlightNumber_T lLastInteractiveFlightNumber;
714 stdair::Date_T lLastInteractiveDate;
715 stdair::AirlineCode_T lInteractiveAirlineCode;
716 stdair::FlightNumber_T lInteractiveFlightNumber;
717 stdair::Date_T lInteractiveDate;
718 stdair::AirportCode_T lInteractiveOrigin;
719 stdair::AirportCode_T lInteractiveDestination;
720 stdair::ClassCode_T lInteractiveBookingClass;
721 stdair::PartySize_T lInteractivePartySize;
724 std::string lSegmentDateKey;
727 stdair::Filename_T lLogFilename;
730 const int lOptionParserStatus =
731 readConfiguration (argc, argv, isBuiltin, isForSchedule, lInventoryFilename,
732 lScheduleInputFilename, lODInputFilename,
733 lYieldInputFilename, lLogFilename);
735 if (lOptionParserStatus == K_AIRINV_EARLY_RETURN_STATUS) {
740 std::ofstream logOutputFile;
742 logOutputFile.open (lLogFilename.c_str());
743 logOutputFile.clear();
746 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);
750 STDAIR_LOG_DEBUG (
"Welcome to AirInv");
753 if (isBuiltin ==
true) {
756 airinvService.buildSampleBom();
759 lInteractiveAirlineCode =
"BA";
760 lInteractiveFlightNumber = 9;
761 lInteractiveDate = stdair::Date_T (2011, 06, 10);
762 lInteractiveBookingClass =
"Q";
763 lInteractivePartySize = 2;
764 lInteractiveOrigin =
"LHR";
765 lInteractiveDestination =
"SYD";
768 if (isForSchedule ==
true) {
770 AIRRAC::YieldFilePath lYieldFilePath (lYieldInputFilename);
771 airinvService.parseAndLoad (lScheduleInputFilename, lODInputFilename,
775 lInteractiveAirlineCode =
"SQ";
776 lInteractiveFlightNumber = 11;
777 lInteractiveDate = stdair::Date_T (2010, 01, 15);
778 lInteractiveBookingClass =
"Y";
779 lInteractivePartySize = 2;
780 lInteractiveOrigin =
"SIN";
781 lInteractiveDestination =
"BKK";
785 airinvService.parseAndLoad (lInventoryFilename);
788 lInteractiveAirlineCode =
"SV";
789 lInteractiveFlightNumber = 5;
790 lInteractiveDate = stdair::Date_T (2010, 03, 11);
791 lInteractiveBookingClass =
"Y";
792 lInteractivePartySize = 2;
793 lInteractiveOrigin =
"KBP";
794 lInteractiveDestination =
"JFK";
799 lLastInteractiveAirlineCode = lInteractiveAirlineCode;
800 lLastInteractiveFlightNumber = lInteractiveFlightNumber;
801 lLastInteractiveDate = lInteractiveDate;
804 STDAIR_LOG_DEBUG (
"====================================================");
805 STDAIR_LOG_DEBUG (
"= Beginning of the interactive session =");
806 STDAIR_LOG_DEBUG (
"====================================================");
810 initReadline (lReader);
813 std::string lUserInput;
814 bool EndOfInput (
false);
815 Command_T::Type_T lCommandType (Command_T::NOP);
817 while (lCommandType != Command_T::QUIT && EndOfInput ==
false) {
819 std::ostringstream oPromptStr;
820 oPromptStr <<
"airinv "
821 << lInteractiveAirlineCode << lInteractiveFlightNumber
822 <<
" / " << lInteractiveDate
825 TokenList_T lTokenListByReadline;
826 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
830 lReader.SaveHistory (lHistoryBackupFilename);
834 std::cout << std::endl;
839 lCommandType = extractCommand (lTokenListByReadline);
841 switch (lCommandType) {
844 case Command_T::HELP: {
845 std::cout << std::endl;
846 std::cout <<
"Commands: " << std::endl;
847 std::cout <<
" help" <<
"\t\t" <<
"Display this help" << std::endl;
848 std::cout <<
" quit" <<
"\t\t" <<
"Quit the application" << std::endl;
849 std::cout <<
" list" <<
"\t\t"
850 <<
"List airlines, flights and departure dates" << std::endl;
851 std::cout <<
" select" <<
"\t\t"
852 <<
"Select a flight-date to become the current one"
854 std::cout <<
" display" <<
"\t"
855 <<
"Display the current flight-date" << std::endl;
856 std::cout <<
" sell" <<
"\t\t"
857 <<
"Make a booking on the current flight-date" << std::endl;
858 std::cout << std::endl;
863 case Command_T::QUIT: {
868 case Command_T::LIST: {
870 TokenList_T lTokenList = extractTokenListForFlight (lTokenListByReadline);
872 stdair::AirlineCode_T lAirlineCode (
"all");
873 stdair::FlightNumber_T lFlightNumber (0);
876 parseFlightKey (lTokenList, lAirlineCode, lFlightNumber);
879 const std::string lFlightNumberStr = (lFlightNumber ==0)?
" (all)":
"";
880 std::cout <<
"List of flights for "
881 << lAirlineCode <<
" " << lFlightNumber << lFlightNumberStr
885 const std::string& lFlightDateListStr =
886 airinvService.list (lAirlineCode, lFlightNumber);
888 if (lFlightDateListStr.empty() ==
false) {
889 std::cout << lFlightDateListStr << std::endl;
890 STDAIR_LOG_DEBUG (lFlightDateListStr);
893 std::cerr <<
"There is no result for "
894 << lAirlineCode <<
" " << lFlightNumber << lFlightNumberStr
895 <<
". Just type the list command without any parameter "
896 <<
"to see the flight-dates for all the airlines and for all "
897 <<
"the flight numbers."
905 case Command_T::SELECT: {
907 TokenList_T lTokenList =
908 extractTokenListForFlightDate (lTokenListByReadline);
911 if (lTokenList.empty() ==
false) {
913 TokenList_T::const_iterator itTok = lTokenList.begin();
918 boost::swap (lInteractiveAirlineCode, lLastInteractiveAirlineCode);
919 boost::swap (lInteractiveFlightNumber, lLastInteractiveFlightNumber);
920 boost::swap (lInteractiveDate, lLastInteractiveDate);
928 parseFlightDateKey (lTokenList, lInteractiveAirlineCode,
929 lInteractiveFlightNumber, lInteractiveDate);
932 const bool isFlightDateValid =
933 airinvService.check (lInteractiveAirlineCode, lInteractiveFlightNumber,
935 if (isFlightDateValid ==
false) {
936 std::ostringstream oFDKStr;
937 oFDKStr <<
"The " << lInteractiveAirlineCode
938 << lInteractiveFlightNumber <<
" / " << lInteractiveDate
939 <<
" flight-date is not valid. Make sure it exists (e.g.,"
940 <<
" with the list command). The current flight-date is kept"
942 std::cout << oFDKStr.str() << std::endl;
943 STDAIR_LOG_ERROR (oFDKStr.str());
946 lInteractiveAirlineCode = lLastInteractiveAirlineCode;
947 lInteractiveFlightNumber = lLastInteractiveFlightNumber;
948 lInteractiveDate = lLastInteractiveDate;
954 std::ostringstream oFDKStr;
955 oFDKStr <<
"Selected the " << lInteractiveAirlineCode
956 << lInteractiveFlightNumber <<
" / " << lInteractiveDate
958 std::cout << oFDKStr.str() << std::endl;
959 STDAIR_LOG_DEBUG (oFDKStr.str());
962 lLastInteractiveAirlineCode = lInteractiveAirlineCode;
963 lLastInteractiveFlightNumber = lInteractiveFlightNumber;
964 lLastInteractiveDate = lInteractiveDate;
970 case Command_T::DISPLAY: {
972 const std::string& lCSVFlightDateDump =
973 airinvService.csvDisplay (lInteractiveAirlineCode,
974 lInteractiveFlightNumber, lInteractiveDate);
975 std::cout << lCSVFlightDateDump << std::endl;
976 STDAIR_LOG_DEBUG (lCSVFlightDateDump);
982 case Command_T::SELL: {
984 TokenList_T lTokenList = extractTokenListForClass (lTokenListByReadline);
988 parseBookingClassKey (lTokenList, lInteractiveBookingClass,
989 lInteractivePartySize,
990 lInteractiveOrigin, lInteractiveDestination);
993 const std::string& lCSVFlightDateDumpBefore =
994 airinvService.csvDisplay (lInteractiveAirlineCode,
995 lInteractiveFlightNumber, lInteractiveDate);
997 STDAIR_LOG_DEBUG (lCSVFlightDateDumpBefore);
1000 std::ostringstream oSDKStr;
1001 oSDKStr << lInteractiveAirlineCode <<
","
1002 << lInteractiveFlightNumber <<
","
1003 << lInteractiveDate <<
","
1004 << lInteractiveOrigin <<
"," << lInteractiveDestination;
1005 const std::string lSegmentDateKey (oSDKStr.str());
1008 const bool isSellSuccessful =
1009 airinvService.sell (lSegmentDateKey,
1010 lInteractiveBookingClass, lInteractivePartySize);
1013 const std::string isSellSuccessfulStr =
1014 (isSellSuccessful ==
true)?
"Yes":
"No";
1015 std::ostringstream oSaleStr;
1016 oSaleStr <<
"Sale ('" << lSegmentDateKey <<
"', "
1017 << lInteractiveBookingClass <<
": " << lInteractivePartySize
1018 <<
") successful? " << isSellSuccessfulStr;
1019 std::cout << oSaleStr.str() << std::endl;
1022 STDAIR_LOG_DEBUG (oSaleStr.str());
1025 const std::string& lCSVFlightDateDumpAfter =
1026 airinvService.csvDisplay (lInteractiveAirlineCode,
1027 lInteractiveFlightNumber, lInteractiveDate);
1029 STDAIR_LOG_DEBUG (lCSVFlightDateDumpAfter);
1035 case Command_T::NOP: {
1039 case Command_T::LAST_VALUE:
1042 std::ostringstream oStr;
1043 oStr <<
"That command is not yet understood: '" << lUserInput
1044 <<
"' => " << lTokenListByReadline;
1045 STDAIR_LOG_DEBUG (oStr.str());
1046 std::cout << oStr.str() << std::endl;
1052 STDAIR_LOG_DEBUG (
"End of the session. Exiting.");
1053 std::cout <<
"End of the session. Exiting." << std::endl;
1056 logOutputFile.close();