LLVM 20.0.0git
Public Member Functions | Protected Attributes | List of all members
llvm::BinaryByteStream Class Reference

An implementation of BinaryStream which holds its entire data set in a single contiguous buffer. More...

#include "llvm/Support/BinaryByteStream.h"

Inheritance diagram for llvm::BinaryByteStream:
Inheritance graph
[legend]

Public Member Functions

 BinaryByteStream ()=default
 
 BinaryByteStream (ArrayRef< uint8_t > Data, llvm::endianness Endian)
 
 BinaryByteStream (StringRef Data, 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.
 
uint64_t getLength () override
 Return the number of bytes of data in this stream.
 
ArrayRef< uint8_tdata () const
 
StringRef str () const
 
- 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.
 

Protected Attributes

llvm::endianness Endian
 
ArrayRef< uint8_tData
 

Additional Inherited Members

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

Detailed Description

An implementation of BinaryStream which holds its entire data set in a single contiguous buffer.

BinaryByteStream guarantees that no read operation will ever incur a copy. Note that BinaryByteStream does not own the underlying buffer.

Definition at line 30 of file BinaryByteStream.h.

Constructor & Destructor Documentation

◆ BinaryByteStream() [1/3]

llvm::BinaryByteStream::BinaryByteStream ( )
default

◆ BinaryByteStream() [2/3]

llvm::BinaryByteStream::BinaryByteStream ( ArrayRef< uint8_t Data,
llvm::endianness  Endian 
)
inline

Definition at line 33 of file BinaryByteStream.h.

◆ BinaryByteStream() [3/3]

llvm::BinaryByteStream::BinaryByteStream ( StringRef  Data,
llvm::endianness  Endian 
)
inline

Definition at line 35 of file BinaryByteStream.h.

Member Function Documentation

◆ data()

ArrayRef< uint8_t > llvm::BinaryByteStream::data ( ) const
inline

◆ getEndian()

llvm::endianness llvm::BinaryByteStream::getEndian ( ) const
inlineoverridevirtual

Implements llvm::BinaryStream.

Definition at line 38 of file BinaryByteStream.h.

References Endian.

Referenced by llvm::MutableBinaryByteStream::getEndian().

◆ getLength()

uint64_t llvm::BinaryByteStream::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 56 of file BinaryByteStream.h.

References Data, and llvm::ArrayRef< T >::size().

Referenced by llvm::MutableBinaryByteStream::getLength().

◆ readBytes()

Error llvm::BinaryByteStream::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 BinaryByteStream.h.

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

Referenced by llvm::MutableBinaryByteStream::readBytes().

◆ readLongestContiguousChunk()

Error llvm::BinaryByteStream::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 48 of file BinaryByteStream.h.

References llvm::BinaryStream::checkOffsetForRead(), Data, llvm::Offset, llvm::ArrayRef< T >::slice(), and llvm::Error::success().

Referenced by llvm::MutableBinaryByteStream::readLongestContiguousChunk().

◆ str()

StringRef llvm::BinaryByteStream::str ( ) const
inline

Definition at line 60 of file BinaryByteStream.h.

References llvm::ArrayRef< T >::data(), Data, and llvm::ArrayRef< T >::size().

Member Data Documentation

◆ Data

ArrayRef<uint8_t> llvm::BinaryByteStream::Data
protected

Definition at line 67 of file BinaryByteStream.h.

Referenced by data(), getLength(), readBytes(), readLongestContiguousChunk(), and str().

◆ Endian

llvm::endianness llvm::BinaryByteStream::Endian
protected

Definition at line 66 of file BinaryByteStream.h.

Referenced by getEndian().


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