Number of values in array or object
| 953 | |
| 954 | /// Number of values in array or object |
| 955 | ArrayIndex Value::size() const { |
| 956 | switch (type()) { |
| 957 | case nullValue: |
| 958 | case intValue: |
| 959 | case uintValue: |
| 960 | case realValue: |
| 961 | case booleanValue: |
| 962 | case stringValue: |
| 963 | return 0; |
| 964 | case arrayValue: // size of the array is highest index + 1 |
| 965 | if (!value_.map_->empty()) { |
| 966 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 967 | --itLast; |
| 968 | return (*itLast).first.index() + 1; |
| 969 | } |
| 970 | return 0; |
| 971 | case objectValue: |
| 972 | return ArrayIndex(value_.map_->size()); |
| 973 | } |
| 974 | JSON_ASSERT_UNREACHABLE; |
| 975 | return 0; // unreachable; |
| 976 | } |
| 977 | |
| 978 | bool Value::empty() const { |
| 979 | if (isNull() || isArray() || isObject()) |
no test coverage detected