24 : Stream(Data, Endian) {}
27 : Stream(Data, Endian) {}
33 Offset += Buffer.
size();
38 if (
auto EC = Stream.
readBytes(Offset, Size, Buffer))
55 FoundOffset = Pos + ThisOffset;
59 assert(FoundOffset >= OriginalOffset);
62 size_t Length = FoundOffset - OriginalOffset;
107 Ref = Stream.
slice(Offset, Length);
127 return skip(NewOffset - Offset);
132 auto EC = Stream.
readBytes(Offset, 1, Buffer);
133 assert(!EC &&
"Cannot peek an empty buffer!");
138 std::pair<BinaryStreamReader, BinaryStreamReader>
148 return std::make_pair(W1, W2);
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Error padToAlignment(uint32_t Align)
RefType slice(uint32_t Offset, uint32_t Len) const
Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...
Error readSubstream(BinarySubstreamRef &Stream, uint32_t Size)
Read Length bytes from the underlying stream into Stream.
This class represents lattice values for constants.
Error readWideString(ArrayRef< UTF16 > &Dest)
Similar to readCString, however read a null-terminated UTF16 string instead.
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
uint8_t peek() const
Examine the next byte of the underlying stream without advancing the stream's offset.
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
The access may reference the value stored in memory.
Error readCString(StringRef &Dest)
Read a null terminated string from Dest.
uint32_t getOffset() const
std::pair< BinaryStreamReader, BinaryStreamReader > split(uint32_t Offset) const
Error readFixedString(StringRef &Dest, uint32_t Length)
Read a Length byte string into Dest.
BinaryStreamReader()=default
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...
An interface for accessing data in a stream-like format, but which discourages copying.
size_t size() const
size - Get the array size.
RefType drop_front(uint32_t N) const
Return a new BinaryStreamRef with the first N elements removed.
void consumeError(Error Err)
Consume a Error without doing anything.
BinaryStreamRef StreamData
void setOffset(uint32_t Off)
static ErrorSuccess success()
Create a success value.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Error readBytes(ArrayRef< uint8_t > &Buffer, uint32_t Size)
Read Size bytes from the underlying stream at the current offset and and set Buffer to the resulting ...
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
uint32_t getLength() const
Error readStreamRef(BinaryStreamRef &Ref)
Read the entire remainder of the underlying stream into Ref.
Error skip(uint32_t Amount)
Advance the stream's offset by Amount bytes.
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 ...
uint32_t bytesRemaining() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RefType keep_front(uint32_t N) const
Return a new BinaryStreamRef with only the first N elements remaining.
Lightweight error class with error context and mandatory checking.
#define LLVM_LIKELY(EXPR)
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Error readLongestContiguousChunk(ArrayRef< uint8_t > &Buffer)
Read as much as possible from the underlying string at the current offset without invoking a copy...
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...