Number of values in array or object
| 857 | |
| 858 | /// Number of values in array or object |
| 859 | ArrayIndex Value::size() const { |
| 860 | switch (type()) { |
| 861 | case nullValue: |
| 862 | case intValue: |
| 863 | case uintValue: |
| 864 | case realValue: |
| 865 | case booleanValue: |
| 866 | case stringValue: |
| 867 | return 0; |
| 868 | case arrayValue: // size of the array is highest index + 1 |
| 869 | if (!value_.map_->empty()) { |
| 870 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 871 | --itLast; |
| 872 | return (*itLast).first.index() + 1; |
| 873 | } |
| 874 | return 0; |
| 875 | case objectValue: |
| 876 | return ArrayIndex(value_.map_->size()); |
| 877 | } |
| 878 | JSON_ASSERT_UNREACHABLE; |
| 879 | return 0; // unreachable; |
| 880 | } |
| 881 | |
| 882 | bool Value::empty() const { |
| 883 | if (isNull() || isArray() || isObject()) |
no test coverage detected