MCPcopy Create free account
hub / github.com/ValveSoftware/Proton / isConvertibleTo

Method isConvertibleTo

vrclient_x64/jsoncpp.cpp:3281–3312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3279}
3280
3281bool Value::isConvertibleTo(ValueType other) const {
3282 switch (other) {
3283 case nullValue:
3284 return (isNumeric() && asDouble() == 0.0) ||
3285 (type_ == booleanValue && value_.bool_ == false) ||
3286 (type_ == stringValue && asString() == "") ||
3287 (type_ == arrayValue && value_.map_->size() == 0) ||
3288 (type_ == objectValue && value_.map_->size() == 0) ||
3289 type_ == nullValue;
3290 case intValue:
3291 return isInt() ||
3292 (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
3293 type_ == booleanValue || type_ == nullValue;
3294 case uintValue:
3295 return isUInt() ||
3296 (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
3297 type_ == booleanValue || type_ == nullValue;
3298 case realValue:
3299 return isNumeric() || type_ == booleanValue || type_ == nullValue;
3300 case booleanValue:
3301 return isNumeric() || type_ == booleanValue || type_ == nullValue;
3302 case stringValue:
3303 return isNumeric() || type_ == booleanValue || type_ == stringValue ||
3304 type_ == nullValue;
3305 case arrayValue:
3306 return type_ == arrayValue || type_ == nullValue;
3307 case objectValue:
3308 return type_ == objectValue || type_ == nullValue;
3309 }
3310 JSON_ASSERT_UNREACHABLE;
3311 return false;
3312}
3313
3314/// Number of values in array or object
3315ArrayIndex Value::size() const {

Callers

nothing calls this directly

Calls 2

InRangeFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected