| 188 | } |
| 189 | |
| 190 | absl::Status ListFlattenImpl( |
| 191 | const ListValue& list, int64_t remaining_depth, |
| 192 | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
| 193 | google::protobuf::MessageFactory* absl_nonnull message_factory, |
| 194 | google::protobuf::Arena* absl_nonnull arena, ListValueBuilder* absl_nonnull builder) { |
| 195 | CEL_ASSIGN_OR_RETURN(size_t size, list.Size()); |
| 196 | for (int64_t i = 0; i < size; ++i) { |
| 197 | CEL_ASSIGN_OR_RETURN(Value value, |
| 198 | list.Get(i, descriptor_pool, message_factory, arena)); |
| 199 | if (absl::optional<ListValue> list_value = value.AsList(); |
| 200 | list_value.has_value() && remaining_depth > 0) { |
| 201 | CEL_RETURN_IF_ERROR(ListFlattenImpl(*list_value, remaining_depth - 1, |
| 202 | descriptor_pool, message_factory, |
| 203 | arena, builder)); |
| 204 | } else { |
| 205 | CEL_RETURN_IF_ERROR(builder->Add(std::move(value))); |
| 206 | } |
| 207 | } |
| 208 | return absl::OkStatus(); |
| 209 | } |
| 210 | |
| 211 | absl::StatusOr<Value> ListFlatten( |
| 212 | const ListValue& list, int64_t depth, |
no test coverage detected