| 2919 | } |
| 2920 | |
| 2921 | float Value::asFloat() const { |
| 2922 | switch (type_) { |
| 2923 | case intValue: |
| 2924 | return static_cast<float>(value_.int_); |
| 2925 | case uintValue: |
| 2926 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2927 | return static_cast<float>(value_.uint_); |
| 2928 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2929 | return integerToDouble(value_.uint_); |
| 2930 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2931 | case realValue: |
| 2932 | return static_cast<float>(value_.real_); |
| 2933 | case nullValue: |
| 2934 | return 0.0; |
| 2935 | case booleanValue: |
| 2936 | return value_.bool_ ? 1.0f : 0.0f; |
| 2937 | default: |
| 2938 | break; |
| 2939 | } |
| 2940 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 2941 | } |
| 2942 | |
| 2943 | bool Value::asBool() const { |
| 2944 | switch (type_) { |
nothing calls this directly
no test coverage detected