0

I want to introduce a different method of deserialization and serialization when generating to protobuf files.

In essence, after running protoc -I=/home/ubuntu/protobuf-3.21.6/src -I=./ --cpp_out=./ addressbook.proto from the examples I would want to generate custom uint8_t* Person_PhoneNumber::_InternalSerialize functions. Those functions should change the serialization method on a condition like the size of the message itself.

Ideally I would want to keep the function signatures same and use something like protobuf plugins to achieve this. The key is for the additional functionality to be be included without changing the API.

What is the best way to extend the protobuf compiler without changing the source code?

just an
  • 33
  • 5
  • Which protocol buffers implementation are you using? Your command says `java_out`, but `uint8_t*` sounds more like C or C++. – jpa Sep 29 '22 at 04:57
  • @jpa Apologies, I have generated code for C++, the original command was `--cpp_out-./addressbook.proto`. I am using protobufs2, but ideally would like the solution to work protobuf3 as well. I have edited the original question. – just an Sep 29 '22 at 10:10

0 Answers0