Number of values in array or object
| 2325 | |
| 2326 | /// Number of values in array or object |
| 2327 | ArrayIndex Value::size() const { |
| 2328 | switch (type_) { |
| 2329 | case nullValue: |
| 2330 | case intValue: |
| 2331 | case uintValue: |
| 2332 | case realValue: |
| 2333 | case booleanValue: |
| 2334 | case stringValue: |
| 2335 | return 0; |
| 2336 | #ifndef JSON_VALUE_USE_INTERNAL_MAP |
| 2337 | case arrayValue: // size of the array is highest index + 1 |
| 2338 | if (!value_.map_->empty()) { |
| 2339 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 2340 | --itLast; |
| 2341 | return (*itLast).first.index() + 1; |
| 2342 | } |
| 2343 | return 0; |
| 2344 | case objectValue: |
| 2345 | return ArrayIndex(value_.map_->size()); |
| 2346 | #else |
| 2347 | case arrayValue: |
| 2348 | return Int(value_.array_->size()); |
| 2349 | case objectValue: |
| 2350 | return Int(value_.map_->size()); |
| 2351 | #endif |
| 2352 | } |
| 2353 | JSON_ASSERT_UNREACHABLE; |
| 2354 | return 0; // unreachable; |
| 2355 | } |
| 2356 | |
| 2357 | bool Value::empty() const { |
| 2358 | if (isNull() || isArray() || isObject()) |