27 return BBS.readLongestContiguousChunk(
Offset, Buffer);
48 return BBS.readLongestContiguousChunk(
Offset, Buffer);
53 return BBS.writeBytes(
Offset, Data);
65 std::optional<uint64_t>
Length)
92 if (Buffer.
size() > MaxLength)
93 Buffer = Buffer.
slice(0, MaxLength);
102 std::optional<uint64_t>
Length)
112 if (
auto EC = checkOffsetForWrite(
Offset,
Data.size()))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
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.
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
Common stuff for mutable and immutable StreamRefs.
BinaryStream * BorrowedImpl
Error checkOffsetForRead(uint64_t Offset, uint64_t DataSize) const
uint64_t getLength() const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Error readLongestContiguousChunk(uint64_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(uint64_t Offset, uint64_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.
BinaryStreamRef()=default
An interface for accessing data in a stream-like format, but which discourages copying.
virtual llvm::endianness getEndian() const =0
virtual uint64_t getLength()=0
Return the number of bytes of data in this stream.
virtual Error readBytes(uint64_t Offset, uint64_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...
virtual Error readLongestContiguousChunk(uint64_t Offset, ArrayRef< uint8_t > &Buffer)=0
Given an offset into the stream, read as much as possible without copying any data.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.
StringRef - Represent a constant reference to a string, i.e.
WritableBinaryStreamRef()=default
Error writeBytes(uint64_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.
A BinaryStream which can be read from as well as written to.
virtual Error writeBytes(uint64_t Offset, ArrayRef< uint8_t > Data)=0
Attempt to write the given bytes into the stream at the desired offset.
virtual Error commit()=0
For buffered streams, commits changes to the backing store.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Implement std::hash so that hash_code can be used in STL containers.