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

Method asBool

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

Source from the content-addressed store, hash-verified

802}
803
804bool Value::asBool() const {
805 switch (type()) {
806 case booleanValue:
807 return value_.bool_;
808 case nullValue:
809 return false;
810 case intValue:
811 return value_.int_ != 0;
812 case uintValue:
813 return value_.uint_ != 0;
814 case realValue: {
815 // According to JavaScript language zero or NaN is regarded as false
816 const auto value_classification = std::fpclassify(value_.real_);
817 return value_classification != FP_ZERO && value_classification != FP_NAN;
818 }
819 default:
820 break;
821 }
822 JSON_FAIL_MESSAGE("Value is not convertible to bool.");
823}
824
825bool Value::isConvertibleTo(ValueType other) const {
826 switch (other) {

Callers 15

TraverseValueFunction · 0.80
newCharReaderMethod · 0.80
writeValueMethod · 0.80
newStreamWriterMethod · 0.80
deserializeMethod · 0.80
ConditionHelperFunction · 0.80
HandleJSONCommandFunction · 0.80
BoolFunction · 0.80
ParsePreprocessorDefineFunction · 0.80
ParseModuleFunction · 0.80
LoadMethod · 0.80
ParseExportInfoMethod · 0.80

Calls 1

typeClass · 0.50

Tested by

no test coverage detected