Number of values in array or object
| 3359 | |
| 3360 | /// Number of values in array or object |
| 3361 | ArrayIndex Value::size() const { |
| 3362 | switch (type_) { |
| 3363 | case nullValue: |
| 3364 | case intValue: |
| 3365 | case uintValue: |
| 3366 | case realValue: |
| 3367 | case booleanValue: |
| 3368 | case stringValue: |
| 3369 | return 0; |
| 3370 | case arrayValue: // size of the array is highest index + 1 |
| 3371 | if (!value_.map_->empty()) { |
| 3372 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3373 | --itLast; |
| 3374 | return (*itLast).first.index() + 1; |
| 3375 | } |
| 3376 | return 0; |
| 3377 | case objectValue: |
| 3378 | return ArrayIndex(value_.map_->size()); |
| 3379 | } |
| 3380 | JSON_ASSERT_UNREACHABLE; |
| 3381 | return 0; // unreachable; |
| 3382 | } |
| 3383 | |
| 3384 | bool Value::empty() const { |
| 3385 | if (isNull() || isArray() || isObject()) |
no test coverage detected