| 3326 | } |
| 3327 | |
| 3328 | float Value::asFloat() const { |
| 3329 | switch (type_) { |
| 3330 | case intValue: |
| 3331 | return static_cast<float>(value_.int_); |
| 3332 | case uintValue: |
| 3333 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3334 | return static_cast<float>(value_.uint_); |
| 3335 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3336 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 3337 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 3338 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3339 | case realValue: |
| 3340 | return static_cast<float>(value_.real_); |
| 3341 | case nullValue: |
| 3342 | return 0.0; |
| 3343 | case booleanValue: |
| 3344 | return value_.bool_ ? 1.0f : 0.0f; |
| 3345 | default: |
| 3346 | break; |
| 3347 | } |
| 3348 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 3349 | } |
| 3350 | |
| 3351 | bool Value::asBool() const { |
| 3352 | switch (type_) { |
nothing calls this directly
no test coverage detected