Add WriteUVarint to ByteBufferWriter and ReadUVarint to ByteBufferReader

Methods to write/read a varint as described by
https://developers.google.com/protocol-buffers/docs/encoding#varints
that will be used for a QUIC data channel.

Split from CL https://codereview.webrtc.org/1844803002/.

Review URL: https://codereview.webrtc.org/1844333006

Cr-Commit-Position: refs/heads/master@{#12322}
This commit is contained in:
mikescarlett
2016-04-11 16:11:38 -07:00
committed by Commit bot
parent 3ba4d53379
commit 9a20fa6292
3 changed files with 99 additions and 0 deletions

View File

@ -57,6 +57,7 @@ class ByteBufferWriter : public ByteBuffer {
void WriteUInt24(uint32_t val);
void WriteUInt32(uint32_t val);
void WriteUInt64(uint64_t val);
void WriteUVarint(uint64_t val);
void WriteString(const std::string& val);
void WriteBytes(const char* val, size_t len);
@ -110,6 +111,7 @@ class ByteBufferReader : public ByteBuffer {
bool ReadUInt24(uint32_t* val);
bool ReadUInt32(uint32_t* val);
bool ReadUInt64(uint64_t* val);
bool ReadUVarint(uint64_t* val);
bool ReadBytes(char* val, size_t len);
// Appends next |len| bytes from the buffer to |val|. Returns false