| 4104 | } |
| 4105 | |
| 4106 | static bool ParseStringIntegerProperty(std::map<std::string, int> *ret, |
| 4107 | std::string *err, const detail::json &o, |
| 4108 | const std::string &property, |
| 4109 | bool required, |
| 4110 | const std::string &parent = "") { |
| 4111 | detail::json_const_iterator it; |
| 4112 | if (!detail::FindMember(o, property.c_str(), it)) { |
| 4113 | if (required) { |
| 4114 | if (err) { |
| 4115 | if (!parent.empty()) { |
| 4116 | (*err) += |
| 4117 | "'" + property + "' property is missing in " + parent + ".\n"; |
| 4118 | } else { |
| 4119 | (*err) += "'" + property + "' property is missing.\n"; |
| 4120 | } |
| 4121 | } |
| 4122 | } |
| 4123 | return false; |
| 4124 | } |
| 4125 | |
| 4126 | const detail::json &dict = detail::GetValue(it); |
| 4127 | |
| 4128 | // Make sure we are dealing with an object / dictionary. |
| 4129 | if (!detail::IsObject(dict)) { |
| 4130 | if (required) { |
| 4131 | if (err) { |
| 4132 | (*err) += "'" + property + "' property is not an object.\n"; |
| 4133 | } |
| 4134 | } |
| 4135 | return false; |
| 4136 | } |
| 4137 | |
| 4138 | ret->clear(); |
| 4139 | |
| 4140 | detail::json_const_iterator dictIt(detail::ObjectBegin(dict)); |
| 4141 | detail::json_const_iterator dictItEnd(detail::ObjectEnd(dict)); |
| 4142 | |
| 4143 | for (; dictIt != dictItEnd; ++dictIt) { |
| 4144 | int intVal; |
| 4145 | if (!detail::GetInt(detail::GetValue(dictIt), intVal)) { |
| 4146 | if (required) { |
| 4147 | if (err) { |
| 4148 | (*err) += "'" + property + "' value is not an integer type.\n"; |
| 4149 | } |
| 4150 | } |
| 4151 | return false; |
| 4152 | } |
| 4153 | |
| 4154 | // Insert into the list. |
| 4155 | (*ret)[detail::GetKey(dictIt)] = intVal; |
| 4156 | } |
| 4157 | return true; |
| 4158 | } |
| 4159 | |
| 4160 | static bool ParseJSONProperty(std::map<std::string, double> *ret, |
| 4161 | std::string *err, const detail::json &o, |
no test coverage detected