| 823 | } |
| 824 | |
| 825 | bool Value::isConvertibleTo(ValueType other) const { |
| 826 | switch (other) { |
| 827 | case nullValue: |
| 828 | return (isNumeric() && asDouble() == 0.0) || |
| 829 | (type() == booleanValue && !value_.bool_) || |
| 830 | (type() == stringValue && asString().empty()) || |
| 831 | (type() == arrayValue && value_.map_->empty()) || |
| 832 | (type() == objectValue && value_.map_->empty()) || |
| 833 | type() == nullValue; |
| 834 | case intValue: |
| 835 | return isInt() || |
| 836 | (type() == realValue && InRange(value_.real_, minInt, maxInt)) || |
| 837 | type() == booleanValue || type() == nullValue; |
| 838 | case uintValue: |
| 839 | return isUInt() || |
| 840 | (type() == realValue && InRange(value_.real_, 0, maxUInt)) || |
| 841 | type() == booleanValue || type() == nullValue; |
| 842 | case realValue: |
| 843 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 844 | case booleanValue: |
| 845 | return isNumeric() || type() == booleanValue || type() == nullValue; |
| 846 | case stringValue: |
| 847 | return isNumeric() || type() == booleanValue || type() == stringValue || |
| 848 | type() == nullValue; |
| 849 | case arrayValue: |
| 850 | return type() == arrayValue || type() == nullValue; |
| 851 | case objectValue: |
| 852 | return type() == objectValue || type() == nullValue; |
| 853 | } |
| 854 | JSON_ASSERT_UNREACHABLE; |
| 855 | return false; |
| 856 | } |
| 857 | |
| 858 | /// Number of values in array or object |
| 859 | ArrayIndex Value::size() const { |
no test coverage detected