23 return BBS.getEndian();
27 return BBS.readBytes(Offset, Size, Buffer);
31 return BBS.readLongestContiguousChunk(Offset, Buffer);
33 uint32_t getLength()
override {
return BBS.getLength(); }
42 : BBS(Data, Endian) {}
46 return BBS.getEndian();
50 return BBS.readBytes(Offset, Size, Buffer);
54 return BBS.readLongestContiguousChunk(Offset, Buffer);
56 uint32_t getLength()
override {
return BBS.getLength(); }
59 return BBS.writeBytes(Offset, Data);
61 Error commit()
override {
return BBS.commit(); }
99 if (Buffer.
size() > MaxLength)
100 Buffer = Buffer.
slice(0, MaxLength);
120 if (
auto EC = checkOffsetForWrite(Offset, Data.
size()))
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer...
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer...
This class represents lattice values for constants.
virtual Error readBytes(uint32_t Offset, uint32_t Size, ArrayRef< uint8_t > &Buffer)=0
Given an offset into the stream and a number of bytes, attempt to read the bytes and set the output A...
BinaryStream * BorrowedImpl
Common stuff for mutable and immutable StreamRefs.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
WritableBinaryStreamRef()=default
virtual Error writeBytes(uint32_t Offset, ArrayRef< uint8_t > Data)=0
Attempt to write the given bytes into the stream at the desired offset.
Error readBytes(uint32_t Offset, uint32_t Size, ArrayRef< uint8_t > &Buffer) const
Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream...
virtual Error readLongestContiguousChunk(uint32_t Offset, ArrayRef< uint8_t > &Buffer)=0
Given an offset into the stream, read as much as possible without copying any data.
Optional< uint32_t > Length
An interface for accessing data in a stream-like format, but which discourages copying.
size_t size() const
size - Get the array size.
Error commit()
For buffered streams, commits changes to the backing store.
uint32_t getLength() const
static ErrorSuccess success()
Create a success value.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
BinaryStreamRef()=default
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array...
virtual Error commit()=0
For buffered streams, commits changes to the backing store.
Error readLongestContiguousChunk(uint32_t Offset, ArrayRef< uint8_t > &Buffer) const
Given an Offset into this BinaryStreamRef, return a reference to the largest buffer the stream could ...
Error writeBytes(uint32_t Offset, ArrayRef< uint8_t > Data) const
Given an Offset into this WritableBinaryStreamRef and some input data, writes the data to the underly...
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Error checkOffsetForRead(uint32_t Offset, uint32_t DataSize) const
A BinaryStream which can be read from as well as written to.