MCPcopy Create free account
hub / github.com/Illumina/hap.py / isConvertibleTo

Method isConvertibleTo

external/jsoncpp/jsoncpp.cpp:2293–2324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2291}
2292
2293bool Value::isConvertibleTo(ValueType other) const {
2294 switch (other) {
2295 case nullValue:
2296 return (isNumeric() && asDouble() == 0.0) ||
2297 (type_ == booleanValue && value_.bool_ == false) ||
2298 (type_ == stringValue && asString() == "") ||
2299 (type_ == arrayValue && value_.map_->size() == 0) ||
2300 (type_ == objectValue && value_.map_->size() == 0) ||
2301 type_ == nullValue;
2302 case intValue:
2303 return isInt() ||
2304 (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
2305 type_ == booleanValue || type_ == nullValue;
2306 case uintValue:
2307 return isUInt() ||
2308 (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
2309 type_ == booleanValue || type_ == nullValue;
2310 case realValue:
2311 return isNumeric() || type_ == booleanValue || type_ == nullValue;
2312 case booleanValue:
2313 return isNumeric() || type_ == booleanValue || type_ == nullValue;
2314 case stringValue:
2315 return isNumeric() || type_ == booleanValue || type_ == stringValue ||
2316 type_ == nullValue;
2317 case arrayValue:
2318 return type_ == arrayValue || type_ == nullValue;
2319 case objectValue:
2320 return type_ == objectValue || type_ == nullValue;
2321 }
2322 JSON_ASSERT_UNREACHABLE;
2323 return false;
2324}
2325
2326/// Number of values in array or object
2327ArrayIndex Value::size() const {

Callers

nothing calls this directly

Calls 2

InRangeFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected