LLVM 20.0.0git
Public Member Functions | Protected Member Functions | List of all members
llvm::BinaryStream Class Referenceabstract

An interface for accessing data in a stream-like format, but which discourages copying. More...

#include "llvm/Support/BinaryStream.h"

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

Public Member Functions

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 Member Functions

Error checkOffsetForRead (uint64_t Offset, uint64_t DataSize)
 

Detailed Description

An interface for accessing data in a stream-like format, but which discourages copying.

Instead of specifying a buffer in which to copy data on a read, the API returns an ArrayRef to data owned by the stream's implementation. Since implementations may not necessarily store data in a single contiguous buffer (or even in memory at all), in such cases a it may be necessary for an implementation to cache such a buffer so that it can return it.

Definition at line 34 of file BinaryStream.h.

Constructor & Destructor Documentation

◆ ~BinaryStream()

virtual llvm::BinaryStream::~BinaryStream ( )
virtualdefault

Member Function Documentation

◆ checkOffsetForRead()

Error llvm::BinaryStream::checkOffsetForRead ( uint64_t  Offset,
uint64_t  DataSize 
)
inlineprotected

◆ getEndian()

virtual llvm::endianness llvm::BinaryStream::getEndian ( ) const
pure virtual

◆ getFlags()

virtual BinaryStreamFlags llvm::BinaryStream::getFlags ( ) const
inlinevirtual

Return the properties of this stream.

Reimplemented in llvm::AppendingBinaryByteStream, and llvm::WritableBinaryStream.

Definition at line 55 of file BinaryStream.h.

References llvm::BSF_None.

◆ getLength()

virtual uint64_t llvm::BinaryStream::getLength ( )
pure virtual

◆ readBytes()

virtual Error llvm::BinaryStream::readBytes ( uint64_t  Offset,
uint64_t  Size,
ArrayRef< uint8_t > &  Buffer 
)
pure virtual

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.

Implemented in llvm::msf::MappedBlockStream, llvm::msf::WritableMappedBlockStream, llvm::BinaryByteStream, llvm::MutableBinaryByteStream, llvm::AppendingBinaryByteStream, llvm::FileBufferByteStream, and llvm::BinaryItemStream< T, Traits >.

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

◆ readLongestContiguousChunk()

virtual Error llvm::BinaryStream::readLongestContiguousChunk ( uint64_t  Offset,
ArrayRef< uint8_t > &  Buffer 
)
pure virtual

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