| 3228 | } |
| 3229 | |
| 3230 | bool Value::isConvertibleTo(ValueType other) const { |
| 3231 | switch (other) { |
| 3232 | case nullValue: |
| 3233 | return (isNumeric() && asDouble() == 0.0) || |
| 3234 | (type() == booleanValue && value_.bool_ == false) || |
| 3235 | (type() == stringValue && asString().empty()) || |
| 3236 | (type() == arrayValue && value_.map_->empty()) || |
| 3237 | (type() == objectValue && value_.map_->empty()) || |
| 3238 | type() == nullValue; |
| 3239 | case intValue: |
| 3240 | return isInt() || |
| 3241 | (type() == realValue && InRange(value_.real_, minInt, maxInt)) || |
| 3242 | type() == booleanValue || type() == nullValue; |
| 3243 | case uintValue: |
| 3244 | return isUInt() || |
| 3245 | (type() == realValue && InRange(value_.real_, 0, maxUInt)) || |
| 3246 | type() == booleanValue || type() == nullValue; |
| 3247 | case realValue: |
| 3248 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 3249 | case booleanValue: |
| 3250 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 3251 | case stringValue: |
| 3252 | return isNumeric() || type() == booleanValue || type() == stringValue || |
| 3253 | type() == nullValue; |
| 3254 | case arrayValue: |
| 3255 | return type() == arrayValue || type() == nullValue; |
| 3256 | case objectValue: |
| 3257 | return type() == objectValue || type() == nullValue; |
| 3258 | } |
| 3259 | JSON_ASSERT_UNREACHABLE; |
| 3260 | return false; |
| 3261 | } |
| 3262 | |
| 3263 | /// Number of values in array or object |
| 3264 | ArrayIndex Value::size() const { |