Adds length-prefixed read to BigEndianReader
A common task when parsing encoded structs from a network is to read a serialization of an object with (possibly nested) length-prefixed members. //third_party/boringssl's Crypto ByteString bakes support for this in by having a "length-prefixed read" API that initially reads a big-endian length L from the buffer, then constructs and returns a new reader on the L many bytes immediately following the length, skipping the parent reader over this substring. However, this API is C-style and, as a consequence, perhaps not suitable for wide use in Chromium code. This patch adds similar functionality to base::BigEndianReader by adding ReadU8LengthPrefixed and ReadU16LengthPrefixed methods. R=mark Change-Id: Idaf0b04b414a3484099a861ef02501e5f8a83a47 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860518 Commit-Queue: David Van Cleve <davidvc@chromium.org> Reviewed-by:Mark Mentovai <mark@chromium.org> Cr-Commit-Position: refs/heads/master@{#706074}
Showing
Please register or sign in to comment