Number of values in array or object
| 3314 | |
| 3315 | /// Number of values in array or object |
| 3316 | ArrayIndex Value::size() const { |
| 3317 | switch (type_) { |
| 3318 | case nullValue: |
| 3319 | case intValue: |
| 3320 | case uintValue: |
| 3321 | case realValue: |
| 3322 | case booleanValue: |
| 3323 | case stringValue: |
| 3324 | return 0; |
| 3325 | case arrayValue: // size of the array is highest index + 1 |
| 3326 | if (!value_.map_->empty()) { |
| 3327 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3328 | --itLast; |
| 3329 | return (*itLast).first.index() + 1; |
| 3330 | } |
| 3331 | return 0; |
| 3332 | case objectValue: |
| 3333 | return ArrayIndex(value_.map_->size()); |
| 3334 | } |
| 3335 | JSON_ASSERT_UNREACHABLE; |
| 3336 | return 0; // unreachable; |
| 3337 | } |
| 3338 | |
| 3339 | bool Value::empty() const { |
| 3340 | if (isNull() || isArray() || isObject()) |
no test coverage detected