MCPcopy Create free account
hub / github.com/Kitware/CMake / asDouble

Method asDouble

Utilities/cmjsoncpp/src/lib_json/json_value.cpp:759–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757}
758
759double Value::asDouble() const {
760 switch (type()) {
761 case intValue:
762 return static_cast<double>(value_.int_);
763 case uintValue:
764#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
765 return static_cast<double>(value_.uint_);
766#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
767 return integerToDouble(value_.uint_);
768#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
769 case realValue:
770 return value_.real_;
771 case nullValue:
772 return 0.0;
773 case booleanValue:
774 return value_.bool_ ? 1.0 : 0.0;
775 default:
776 break;
777 }
778 JSON_FAIL_MESSAGE("Value is not convertible to double.");
779}
780
781float Value::asFloat() const {
782 switch (type()) {

Callers 3

TraverseValueFunction · 0.80
writeValueMethod · 0.80
deserializeMethod · 0.80

Calls 2

integerToDoubleFunction · 0.85
typeClass · 0.50

Tested by

no test coverage detected