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

Inherited from BinaryStream:

Methods

BinaryItemStream<T, Traits>(
    llvm::support::endianness Endian)

Declared at: llvm/include/llvm/Support/BinaryItemStream.h:36

Parameters

llvm::support::endianness Endian

void computeItemOffsets()

Declared at: llvm/include/llvm/Support/BinaryItemStream.h:74

llvm::support::endianness getEndian() const

Declared at: llvm/include/llvm/Support/BinaryItemStream.h:39

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)

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)

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)

Declared at: llvm/include/llvm/Support/BinaryItemStream.h:64

Parameters

ArrayRef<T> ItemArray

Expected<uint32_t> translateOffsetIndex(
    uint64_t Offset)

Declared at: llvm/include/llvm/Support/BinaryItemStream.h:86

Parameters

uint64_t Offset