Home > Software design >  Populating protobuf fields in C
Populating protobuf fields in C

Time:11-24

In a codebase I see some protobuf definition as

message Foo {
repeated FooData foo_data = 1;
}

Later on these protobufs are used in a C method in the following way

auto& bar = *protobuf_foo.add_foo_data();

but I don't see add_foo_data() defined anywhere. Is this a protobuf property that prepending add_ and adding parentheses at the end is some sort of reserved syntax?

CodePudding user response:

This method comes from c code generated from protobuf definitions.

https://developers.google.com/protocol-buffers/docs/reference/cpp-generated

  • Related