Number of values in array or object
| 3538 | |
| 3539 | /// Number of values in array or object |
| 3540 | ArrayIndex Value::size() const |
| 3541 | { |
| 3542 | switch (type()) |
| 3543 | { |
| 3544 | case nullValue: |
| 3545 | case intValue: |
| 3546 | case uintValue: |
| 3547 | case realValue: |
| 3548 | case booleanValue: |
| 3549 | case stringValue: |
| 3550 | return 0; |
| 3551 | case arrayValue: // size of the array is highest index + 1 |
| 3552 | if (!value_.map_->empty()) |
| 3553 | { |
| 3554 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3555 | --itLast; |
| 3556 | return (*itLast).first.index() + 1; |
| 3557 | } |
| 3558 | return 0; |
| 3559 | case objectValue: |
| 3560 | return ArrayIndex(value_.map_->size()); |
| 3561 | } |
| 3562 | JSON_ASSERT_UNREACHABLE; |
| 3563 | return 0; // unreachable; |
| 3564 | } |
| 3565 | |
| 3566 | bool Value::empty() const |
| 3567 | { |
no test coverage detected