| 779 | } |
| 780 | |
| 781 | float Value::asFloat() const { |
| 782 | switch (type()) { |
| 783 | case intValue: |
| 784 | return static_cast<float>(value_.int_); |
| 785 | case uintValue: |
| 786 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 787 | return static_cast<float>(value_.uint_); |
| 788 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 789 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 790 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 791 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 792 | case realValue: |
| 793 | return static_cast<float>(value_.real_); |
| 794 | case nullValue: |
| 795 | return 0.0; |
| 796 | case booleanValue: |
| 797 | return value_.bool_ ? 1.0F : 0.0F; |
| 798 | default: |
| 799 | break; |
| 800 | } |
| 801 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 802 | } |
| 803 | |
| 804 | bool Value::asBool() const { |
| 805 | switch (type()) { |
nothing calls this directly
no test coverage detected