| 2171 | } |
| 2172 | |
| 2173 | float Value::asFloat() const { |
| 2174 | switch (type_) { |
| 2175 | case intValue: |
| 2176 | return static_cast<float>(value_.int_); |
| 2177 | case uintValue: |
| 2178 | #if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2179 | return static_cast<float>(value_.uint_); |
| 2180 | #else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2181 | return integerToDouble(value_.uint_); |
| 2182 | #endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION) |
| 2183 | case realValue: |
| 2184 | return static_cast<float>(value_.real_); |
| 2185 | case nullValue: |
| 2186 | return 0.0; |
| 2187 | case booleanValue: |
| 2188 | return value_.bool_ ? 1.0f : 0.0f; |
| 2189 | default: |
| 2190 | break; |
| 2191 | } |
| 2192 | JSON_FAIL_MESSAGE("Value is not convertible to float."); |
| 2193 | } |
| 2194 | |
| 2195 | bool Value::asBool() const { |
| 2196 | switch (type_) { |
nothing calls this directly
no test coverage detected