Match the std::string_view against NaN, Inf, Infinity with optional leading minus
| 216 | |
| 217 | // Match the std::string_view against NaN, Inf, Infinity with optional leading minus |
| 218 | std::optional<double> NonFiniteDoubleFromString(std::string_view str) { |
| 219 | if (str == "NaN") { |
| 220 | return std::numeric_limits<double>::quiet_NaN(); |
| 221 | } else if (str == "-NaN") { |
| 222 | return -std::numeric_limits<double>::quiet_NaN(); |
| 223 | } else if (str == "Inf" || str == "Infinity") { |
| 224 | return std::numeric_limits<double>::infinity(); |
| 225 | } else if (str == "-Inf" || str == "-Infinity") { |
| 226 | return -std::numeric_limits<double>::infinity(); |
| 227 | } else { |
| 228 | return std::nullopt; |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | std::optional<double> NonFiniteDoubleFromRawToken(sj::value& json_obj) { |
| 233 | std::string_view token = json_obj.raw_json_token(); |
no outgoing calls
no test coverage detected