7 #if BOOST_VERSION >= 104100
9 #include <boost/property_tree/ptree.hpp>
10 #include <boost/property_tree/json_parser.hpp>
11 #include <boost/regex.hpp>
12 #endif // BOOST_VERSION >= 104100
20 #if BOOST_VERSION >= 104100
21 namespace bpt = boost::property_tree;
22 #else // BOOST_VERSION >= 104100
26 #endif // BOOST_VERSION >= 104100
35 bool hasCommandBeenSuccessfullyRetrieved =
true;
46 const std::string lRegEx(
"^[{][[:space:]]*\""
47 "([[:alpha:]|_]*)\"[[:space:]]*:"
50 "([[:alnum:]|[:punct:]|[:space:]]*)"
54 boost::regex lExpression (lRegEx);
56 const std::string& lBomJSONStr = iBomJSONStr.
getString();
57 std::string::const_iterator itStart = lBomJSONStr.begin();
58 std::string::const_iterator itEnd = lBomJSONStr.end();
60 boost::match_results<std::string::const_iterator> lWhat;
61 boost::match_flag_type lFlags = boost::match_default;
63 regex_search (itStart, itEnd, lWhat, lExpression, lFlags);
67 std::vector<std::string> oTokenList;
68 for (boost::match_results<std::string::const_iterator>::const_iterator itMatch
69 = lWhat.begin(); itMatch != lWhat.end(); ++itMatch) {
71 const std::string lMatchedString (std::string (itMatch->first,
73 oTokenList.push_back (lMatchedString);
78 if (oTokenList.size() <= 1) {
79 hasCommandBeenSuccessfullyRetrieved =
false;
80 return hasCommandBeenSuccessfullyRetrieved;
83 assert (oTokenList.size() >= 2);
85 const std::string lCommandStr = oTokenList.at(1);
90 hasCommandBeenSuccessfullyRetrieved =
false;
93 return hasCommandBeenSuccessfullyRetrieved;
100 bool hasKeyBeenSuccessfullyRetrieved =
true;
102 #if BOOST_VERSION >= 104100
111 std::istringstream iStr (iBomJSONStr.
getString());
112 read_json (iStr, pt);
115 bpt::ptree::const_iterator itBegin = pt.begin();
116 const std::string lCommandName = itBegin->first;
117 std::ostringstream lPath;
118 lPath << lCommandName <<
".airline_code";
124 }
catch (bpt::ptree_error& bptException) {
125 hasKeyBeenSuccessfullyRetrieved =
false;
128 #endif // BOOST_VERSION >= 104100
129 return hasKeyBeenSuccessfullyRetrieved;
134 Date_T& ioDepartureDate) {
135 bool hasKeyBeenSuccessfullyRetrieved =
true;
137 #if BOOST_VERSION >= 104100
146 std::istringstream iStr (iBomJSONStr.
getString());
147 read_json (iStr, pt);
150 const std::string& lDepartureDateStr =
151 pt.get<std::string> (
"flight_date.departure_date");
156 boost::gregorian::from_simple_string (lDepartureDateStr);
158 }
catch (bpt::ptree_error& bptException) {
159 hasKeyBeenSuccessfullyRetrieved =
false;
161 #endif // BOOST_VERSION >= 104100
163 return hasKeyBeenSuccessfullyRetrieved;
170 bool hasKeyBeenSuccessfullyRetrieved =
true;
172 #if BOOST_VERSION >= 104100
181 std::istringstream iStr (iBomJSONStr.
getString());
182 read_json (iStr, pt);
185 bpt::ptree::const_iterator itBegin = pt.begin();
186 const std::string lCommandName = itBegin->first;
187 std::ostringstream lPath;
188 lPath << lCommandName <<
".flight_number";
194 }
catch (bpt::ptree_error& bptException) {
195 hasKeyBeenSuccessfullyRetrieved =
false;
197 #endif // BOOST_VERSION >= 104100
199 return hasKeyBeenSuccessfullyRetrieved;
206 bool hasKeyBeenSuccessfullyRetrieved =
true;
208 #if BOOST_VERSION >= 104100
217 std::istringstream iStr (iBomJSONStr.
getString());
218 read_json (iStr, pt);
221 bpt::ptree::const_iterator itBegin = pt.begin();
224 for (bpt::ptree::const_iterator itBP = ptListOfBP.begin();
225 itBP != ptListOfBP.end(); ++itBP) {
229 bpt::ptree::const_iterator itDate = ptBP.begin();
232 std::string lDateString = ptDate.data();
233 if (lDateString.empty() ==
false) {
236 boost::gregorian::from_simple_string (lDateString);
239 oBreakPointList.push_back (lBreakPoint);
242 }
catch (bpt::ptree_error& bptException) {
243 hasKeyBeenSuccessfullyRetrieved =
false;
244 }
catch (boost::bad_lexical_cast& eCast) {
245 hasKeyBeenSuccessfullyRetrieved =
false;
247 #endif // BOOST_VERSION >= 104100
249 return hasKeyBeenSuccessfullyRetrieved;
256 bool hasKeyBeenSuccessfullyRetrieved =
true;
258 #if BOOST_VERSION >= 104100
267 std::istringstream iStr (iBomJSONStr.
getString());
268 read_json (iStr, pt);
271 bpt::ptree::const_iterator itBegin = pt.begin();
272 const std::string lEventTypeName = itBegin->first;
273 std::ostringstream lPath;
274 lPath << lEventTypeName <<
".event_type";
278 const std::string lEventTypeStr = pt.get<std::string> (lPath.str());
282 const EventType lEventType (lEventTypeStr);
283 ioEventType = lEventType.getType();
285 }
catch (bpt::ptree_error& bptException) {
286 hasKeyBeenSuccessfullyRetrieved =
false;
288 hasKeyBeenSuccessfullyRetrieved =
false;
290 #endif // BOOST_VERSION >= 104100
292 return hasKeyBeenSuccessfullyRetrieved;
299 bool hasConfigBeenSuccessfullyRetrieved =
true;
301 #if BOOST_VERSION >= 104100
310 std::istringstream iStr (iBomJSONStr.
getString());
311 read_json (iStr, pt);
314 iConfigHolderStruct.
add (pt);
315 }
catch (bpt::ptree_error& bptException) {
316 hasConfigBeenSuccessfullyRetrieved =
false;
318 #endif // BOOST_VERSION >= 104100
320 return hasConfigBeenSuccessfullyRetrieved;