| 3268 | } |
| 3269 | |
| 3270 | float Value::asFloat() const { |
| 3271 | switch (type_) { |
| 3272 | case intValue: |
| 3273 | return static_cast<float>(value_.int_); |
| 3274 | case uintValue: |
| 3275 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3276 | return static_cast<float>(value_.uint_); |
| 3277 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3278 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 3279 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 3280 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3281 | case realValue: |
| 3282 | return static_cast<float>(value_.real_); |
| 3283 | case nullValue: |
| 3284 | return 0.0; |
| 3285 | case booleanValue: |
| 3286 | return value_.bool_ ? 1.0f : 0.0f; |
| 3287 | default: |
| 3288 | break; |
| 3289 | } |
| 3290 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 3291 | } |
| 3292 | |
| 3293 | bool Value::asBool() const { |
| 3294 | switch (type_) { |
nothing calls this directly
no test coverage detected