Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Populating protobuf fields in C++

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This method comes from c++ code generated from protobuf definitions.

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading