| 3186 | } |
| 3187 | |
| 3188 | float Value::asFloat() const { |
| 3189 | switch (type()) { |
| 3190 | case intValue: |
| 3191 | return static_cast<float>(value_.int_); |
| 3192 | case uintValue: |
| 3193 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3194 | return static_cast<float>(value_.uint_); |
| 3195 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3196 | // This can fail (silently?) if the value is bigger than MAX_FLOAT. |
| 3197 | return static_cast<float>(integerToDouble(value_.uint_)); |
| 3198 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 3199 | case realValue: |
| 3200 | return static_cast<float>(value_.real_); |
| 3201 | case nullValue: |
| 3202 | return 0.0; |
| 3203 | case booleanValue: |
| 3204 | return value_.bool_ ? 1.0f : 0.0f; |
| 3205 | default: |
| 3206 | break; |
| 3207 | } |
| 3208 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 3209 | } |
| 3210 | |
| 3211 | bool Value::asBool() const { |
| 3212 | switch (type()) { |
nothing calls this directly
no test coverage detected