如何读取 google::p rotobuf::io::CodedOutputStream::WriteVarint32
How to read data written by google::protobuf::io::CodedOutputStream::WriteVarint32ToArray
我在google::protobuf::io::CodedOutputStream
中使用此方法将可变长度编码的整数写入缓冲区:
static uint8 * WriteVarint32ToArray(uint32 value, uint8 * target)
读取相同值的相应方法是什么?
我在文档中看到了这些:
static const uint8 * ReadLittleEndian32FromArray(const uint8 * buffer, uint32 * value)
static const uint8 * ReadLittleEndian64FromArray(const uint8 * buffer, uint64 * value)
但似乎没有一个能满足我的需求。我期待一个ReadVarint32FromArray
但这似乎不可用。由于我读取写入内存缓冲区而不是流,因此我需要像 uesd 这样的静态方法来写入。
文档:https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream
CodedInputStream::ReadVarint32
.没有static
版本,您需要实际实例化由数组支持的CodedInputStream
;有一个构造函数采用指针和大小。