| 3217 | } |
| 3218 | |
| 3219 | float Value::asFloat() const { |
| 3220 | switch (type()) { |
| 3221 | case intValue: |
| 3222 | return static_cast<float>(value_.int_); |
| 3223 | case uintValue: |
| 3224 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3225 | return static_cast<float>(value_.uint_); |
| 3226 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3227 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 3228 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 3229 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3230 | case realValue: |
| 3231 | return static_cast<float>(value_.real_); |
| 3232 | case nullValue: |
| 3233 | return 0.0; |
| 3234 | case booleanValue: |
| 3235 | return value_.bool_ ? 1.0F : 0.0F; |
| 3236 | default: |
| 3237 | break; |
| 3238 | } |
| 3239 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 3240 | } |
| 3241 | |
| 3242 | bool Value::asBool() const { |
| 3243 | switch (type()) { |
nothing calls this directly
no test coverage detected