| 3261 | } |
| 3262 | |
| 3263 | bool Value::isConvertibleTo(ValueType other) const { |
| 3264 | switch (other) { |
| 3265 | case nullValue: |
| 3266 | return (isNumeric() && asDouble() == 0.0) || |
| 3267 | (type() == booleanValue && !value_.bool_) || |
| 3268 | (type() == stringValue && asString().empty()) || |
| 3269 | (type() == arrayValue && value_.map_->empty()) || |
| 3270 | (type() == objectValue && value_.map_->empty()) || |
| 3271 | type() == nullValue; |
| 3272 | case intValue: |
| 3273 | return isInt() || |
| 3274 | (type() == realValue && InRange(value_.real_, minInt, maxInt)) || |
| 3275 | type() == booleanValue || type() == nullValue; |
| 3276 | case uintValue: |
| 3277 | return isUInt() || |
| 3278 | (type() == realValue && InRange(value_.real_, 0, maxUInt)) || |
| 3279 | type() == booleanValue || type() == nullValue; |
| 3280 | case realValue: |
| 3281 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 3282 | case booleanValue: |
| 3283 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 3284 | case stringValue: |
| 3285 | return isNumeric() || type() == booleanValue || type() == stringValue || |
| 3286 | type() == nullValue; |
| 3287 | case arrayValue: |
| 3288 | return type() == arrayValue || type() == nullValue; |
| 3289 | case objectValue: |
| 3290 | return type() == objectValue || type() == nullValue; |
| 3291 | } |
| 3292 | JSON_ASSERT_UNREACHABLE; |
| 3293 | return false; |
| 3294 | } |
| 3295 | |
| 3296 | /// Number of values in array or object |
| 3297 | ArrayIndex Value::size() const { |