| 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) { |