MCPcopy Create free account
hub / github.com/Kitware/VTK / asFloat

Method asFloat

ThirdParty/jsoncpp/vtkjsoncpp/jsoncpp.cpp:3219–3240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3217}
3218
3219float Value::asFloat() const {
3220 switch (type()) {
3221 case intValue:
3222 return static_cast<float>(value_.int_);
3223 case uintValue:
3224#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3225 return static_cast<float>(value_.uint_);
3226#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3227 // This can fail (silently?) if the value is bigger than MAX_FLOAT.
3228 return static_cast<float>(integerToDouble(value_.uint_));
3229#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
3230 case realValue:
3231 return static_cast<float>(value_.real_);
3232 case nullValue:
3233 return 0.0;
3234 case booleanValue:
3235 return value_.bool_ ? 1.0F : 0.0F;
3236 default:
3237 break;
3238 }
3239 JSON_FAIL_MESSAGE("Value is not convertible to float.");
3240}
3241
3242bool Value::asBool() const {
3243 switch (type()) {

Callers

nothing calls this directly

Calls 2

integerToDoubleFunction · 0.85
typeEnum · 0.50

Tested by

no test coverage detected