Number of values in array or object
| 3262 | |
| 3263 | /// Number of values in array or object |
| 3264 | ArrayIndex Value::size() const { |
| 3265 | switch (type()) { |
| 3266 | case nullValue: |
| 3267 | case intValue: |
| 3268 | case uintValue: |
| 3269 | case realValue: |
| 3270 | case booleanValue: |
| 3271 | case stringValue: |
| 3272 | return 0; |
| 3273 | case arrayValue: // size of the array is highest index + 1 |
| 3274 | if (!value_.map_->empty()) { |
| 3275 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3276 | --itLast; |
| 3277 | return (*itLast).first.index() + 1; |
| 3278 | } |
| 3279 | return 0; |
| 3280 | case objectValue: |
| 3281 | return ArrayIndex(value_.map_->size()); |
| 3282 | } |
| 3283 | JSON_ASSERT_UNREACHABLE; |
| 3284 | return 0; // unreachable; |
| 3285 | } |
| 3286 | |
| 3287 | bool Value::empty() const { |
| 3288 | if (isNull() || isArray() || isObject()) |