| 3281 | } |
| 3282 | |
| 3283 | float Value::asFloat() const { |
| 3284 | switch (type_) { |
| 3285 | case intValue: |
| 3286 | return static_cast<float>(value_.int_); |
| 3287 | case uintValue: |
| 3288 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3289 | return static_cast<float>(value_.uint_); |
| 3290 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3291 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 3292 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 3293 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3294 | case realValue: |
| 3295 | return static_cast<float>(value_.real_); |
| 3296 | case nullValue: |
| 3297 | return 0.0; |
| 3298 | case booleanValue: |
| 3299 | return value_.bool_ ? 1.0f : 0.0f; |
| 3300 | default: |
| 3301 | break; |
| 3302 | } |
| 3303 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 3304 | } |
| 3305 | |
| 3306 | bool Value::asBool() const { |
| 3307 | switch (type_) { |
nothing calls this directly
no test coverage detected