Number of values in array or object
| 933 | |
| 934 | /// Number of values in array or object |
| 935 | ArrayIndex Value::size() const { |
| 936 | switch (type_) { |
| 937 | case nullValue: |
| 938 | case intValue: |
| 939 | case uintValue: |
| 940 | case realValue: |
| 941 | case booleanValue: |
| 942 | case stringValue: |
| 943 | return 0; |
| 944 | case arrayValue: // size of the array is highest index + 1 |
| 945 | if (!value_.map_->empty()) { |
| 946 | ObjectValues::const_iterator itLast = value_.map_->end(); |
| 947 | --itLast; |
| 948 | return (*itLast).first.index() + 1; |
| 949 | } |
| 950 | return 0; |
| 951 | case objectValue: |
| 952 | return ArrayIndex(value_.map_->size()); |
| 953 | } |
| 954 | JSON_ASSERT_UNREACHABLE; |
| 955 | return 0; // unreachable; |
| 956 | } |
| 957 | |
| 958 | bool Value::empty() const { |
| 959 | if (isNull() || isArray() || isObject()) |