class BinaryItemStream
Declaration
template <typename T, typename Traits = BinaryItemTraits<T>>
class BinaryItemStream : public BinaryStream { /* full declaration omitted */ };
Description
BinaryItemStream represents a sequence of objects stored in some kind of external container but for which it is useful to view as a stream of contiguous bytes. An example of this might be if you have a collection of records and you serialize each one into a buffer, and store these serialized records in a container. The pointers themselves are not laid out contiguously in memory, but we may wish to read from or write to these records as if they were.
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:34
Inherits from: BinaryStream
Templates
- T
- Traits = BinaryItemTraits<T>
Member Variables
- private llvm::support::endianness Endian
- private ArrayRef<T> Items
- private std::vector<uint64_t> ItemEndOffsets
Method Overview
- public BinaryItemStream<T, Traits>(llvm::support::endianness Endian)
- private void computeItemOffsets()
- public llvm::support::endianness getEndian() const
- public uint64_t getLength()
- public llvm::Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef<uint8_t> & Buffer)
- public llvm::Error readLongestContiguousChunk(uint64_t Offset, ArrayRef<uint8_t> & Buffer)
- public void setItems(ArrayRef<T> ItemArray)
- private Expected<uint32_t> translateOffsetIndex(uint64_t Offset)
Inherited from BinaryStream:
- protected checkOffsetForRead
- public getEndian
- public getFlags
- public getLength
- public readBytes
- public readLongestContiguousChunk
Methods
¶BinaryItemStream<T, Traits>(
llvm::support::endianness Endian)
BinaryItemStream<T, Traits>(
llvm::support::endianness Endian)
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:36
Parameters
- llvm::support::endianness Endian
¶void computeItemOffsets()
void computeItemOffsets()
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:74
¶llvm::support::endianness getEndian() const
llvm::support::endianness getEndian() const
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:39
¶uint64_t getLength()
uint64_t getLength()
Description
Return the number of bytes of data in this stream.
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:69
¶llvm::Error readBytes(uint64_t Offset,
uint64_t Size,
ArrayRef<uint8_t>& Buffer)
llvm::Error readBytes(uint64_t Offset,
uint64_t Size,
ArrayRef<uint8_t>& Buffer)
Description
Given an offset into the stream and a number of bytes, attempt to read the bytes and set the output ArrayRef to point to data owned by the stream.
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:41
Parameters
- uint64_t Offset
- uint64_t Size
- ArrayRef<uint8_t>& Buffer
¶llvm::Error readLongestContiguousChunk(
uint64_t Offset,
ArrayRef<uint8_t>& Buffer)
llvm::Error readLongestContiguousChunk(
uint64_t Offset,
ArrayRef<uint8_t>& Buffer)
Description
Given an offset into the stream, read as much as possible without copying any data.
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:55
Parameters
- uint64_t Offset
- ArrayRef<uint8_t>& Buffer
¶void setItems(ArrayRef<T> ItemArray)
void setItems(ArrayRef<T> ItemArray)
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:64
Parameters
- ArrayRef<T> ItemArray
¶Expected<uint32_t> translateOffsetIndex(
uint64_t Offset)
Expected<uint32_t> translateOffsetIndex(
uint64_t Offset)
Declared at: llvm/include/llvm/Support/BinaryItemStream.h:86
Parameters
- uint64_t Offset