LLVM 20.0.0git
Public Member Functions | List of all members
llvm::BinaryItemStream< T, Traits > Class Template Reference

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. More...

#include "llvm/Support/BinaryItemStream.h"

Inheritance diagram for llvm::BinaryItemStream< T, Traits >:
Inheritance graph
[legend]

Public Member Functions

 BinaryItemStream (llvm::endianness Endian)
 
llvm::endianness getEndian () const override
 
Error readBytes (uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) override
 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.
 
Error readLongestContiguousChunk (uint64_t Offset, ArrayRef< uint8_t > &Buffer) override
 Given an offset into the stream, read as much as possible without copying any data.
 
void setItems (ArrayRef< T > ItemArray)
 
uint64_t getLength () override
 Return the number of bytes of data in this stream.
 
- Public Member Functions inherited from llvm::BinaryStream
virtual ~BinaryStream ()=default
 
virtual llvm::endianness getEndian () const =0
 
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 ArrayRef to point to data owned by the stream.
 
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.
 
virtual uint64_t getLength ()=0
 Return the number of bytes of data in this stream.
 
virtual BinaryStreamFlags getFlags () const
 Return the properties of this stream.
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::BinaryStream
Error checkOffsetForRead (uint64_t Offset, uint64_t DataSize)
 

Detailed Description

template<typename T, typename Traits = BinaryItemTraits<T>>
class llvm::BinaryItemStream< T, Traits >

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.

Definition at line 34 of file BinaryItemStream.h.

Constructor & Destructor Documentation

◆ BinaryItemStream()

template<typename T , typename Traits = BinaryItemTraits<T>>
llvm::BinaryItemStream< T, Traits >::BinaryItemStream ( llvm::endianness  Endian)
inlineexplicit

Definition at line 36 of file BinaryItemStream.h.

References Endian.

Member Function Documentation

◆ getEndian()

template<typename T , typename Traits = BinaryItemTraits<T>>
llvm::endianness llvm::BinaryItemStream< T, Traits >::getEndian ( ) const
inlineoverridevirtual

Implements llvm::BinaryStream.

Definition at line 38 of file BinaryItemStream.h.

◆ getLength()

template<typename T , typename Traits = BinaryItemTraits<T>>
uint64_t llvm::BinaryItemStream< T, Traits >::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 68 of file BinaryItemStream.h.

◆ readBytes()

template<typename T , typename Traits = BinaryItemTraits<T>>
Error llvm::BinaryItemStream< T, Traits >::readBytes ( uint64_t  Offset,
uint64_t  Size,
ArrayRef< uint8_t > &  Buffer 
)
inlineoverridevirtual

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.

Implements llvm::BinaryStream.

Definition at line 40 of file BinaryItemStream.h.

References llvm::BinaryStream::checkOffsetForRead(), llvm::Offset, Size, llvm::stream_too_short, llvm::Error::success(), and llvm::ArrayRef< T >::take_front().

◆ readLongestContiguousChunk()

template<typename T , typename Traits = BinaryItemTraits<T>>
Error llvm::BinaryItemStream< T, Traits >::readLongestContiguousChunk ( uint64_t  Offset,
ArrayRef< uint8_t > &  Buffer 
)
inlineoverridevirtual

Given an offset into the stream, read as much as possible without copying any data.

Implements llvm::BinaryStream.

Definition at line 54 of file BinaryItemStream.h.

References llvm::Offset, and llvm::Error::success().

◆ setItems()

template<typename T , typename Traits = BinaryItemTraits<T>>
void llvm::BinaryItemStream< T, Traits >::setItems ( ArrayRef< T ItemArray)
inline

Definition at line 63 of file BinaryItemStream.h.

Referenced by writeRecords().


The documentation for this class was generated from the following file: