14 using namespace llvm::support;
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(); }
102 if (Buffer.
size() > MaxLength)
103 Buffer = Buffer.
slice(0, MaxLength);
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...
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 > 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...
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.
size_t size() const
size - Get the array size.
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.
An interface for accessing data in a stream-like format, but which discourages copying.
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...
Error commit()
For buffered streams, commits changes to the backing store.
static ErrorSuccess success()
Create a success value.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
BinaryStreamRef()=default
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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 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...
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Error checkOffset(uint32_t Offset, uint32_t DataSize) const
A BinaryStream which can be read from as well as written to.