Add a BinarySubstreamRef, and a method to read one.

This is essentially just a BinaryStreamRef packaged with an
offset and the logic for reading one is no different than the
logic for reading a BinaryStreamRef, except that we save the
current offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306122 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner
2017-06-23 16:38:40 +00:00
parent d9be98a70d
commit 36e5ba3f32
3 changed files with 20 additions and 0 deletions
+6
View File
@@ -109,6 +109,12 @@ Error BinaryStreamReader::readStreamRef(BinaryStreamRef &Ref, uint32_t Length) {
return Error::success();
}
Error BinaryStreamReader::readSubstream(BinarySubstreamRef &Stream,
uint32_t Size) {
Stream.Offset = getOffset();
return readStreamRef(Stream.StreamData, Size);
}
Error BinaryStreamReader::skip(uint32_t Amount) {
if (Amount > bytesRemaining())
return make_error<BinaryStreamError>(stream_error_code::stream_too_short);