MCPcopy Create free account
hub / github.com/apache/arrow / NonFiniteDoubleFromString

Function NonFiniteDoubleFromString

cpp/src/arrow/json/from_string.cc:218–230  ·  view source on GitHub ↗

Match the std::string_view against NaN, Inf, Infinity with optional leading minus

Source from the content-addressed store, hash-verified

216
217// Match the std::string_view against NaN, Inf, Infinity with optional leading minus
218std::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
232std::optional<double> NonFiniteDoubleFromRawToken(sj::value& json_obj) {
233 std::string_view token = json_obj.raw_json_token();

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected