Number of values in array or object
| 2994 | |
| 2995 | /// Number of values in array or object |
| 2996 | ArrayIndex Value::size() const { |
| 2997 | switch (type_) { |
| 2998 | case nullValue: |
| 2999 | case intValue: |
| 3000 | case uintValue: |
| 3001 | case realValue: |
| 3002 | case booleanValue: |
| 3003 | case stringValue: |
| 3004 | return 0; |
| 3005 | case arrayValue: // size of the array is highest index + 1 |
| 3006 | if (!value_.map_->empty()) { |
| 3007 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 3008 | --itLast; |
| 3009 | return (*itLast).first.index() + 1; |
| 3010 | } |
| 3011 | return 0; |
| 3012 | case objectValue: |
| 3013 | return ArrayIndex(value_.map_->size()); |
| 3014 | } |
| 3015 | JSON_ASSERT_UNREACHABLE; |
| 3016 | return 0; // unreachable; |
| 3017 | } |
| 3018 | |
| 3019 | bool Value::empty() const { |
| 3020 | if (isNull() || isArray() || isObject()) |