Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006 #include <sstream>
00007
00008 #include <boost/property_tree/ptree.hpp>
00009 #include <boost/property_tree/json_parser.hpp>
00010
00011 #include <stdair/bom/BomJSONImport.hpp>
00012
00013 namespace bpt = boost::property_tree;
00014
00015 namespace stdair {
00016
00017
00018 bool BomJSONImport::jsonImportInventoryKey (const std::string& iBomTree,
00019 AirlineCode_T& ioAirlineCode) {
00020 bool hasKeyBeenSuccessfullyRetrieved = true;
00021
00022
00023 bpt::ptree pt;
00024
00025 try {
00026
00027
00028
00029
00030 std::istringstream iStr (iBomTree);
00031 read_json (iStr, pt);
00032
00033
00034
00035
00036 ioAirlineCode = pt.get<AirlineCode_T> ("flight_date.airline_code");
00037
00038 } catch (bpt::ptree_error& bptException) {
00039 hasKeyBeenSuccessfullyRetrieved = false;
00040 }
00041
00042 return hasKeyBeenSuccessfullyRetrieved;
00043 }
00044
00045
00046 bool BomJSONImport::jsonImportFlightDateKey (const std::string& iBomTree,
00047 FlightNumber_T& ioFlightNumber,
00048 Date_T& ioDepartureDate) {
00049 bool hasKeyBeenSuccessfullyRetrieved = false;
00050
00051
00052 bpt::ptree pt;
00053
00054 try {
00055
00056
00057
00058
00059 std::istringstream iStr (iBomTree);
00060 read_json (iStr, pt);
00061
00062
00063
00064 ioFlightNumber = pt.get<FlightNumber_T> ("flight_date.flight_number");
00065
00066 const std::string& lDepartureDateStr =
00067 pt.get<std::string> ("flight_date.departure_date");
00068 ioDepartureDate = boost::gregorian::from_simple_string (lDepartureDateStr);
00069
00070 } catch (bpt::ptree_error& bptException) {
00071 hasKeyBeenSuccessfullyRetrieved = false;
00072 }
00073
00074 return hasKeyBeenSuccessfullyRetrieved;
00075 }
00076
00077 }