MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / isConvertibleTo

Method isConvertibleTo

Source/JSON/jsoncpp.cpp:2962–2993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2960}
2961
2962bool Value::isConvertibleTo(ValueType other) const {
2963 switch (other) {
2964 case nullValue:
2965 return (isNumeric() && asDouble() == 0.0) ||
2966 (type_ == booleanValue && value_.bool_ == false) ||
2967 (type_ == stringValue && asString() == "") ||
2968 (type_ == arrayValue && value_.map_->size() == 0) ||
2969 (type_ == objectValue && value_.map_->size() == 0) ||
2970 type_ == nullValue;
2971 case intValue:
2972 return isInt() ||
2973 (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
2974 type_ == booleanValue || type_ == nullValue;
2975 case uintValue:
2976 return isUInt() ||
2977 (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
2978 type_ == booleanValue || type_ == nullValue;
2979 case realValue:
2980 return isNumeric() || type_ == booleanValue || type_ == nullValue;
2981 case booleanValue:
2982 return isNumeric() || type_ == booleanValue || type_ == nullValue;
2983 case stringValue:
2984 return isNumeric() || type_ == booleanValue || type_ == stringValue ||
2985 type_ == nullValue;
2986 case arrayValue:
2987 return type_ == arrayValue || type_ == nullValue;
2988 case objectValue:
2989 return type_ == objectValue || type_ == nullValue;
2990 }
2991 JSON_ASSERT_UNREACHABLE;
2992 return false;
2993}
2994
2995/// Number of values in array or object
2996ArrayIndex Value::size() const {

Callers

nothing calls this directly

Calls 2

InRangeFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected