MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ListFlattenImpl

Function ListFlattenImpl

extensions/lists_functions.cc:190–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190absl::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
211absl::StatusOr<Value> ListFlatten(
212 const ListValue& list, int64_t depth,

Callers 1

ListFlattenFunction · 0.85

Calls 3

AsListMethod · 0.45
has_valueMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected