chromium/mojo/public/tools/bindings/generators/cpp_templates/struct_data_view_definition.tmpl

{%- for pf in struct.packed.packed_fields_in_ordinal_order %}
{%-   set kind = pf.field.kind %}
{%-   set name = pf.field.name %}

{%-   if kind|is_union_kind %}
inline void {{struct.name}}DataView::Get{{name|under_to_camel}}DataView(
    {{kind|cpp_data_view_type}}* output) {
{%-     if pf.min_version != 0 %}
  auto pointer = data_->header_.version >= {{pf.min_version}}
                 ? &data_->{{name}} : nullptr;
{%-     else %}
  auto pointer = &data_->{{name}};
{%-     endif %}
  *output = {{kind|cpp_data_view_type}}(pointer, message_);
}

{%-   elif kind|is_object_kind %}
inline void {{struct.name}}DataView::Get{{name|under_to_camel}}DataView(
    {{kind|cpp_data_view_type}}* output) {
{%-     if pf.min_version != 0 %}
  auto pointer = data_->header_.version >= {{pf.min_version}}
                 ? data_->{{name}}.Get() : nullptr;
{%-     else %}
  auto pointer = data_->{{name}}.Get();
{%-     endif %}
  *output = {{kind|cpp_data_view_type}}(pointer, message_);
}
{%-   endif %}
{%- endfor %}