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

Function SetsContains

extensions/sets_functions.cc:41–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace {
40
41absl::StatusOr<Value> SetsContains(
42 const ListValue& list, const ListValue& sublist,
43 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
44 google::protobuf::MessageFactory* absl_nonnull message_factory,
45 google::protobuf::Arena* absl_nonnull arena) {
46 bool any_missing = false;
47 CEL_RETURN_IF_ERROR(sublist.ForEach(
48 [&](const Value& sublist_element) -> absl::StatusOr<bool> {
49 CEL_ASSIGN_OR_RETURN(auto contains,
50 list.Contains(sublist_element, descriptor_pool,
51 message_factory, arena));
52
53 // Treat CEL error as missing
54 any_missing =
55 !contains->Is<BoolValue>() || !contains.GetBool().NativeValue();
56 // The first false result will terminate the loop.
57 return !any_missing;
58 },
59 descriptor_pool, message_factory, arena));
60 return BoolValue(!any_missing);
61}
62
63absl::StatusOr<Value> SetsIntersects(
64 const ListValue& list, const ListValue& sublist,

Callers 1

SetsEquivalentFunction · 0.85

Calls 4

BoolValueClass · 0.50
ForEachMethod · 0.45
NativeValueMethod · 0.45
GetBoolMethod · 0.45

Tested by

no test coverage detected