Number of values in array or object
| 3402 | |
| 3403 | /// Number of values in array or object |
| 3404 | ArrayIndex Value::size() const { |
| 3405 | switch (type_) { |
| 3406 | case nullValue: |
| 3407 | case intValue: |
| 3408 | case uintValue: |
| 3409 | case realValue: |
| 3410 | case booleanValue: |
| 3411 | case stringValue: |
| 3412 | return 0; |
| 3413 | case arrayValue: // size of the array is highest index + 1 |
| 3414 | if (!value_.map_->empty()) { |
| 3415 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3416 | --itLast; |
| 3417 | return (*itLast).first.index() + 1; |
| 3418 | } |
| 3419 | return 0; |
| 3420 | case objectValue: |
| 3421 | return ArrayIndex(value_.map_->size()); |
| 3422 | } |
| 3423 | JSON_ASSERT_UNREACHABLE; |
| 3424 | return 0; // unreachable; |
| 3425 | } |
| 3426 | |
| 3427 | bool Value::empty() const { |
| 3428 | if (isNull() || isArray() || isObject()) |
no test coverage detected