MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / asBool

Method asBool

Sources/Dependencies/jsoncpp/value.cpp:900–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

898 }
899
900 bool Value::asBool() const {
901 switch (type()) {
902 case booleanValue:
903 return value_.bool_;
904 case nullValue:
905 return false;
906 case intValue:
907 return value_.int_ != 0;
908 case uintValue:
909 return value_.uint_ != 0;
910 case realValue: {
911 // According to JavaScript language zero or NaN is regarded as false
912 const auto value_classification = std::fpclassify(value_.real_);
913 return value_classification != FP_ZERO && value_classification != FP_NAN;
914 }
915 default:
916 break;
917 }
918 JSON_FAIL_MESSAGE("Value is not convertible to bool.");
919 }
920
921 bool Value::isConvertibleTo(ValueType other) const {
922 switch (other) {

Callers 3

writeValueMethod · 0.80
newStreamWriterMethod · 0.80
newCharReaderMethod · 0.80

Calls 1

typeClass · 0.85

Tested by

no test coverage detected