Number of values in array or object
| 918 | |
| 919 | /// Number of values in array or object |
| 920 | ArrayIndex Value::size() const { |
| 921 | switch (type_) { |
| 922 | case nullValue: |
| 923 | case intValue: |
| 924 | case uintValue: |
| 925 | case realValue: |
| 926 | case booleanValue: |
| 927 | case stringValue: |
| 928 | return 0; |
| 929 | case arrayValue: // size of the array is highest index + 1 |
| 930 | if (!value_.map_->empty()) { |
| 931 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 932 | --itLast; |
| 933 | return (*itLast).first.index() + 1; |
| 934 | } |
| 935 | return 0; |
| 936 | case objectValue: |
| 937 | return ArrayIndex(value_.map_->size()); |
| 938 | } |
| 939 | JSON_ASSERT_UNREACHABLE; |
| 940 | return 0; // unreachable; |
| 941 | } |
| 942 | |
| 943 | bool Value::empty() const { |
| 944 | if (isNull() || isArray() || isObject()) |