| 850 | } |
| 851 | |
| 852 | float Value::asFloat() const { |
| 853 | switch (type()) { |
| 854 | case intValue: |
| 855 | return static_cast<float>(value_.int_); |
| 856 | case uintValue: |
| 857 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 858 | return static_cast<float>(value_.uint_); |
| 859 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 860 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 861 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 862 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 863 | case realValue: |
| 864 | return static_cast<float>(value_.real_); |
| 865 | case nullValue: |
| 866 | return 0.0; |
| 867 | case booleanValue: |
| 868 | return value_.bool_ ? 1.0F : 0.0F; |
| 869 | default: |
| 870 | break; |
| 871 | } |
| 872 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 873 | } |
| 874 | |
| 875 | ErrorCode Value::get(bool& value) const { |
| 876 | switch (type()) { |
nothing calls this directly
no test coverage detected