Number of values in array or object
| 2245 | |
| 2246 | /// Number of values in array or object |
| 2247 | ArrayIndex Value::size() const { |
| 2248 | switch (type_) { |
| 2249 | case nullValue: |
| 2250 | case intValue: |
| 2251 | case uintValue: |
| 2252 | case realValue: |
| 2253 | case booleanValue: |
| 2254 | case stringValue: |
| 2255 | return 0; |
| 2256 | #ifndef JSON_VALUE_USE_INTERNAL_MAP |
| 2257 | case arrayValue: // size of the array is highest index + 1 |
| 2258 | if (!value_.map_->empty()) { |
| 2259 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 2260 | --itLast; |
| 2261 | return (*itLast).first.index() + 1; |
| 2262 | } |
| 2263 | return 0; |
| 2264 | case objectValue: |
| 2265 | return ArrayIndex(value_.map_->size()); |
| 2266 | #else |
| 2267 | case arrayValue: |
| 2268 | return Int(value_.array_->size()); |
| 2269 | case objectValue: |
| 2270 | return Int(value_.map_->size()); |
| 2271 | #endif |
| 2272 | } |
| 2273 | JSON_ASSERT_UNREACHABLE; |
| 2274 | return 0; // unreachable; |
| 2275 | } |
| 2276 | |
| 2277 | bool Value::empty() const { |
| 2278 | if (isNull() || isArray() || isObject()) |
no test coverage detected