Reputation: 18109
I'm using this method in google::protobuf::io::CodedOutputStream
to write variable length encoded integers to a buffer:
static uint8 * WriteVarint32ToArray(uint32 value, uint8 * target)
What is the corresponding method to read the same value?
I see these in the documentation:
static const uint8 * ReadLittleEndian32FromArray(const uint8 * buffer, uint32 * value)
static const uint8 * ReadLittleEndian64FromArray(const uint8 * buffer, uint64 * value)
But none that seems to do what I need. I was expecting a ReadVarint32FromArray
but this seems unavailable. Since I read an write a memory buffer and not a stream, i need a static method like the one uesd for writing.
The documentation: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream
Upvotes: 1
Views: 661
Reputation: 52471
CodedInputStream::ReadVarint32
. There's no static
version, you would need to actually instantiate a CodedInputStream
backed by your array; there's a constructor taking pointer and size.
Upvotes: 2