Closed piperoc closed 6 months ago
I simplified the code to show my issue.
Here's the codegen cpp file from the proto above:
And this is the main program to test encode/decode and get the error:
I look at the generated code and it seems to have all the necessary code to deal with the std::vector<SimpleMessage>
.
Unlike the tutorial example, I would not know how to add those
EASYPB_MainMessage_EXTRA_FIELDS
EASYPB_MainMessage_EXTRA_ENCODING
EASYPB_MainMessage_EXTRA_DECODING
since the generated code already has the expected lines...
Thanks for clarifying.
That's easy - you should pass std::string to the decoder, since "char*" type doesn't carry the string size information. Change the decoding call to
easypb::decode
(enc);
All those EXTRA macros can be used to manually handle complex cases where Codegen can't auto-generate the code. It's not the case here. Of course, I will document these macros, today Codegen docs are almost non-existent.
I created a simple testing solution.
My proto file looks like this:
The codegen processes it without any problem and eventually translated the
repeated SimpleMessage
intostd::vector<SimpleMessage>
as you would expect.My code sends and receives through a TCP socket.
I can encode/decode SimpleMessage object without any issue. But in trying to decode a ComplexMessage I run into the error:
Unexpected end of buffer in varint
which seems to be related to an EOF of sorts.I will try to simplify my test to take out the socket code so I can share a simpler test. But in the meanwhile I wonder if there is any size limitation that my vector might exceed.
Thanks again.