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