Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eval/public/cel_value_clone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,10 @@ absl::StatusOr<CelValue> CelValueClone(google::protobuf::Arena* arena, CelValue
return in.Visit<absl::StatusOr<CelValue>>(CloneVisitor{.arena = arena});
}

absl::StatusOr<const CelMap*> CelMapClone(google::protobuf::Arena* arena,
const CelMap* in) {
CEL_ASSIGN_OR_RETURN(CelValue out, CloneVisitor{.arena = arena}(in));
return out.MapOrDie(); // Crash OK
}

} // namespace google::api::expr::runtime
6 changes: 6 additions & 0 deletions eval/public/cel_value_clone.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ inline absl::StatusOr<CelValue> CelValueClone(google::protobuf::Arena* arena,
return CelValueClone(arena, *in);
}

// Clones (deep copy) a CelMap such that the resulting CelMap has a lifetime
// tied to the given arena. The container implementations for the output are not
// guaranteed to be the same as the input.
absl::StatusOr<const CelMap*> CelMapClone(google::protobuf::Arena* arena,
const CelMap* in);

} // namespace google::api::expr::runtime

#endif // THIRD_PARTY_CEL_CPP_EVAL_PUBLIC_CEL_VALUE_CLONE_H_
Loading