Number of values in array or object
| 3344 | |
| 3345 | /// Number of values in array or object |
| 3346 | ArrayIndex Value::size() const { |
| 3347 | switch (type_) { |
| 3348 | case nullValue: |
| 3349 | case intValue: |
| 3350 | case uintValue: |
| 3351 | case realValue: |
| 3352 | case booleanValue: |
| 3353 | case stringValue: |
| 3354 | return 0; |
| 3355 | case arrayValue: // size of the array is highest index + 1 |
| 3356 | if (!value_.map_->empty()) { |
| 3357 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3358 | --itLast; |
| 3359 | return (*itLast).first.index() + 1; |
| 3360 | } |
| 3361 | return 0; |
| 3362 | case objectValue: |
| 3363 | return ArrayIndex(value_.map_->size()); |
| 3364 | } |
| 3365 | JSON_ASSERT_UNREACHABLE; |
| 3366 | return 0; // unreachable; |
| 3367 | } |
| 3368 | |
| 3369 | bool Value::empty() const { |
| 3370 | if (isNull() || isArray() || isObject()) |
no test coverage detected