MCPcopy Create free account
hub / github.com/Samsung/ONE / isConvertibleTo

Method isConvertibleTo

runtime/3rdparty/jsoncpp/jsoncpp.cpp:3509–3537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3507}
3508
3509bool Value::isConvertibleTo(ValueType other) const
3510{
3511 switch (other)
3512 {
3513 case nullValue:
3514 return (isNumeric() && asDouble() == 0.0) || (type() == booleanValue && !value_.bool_) ||
3515 (type() == stringValue && asString().empty()) ||
3516 (type() == arrayValue && value_.map_->empty()) ||
3517 (type() == objectValue && value_.map_->empty()) || type() == nullValue;
3518 case intValue:
3519 return isInt() || (type() == realValue && InRange(value_.real_, minInt, maxInt)) ||
3520 type() == booleanValue || type() == nullValue;
3521 case uintValue:
3522 return isUInt() || (type() == realValue && InRange(value_.real_, 0, maxUInt)) ||
3523 type() == booleanValue || type() == nullValue;
3524 case realValue:
3525 return isNumeric() || type() == booleanValue || type() == nullValue;
3526 case booleanValue:
3527 return isNumeric() || type() == booleanValue || type() == nullValue;
3528 case stringValue:
3529 return isNumeric() || type() == booleanValue || type() == stringValue || type() == nullValue;
3530 case arrayValue:
3531 return type() == arrayValue || type() == nullValue;
3532 case objectValue:
3533 return type() == objectValue || type() == nullValue;
3534 }
3535 JSON_ASSERT_UNREACHABLE;
3536 return false;
3537}
3538
3539/// Number of values in array or object
3540ArrayIndex Value::size() const

Callers

nothing calls this directly

Calls 3

InRangeFunction · 0.85
typeFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected