Definition at line 17 of file json_dispatch.cpp.hpp.
18 {
20 if (
auto* p = val.
data.template ptr<i64>()) {
21 *out_value = *p;
23 }
24 if (
auto* p = val.
data.template ptr<bool>()) {
25 *out_value = *p ? 1 : 0;
28 }
29 if (
auto* p = val.
data.template ptr<float>()) {
30#if FL_PLATFORM_HAS_LARGE_MEMORY
31 *out_value =
static_cast<i64>(*p);
32 if (*p != static_cast<float>(*out_value)) {
35 }
36#else
37 (void)p;
38 *out_value = 0;
39 result.setError(
"float -> int not supported on Low-memory");
40#endif
42 }
43 if (
auto* p = val.
data.template ptr<fl::string>()) {
46 if (
end != p->c_str() && *
end ==
'\0') {
47 *out_value =
static_cast<i64>(parsed);
48 result.addWarning(fl::string(
"string '") + *p +
"' parsed to int " +
fl::to_string(*out_value));
49 } else {
50 result.setError(fl::string(
"cannot parse string '") + *p +
"' as integer");
51 }
53 }
54 if (val.
data.template ptr<fl::nullptr_t>()) {
55 result.setError(
"cannot convert null to integer");
57 }
58
59
60
61 result.setError(
"cannot convert array or object to integer");
62 *out_value = 0;
64}
expected< T, E > result
Alias for expected (Rust-style naming)
string to_string(T value) FL_NO_EXCEPT
long strtol(const char *str, char **endptr, int base)
References fl::end(), fl::FL_NO_EXCEPT, fl::strtol(), and fl::to_string().
Referenced by fl::detail::JsonToType< T, typename fl::enable_if< fl::is_integral< T >::value &&!fl::is_same< T, bool >::value >::type >::convert().