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