LLVM 18.0.0git
Public Member Functions | List of all members
llvm::AppendingBinaryByteStream Class Reference

An implementation of WritableBinaryStream which can write at its end causing the underlying data to grow. More...

#include "llvm/Support/BinaryByteStream.h"

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

Public Member Functions

 AppendingBinaryByteStream ()=default
 
 AppendingBinaryByteStream (llvm::support::endianness Endian)
 
void clear ()
 
llvm::support::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.
 
void insert (uint64_t Offset, ArrayRef< uint8_t > Bytes)
 
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.
 
BinaryStreamFlags getFlags () const override
 Return the properties of this stream.
 
MutableArrayRef< uint8_t > data ()
 
- 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::support::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 WritableBinaryStream which can write at its end causing the underlying data to grow.

This class owns the underlying data.

Definition at line 134 of file BinaryByteStream.h.

Constructor & Destructor Documentation

◆ AppendingBinaryByteStream() [1/2]

llvm::AppendingBinaryByteStream::AppendingBinaryByteStream ( )
default

◆ AppendingBinaryByteStream() [2/2]

llvm::AppendingBinaryByteStream::AppendingBinaryByteStream ( llvm::support::endianness  Endian)
inline

Definition at line 140 of file BinaryByteStream.h.

References Endian.

Member Function Documentation

◆ clear()

void llvm::AppendingBinaryByteStream::clear ( )
inline

Definition at line 143 of file BinaryByteStream.h.

References llvm::Data.

Referenced by llvm::codeview::ContinuationRecordBuilder::begin().

◆ commit()

Error llvm::AppendingBinaryByteStream::commit ( )
inlineoverridevirtual

For buffered streams, commits changes to the backing store.

Implements llvm::WritableBinaryStream.

Definition at line 192 of file BinaryByteStream.h.

References llvm::Error::success().

◆ data()

MutableArrayRef< uint8_t > llvm::AppendingBinaryByteStream::data ( )
inline

Definition at line 197 of file BinaryByteStream.h.

References llvm::Data.

◆ getEndian()

llvm::support::endianness llvm::AppendingBinaryByteStream::getEndian ( ) const
inlineoverridevirtual

Implements llvm::BinaryStream.

Definition at line 145 of file BinaryByteStream.h.

References Endian.

◆ getFlags()

BinaryStreamFlags llvm::AppendingBinaryByteStream::getFlags ( ) const
inlineoverridevirtual

Return the properties of this stream.

Reimplemented from llvm::BinaryStream.

Definition at line 195 of file BinaryByteStream.h.

References llvm::BSF_Append, and llvm::BSF_Write.

◆ getLength()

uint64_t llvm::AppendingBinaryByteStream::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 169 of file BinaryByteStream.h.

References llvm::Data.

Referenced by writeBytes().

◆ insert()

void llvm::AppendingBinaryByteStream::insert ( uint64_t  Offset,
ArrayRef< uint8_t >  Bytes 
)
inline

◆ readBytes()

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

References llvm::WritableBinaryStream::checkOffsetForWrite(), llvm::Data, llvm::Offset, llvm::ArrayRef< T >::size(), Size, llvm::ArrayRef< T >::slice(), and llvm::Error::success().

◆ readLongestContiguousChunk()

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

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

◆ writeBytes()

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

References llvm::ArrayRef< T >::data(), llvm::Data, llvm::ArrayRef< T >::empty(), getLength(), llvm::invalid_offset, llvm::Offset, llvm::ArrayRef< T >::size(), and llvm::Error::success().


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