Number of values in array or object
| 3295 | |
| 3296 | /// Number of values in array or object |
| 3297 | ArrayIndex Value::size() const { |
| 3298 | switch (type()) { |
| 3299 | case nullValue: |
| 3300 | case intValue: |
| 3301 | case uintValue: |
| 3302 | case realValue: |
| 3303 | case booleanValue: |
| 3304 | case stringValue: |
| 3305 | return 0; |
| 3306 | case arrayValue: // size of the array is highest index + 1 |
| 3307 | if (!value_.map_->empty()) { |
| 3308 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3309 | --itLast; |
| 3310 | return (*itLast).first.index() + 1; |
| 3311 | } |
| 3312 | return 0; |
| 3313 | case objectValue: |
| 3314 | return ArrayIndex(value_.map_->size()); |
| 3315 | } |
| 3316 | JSON_ASSERT_UNREACHABLE; |
| 3317 | return 0; // unreachable; |
| 3318 | } |
| 3319 | |
| 3320 | bool Value::empty() const { |
| 3321 | if (isNull() || isArray() || isObject()) |
no test coverage detected