LLVM 19.0.0git
Public Member Functions | List of all members
llvm::MutableBinaryByteStream 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::MutableBinaryByteStream:
Inheritance graph
[legend]

Public Member Functions

 MutableBinaryByteStream ()=default
 
 MutableBinaryByteStream (MutableArrayRef< uint8_t > 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.
 
Error writeBytes (uint64_t Offset, ArrayRef< uint8_t > Buffer) override
 Attempt to write the given bytes into the stream at the desired offset.
 
Error commit () override
 For buffered streams, commits changes to the backing store.
 
MutableArrayRef< uint8_t > data () const
 
- Public Member Functions inherited from llvm::WritableBinaryStream
 ~WritableBinaryStream () override=default
 
virtual Error writeBytes (uint64_t Offset, ArrayRef< uint8_t > Data)=0
 Attempt to write the given bytes into the stream at the desired offset.
 
virtual Error commit ()=0
 For buffered streams, commits changes to the backing store.
 
BinaryStreamFlags getFlags () const override
 Return the properties of 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::WritableBinaryStream
Error checkOffsetForWrite (uint64_t Offset, uint64_t DataSize)
 
- 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.

As with BinaryByteStream, the mutable version also guarantees that no read operation will ever incur a copy, and similarly it does not own the underlying buffer.

Definition at line 88 of file BinaryByteStream.h.

Constructor & Destructor Documentation

◆ MutableBinaryByteStream() [1/2]

llvm::MutableBinaryByteStream::MutableBinaryByteStream ( )
default

◆ MutableBinaryByteStream() [2/2]

llvm::MutableBinaryByteStream::MutableBinaryByteStream ( MutableArrayRef< uint8_t >  Data,
llvm::endianness  Endian 
)
inline

Definition at line 91 of file BinaryByteStream.h.

Member Function Documentation

◆ commit()

Error llvm::MutableBinaryByteStream::commit ( )
inlineoverridevirtual

For buffered streams, commits changes to the backing store.

Implements llvm::WritableBinaryStream.

Definition at line 123 of file BinaryByteStream.h.

References llvm::Error::success().

◆ data()

MutableArrayRef< uint8_t > llvm::MutableBinaryByteStream::data ( ) const
inline

Definition at line 125 of file BinaryByteStream.h.

◆ getEndian()

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

Implements llvm::BinaryStream.

Definition at line 95 of file BinaryByteStream.h.

References llvm::BinaryByteStream::getEndian().

◆ getLength()

uint64_t llvm::MutableBinaryByteStream::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 109 of file BinaryByteStream.h.

References llvm::BinaryByteStream::getLength().

◆ readBytes()

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

References llvm::Offset, llvm::BinaryByteStream::readBytes(), and Size.

◆ readLongestContiguousChunk()

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

References llvm::Offset, and llvm::BinaryByteStream::readLongestContiguousChunk().

◆ writeBytes()

Error llvm::MutableBinaryByteStream::writeBytes ( uint64_t  Offset,
ArrayRef< uint8_t >  Data 
)
inlineoverridevirtual

Attempt to write the given bytes into the stream at the desired offset.

This will always necessitate a copy. Cannot shrink or grow the stream, only writes into existing allocated space.

Implements llvm::WritableBinaryStream.

Definition at line 111 of file BinaryByteStream.h.

References llvm::WritableBinaryStream::checkOffsetForWrite(), llvm::ArrayRef< T >::data(), llvm::MutableArrayRef< T >::data(), llvm::ArrayRef< T >::empty(), llvm::Offset, llvm::ArrayRef< T >::size(), and llvm::Error::success().


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