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

Method VisitCreateStruct

tools/cel_unparser.cc:310–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310absl::Status Unparser::VisitCreateStruct(const Expr::CreateStruct& expr) {
311 if (!expr.message_name().empty()) {
312 Print(expr.message_name());
313 }
314 Print(kLeftBrace);
315 for (int i = 0; i < expr.entries_size(); i++) {
316 if (i > 0) {
317 Print(kComma, kSpace);
318 }
319
320 const auto& e = expr.entries(i);
321 if (e.optional_entry()) {
322 Print(kQuestionMark);
323 }
324 switch (e.key_kind_case()) {
325 case Expr::CreateStruct::Entry::kFieldKey:
326 Print(FormatField(e.field_key()));
327 break;
328 case Expr::CreateStruct::Entry::kMapKey:
329 CEL_RETURN_IF_ERROR(Visit(e.map_key()));
330 break;
331 default:
332 return absl::InvalidArgumentError(
333 absl::StrCat("Unexpected struct: ", expr.ShortDebugString()));
334 }
335 Print(kColon, kSpace);
336 CEL_RETURN_IF_ERROR(Visit(e.value()));
337 }
338 Print(kRightBrace);
339 return absl::OkStatus();
340}
341
342absl::Status Unparser::VisitComprehension(const Expr::Comprehension& expr) {
343 bool nested = IsComplexOperator(expr.iter_range());

Callers

nothing calls this directly

Calls 4

FormatFieldFunction · 0.85
VisitFunction · 0.50
emptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected