Go to the documentation of this file.00001
00002
00003
00004
00005 #include <string>
00006 #include <vector>
00007
00008 namespace airsched {
00009
00011 struct Place_T {
00012
00013 std::string _name;
00014 std::string _code;
00016 Place_T () : _name (""), _code ("") {}
00017
00018 void display() const {
00019 std::cout << "Place: " << _name << " (" << _code << ")" << std::endl;
00020 }
00021 };
00022
00024 typedef std::vector<Place_T> PlaceList_T;
00025
00027 struct Date_T {
00028
00029 boost::gregorian::date _date;
00030 unsigned int _reldays;
00031 unsigned int _day;
00032 unsigned int _month;
00033 unsigned int _year;
00035 Date_T () : _reldays (14), _day(1), _month(1), _year(1970) {}
00036
00037 void display() const {
00038 std::cout << "Date: " << _date << " (" << _day << "/" << _month
00039 << "/" << _year << "), i.e. in " << _reldays << " days"
00040 << std::endl;
00041 }
00043 boost::gregorian::date getDate() const {
00044 return boost::gregorian::date (_year, _month, _day);
00045 }
00046 };
00047
00049 typedef std::vector<Date_T> DateList_T;
00050
00052 struct Airline_T {
00053
00054 bool _isPreferred;
00055 std::string _name;
00056 std::string _code;
00058 Airline_T () : _isPreferred (true), _name(""), _code("") {}
00059
00060 void display() const {
00061 const std::string isPreferredStr = (_isPreferred)?"+":"-";
00062 std::cout << "Airline: " << isPreferredStr << _name << " (" << _code << ")"
00063 << std::endl;
00064 }
00065 };
00066
00068 typedef std::vector<Airline_T> AirlineList_T;
00069
00071 struct Passenger_T {
00072
00073 typedef enum { ADULT = 0, CHILD, PET, LAST_VALUE } PassengerType_T;
00074 static const std::string _labels[LAST_VALUE];
00075 PassengerType_T _type;
00076 unsigned short _number;
00078 Passenger_T () : _type(ADULT), _number(1) {}
00079
00080 void display() const {
00081 std::cout << "Passenger: " << _number << " (" << _labels[_type] << ")"
00082 << std::endl;
00083 }
00084 };
00085
00087 const std::string Passenger_T::_labels[Passenger_T::LAST_VALUE] =
00088 { "Adult", "Child", "Pet" };
00089
00091 typedef std::vector<Passenger_T> PassengerList_T;
00092
00094 struct SearchString_T {
00095
00096 PlaceList_T _placeList;
00097 DateList_T _dateList;
00098 AirlineList_T _airlineList;
00099 PassengerList_T _passengerList;
00100
00102 SearchString_T () {}
00103
00104
00105 void display() const {
00106 std::cout << std::endl;
00107
00108 for (PlaceList_T::const_iterator itPlace = _placeList.begin();
00109 itPlace != _placeList.end(); ++itPlace) {
00110 const Place_T& lPlace = *itPlace;
00111 lPlace.display();
00112 }
00113
00114 for (DateList_T::const_iterator itDate = _dateList.begin();
00115 itDate != _dateList.end(); ++itDate) {
00116 const Date_T& lDate = *itDate;
00117 lDate.display();
00118 }
00119
00120 for (AirlineList_T::const_iterator itAirline = _airlineList.begin();
00121 itAirline != _airlineList.end(); ++itAirline) {
00122 const Airline_T& lAirline = *itAirline;
00123 lAirline.display();
00124 }
00125
00126 for (PassengerList_T::const_iterator itPassenger = _passengerList.begin();
00127 itPassenger != _passengerList.end(); ++itPassenger) {
00128 const Passenger_T& lPassenger = *itPassenger;
00129 lPassenger.display();
00130 }
00131
00132 std::cout << "-- Staging --" << std::endl;
00133 _tmpPlace.display();
00134 }
00135
00136
00137 Place_T _tmpPlace;
00138 Date_T _tmpDate;
00139 Airline_T _tmpAirline;
00140 Passenger_T _tmpPassenger;
00141 };
00142
00144
00145
00146
00148
00174 SearchString_T parseBookingRequest (const std::string& iSearchString);
00175
00176 }