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

Method isConvertibleTo

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

Source from the content-addressed store, hash-verified

823}
824
825bool Value::isConvertibleTo(ValueType other) const {
826 switch (other) {
827 case nullValue:
828 return (isNumeric() && asDouble() == 0.0) ||
829 (type() == booleanValue && !value_.bool_) ||
830 (type() == stringValue && asString().empty()) ||
831 (type() == arrayValue && value_.map_->empty()) ||
832 (type() == objectValue && value_.map_->empty()) ||
833 type() == nullValue;
834 case intValue:
835 return isInt() ||
836 (type() == realValue && InRange(value_.real_, minInt, maxInt)) ||
837 type() == booleanValue || type() == nullValue;
838 case uintValue:
839 return isUInt() ||
840 (type() == realValue && InRange(value_.real_, 0, maxUInt)) ||
841 type() == booleanValue || type() == nullValue;
842 case realValue:
843 return isNumeric() || type() == booleanValue || type() == nullValue;
844 case booleanValue:
845 return isNumeric() || type() == booleanValue || type() == nullValue;
846 case stringValue:
847 return isNumeric() || type() == booleanValue || type() == stringValue ||
848 type() == nullValue;
849 case arrayValue:
850 return type() == arrayValue || type() == nullValue;
851 case objectValue:
852 return type() == objectValue || type() == nullValue;
853 }
854 JSON_ASSERT_UNREACHABLE;
855 return false;
856}
857
858/// Number of values in array or object
859ArrayIndex Value::size() const {

Callers 4

cmLoadFlagTableStringFunction · 0.80
INVALID_PRESET_NAMEFunction · 0.80
EXPECTED_TYPEFunction · 0.80
BuildDefinitionFunction · 0.80

Calls 3

InRangeFunction · 0.85
typeClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected