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

Method StructExprToProto

common/ast/expr_proto.cc:173–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 }
172
173 absl::Status StructExprToProto(const Expr& expr,
174 const StructExpr& struct_expr,
175 ExprProto* absl_nonnull proto) {
176 proto->Clear();
177 auto* struct_proto = proto->mutable_struct_expr();
178 proto->set_id(expr.id());
179 struct_proto->set_message_name(struct_expr.name());
180 if (!struct_expr.fields().empty()) {
181 struct_proto->mutable_entries()->Reserve(
182 static_cast<int>(struct_expr.fields().size()));
183 for (const auto& field_expr : struct_expr.fields()) {
184 auto* field_proto = struct_proto->add_entries();
185 field_proto->set_id(field_expr.id());
186 field_proto->set_field_key(field_expr.name());
187 if (field_expr.has_value()) {
188 Push(field_expr.value(), field_proto->mutable_value());
189 }
190 if (field_expr.optional()) {
191 field_proto->set_optional_entry(true);
192 }
193 }
194 }
195 return absl::OkStatus();
196 }
197
198 absl::Status MapExprToProto(const Expr& expr, const MapExpr& map_expr,
199 ExprProto* absl_nonnull proto) {

Callers

nothing calls this directly

Calls 11

mutable_valueMethod · 0.80
ClearMethod · 0.45
set_idMethod · 0.45
idMethod · 0.45
nameMethod · 0.45
emptyMethod · 0.45
ReserveMethod · 0.45
sizeMethod · 0.45
has_valueMethod · 0.45
valueMethod · 0.45
optionalMethod · 0.45

Tested by

no test coverage detected