| 3322 | } |
| 3323 | |
| 3324 | bool Value::isConvertibleTo(ValueType other) const { |
| 3325 | switch (other) { |
| 3326 | case nullValue: |
| 3327 | return (isNumeric() && asDouble() == 0.0) || |
| 3328 | (type_ == booleanValue && value_.bool_ == false) || |
| 3329 | (type_ == stringValue && asString().empty()) || |
| 3330 | (type_ == arrayValue && value_.map_->size() == 0) || |
| 3331 | (type_ == objectValue && value_.map_->size() == 0) || |
| 3332 | type_ == nullValue; |
| 3333 | case intValue: |
| 3334 | return isInt() || |
| 3335 | (type_ == realValue && InRange(value_.real_, minInt, maxInt)) || |
| 3336 | type_ == booleanValue || type_ == nullValue; |
| 3337 | case uintValue: |
| 3338 | return isUInt() || |
| 3339 | (type_ == realValue && InRange(value_.real_, 0, maxUInt)) || |
| 3340 | type_ == booleanValue || type_ == nullValue; |
| 3341 | case realValue: |
| 3342 | return isNumeric() || type_ == booleanValue || type_ == nullValue; |
| 3343 | case booleanValue: |
| 3344 | return isNumeric() || type_ == booleanValue || type_ == nullValue; |
| 3345 | case stringValue: |
| 3346 | return isNumeric() || type_ == booleanValue || type_ == stringValue || |
| 3347 | type_ == nullValue; |
| 3348 | case arrayValue: |
| 3349 | return type_ == arrayValue || type_ == nullValue; |
| 3350 | case objectValue: |
| 3351 | return type_ == objectValue || type_ == nullValue; |
| 3352 | } |
| 3353 | JSON_ASSERT_UNREACHABLE; |
| 3354 | return false; |
| 3355 | } |
| 3356 | |
| 3357 | /// Number of values in array or object |
| 3358 | ArrayIndex Value::size() const { |