LLVM 19.0.0git
Public Member Functions | Friends | List of all members
llvm::BinaryStreamRef Class Reference

BinaryStreamRef is to BinaryStream what ArrayRef is to an Array. More...

#include "llvm/Support/BinaryStreamRef.h"

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

Public Member Functions

 BinaryStreamRef ()=default
 
 BinaryStreamRef (BinaryStream &Stream)
 
 BinaryStreamRef (BinaryStream &Stream, uint64_t Offset, std::optional< uint64_t > Length)
 
 BinaryStreamRef (ArrayRef< uint8_t > Data, llvm::endianness Endian)
 
 BinaryStreamRef (StringRef Data, llvm::endianness Endian)
 
 BinaryStreamRef (const BinaryStreamRef &Other)=default
 
BinaryStreamRefoperator= (const BinaryStreamRef &Other)=default
 
 BinaryStreamRef (BinaryStreamRef &&Other)=default
 
BinaryStreamRefoperator= (BinaryStreamRef &&Other)=default
 
 BinaryStreamRef (BinaryStreamRef &S, uint64_t Offset, uint64_t Length)=delete
 
Error readBytes (uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) const
 Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream.
 
Error readLongestContiguousChunk (uint64_t Offset, ArrayRef< uint8_t > &Buffer) const
 Given an Offset into this BinaryStreamRef, return a reference to the largest buffer the stream could support without necessitating a copy.
 
- Public Member Functions inherited from llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >
llvm::endianness getEndian () const
 
uint64_t getLength () const
 
BinaryStreamRef drop_front (uint64_t N) const
 Return a new BinaryStreamRef with the first N elements removed.
 
BinaryStreamRef drop_back (uint64_t N) const
 Return a new BinaryStreamRef with the last N elements removed.
 
BinaryStreamRef keep_front (uint64_t N) const
 Return a new BinaryStreamRef with only the first N elements remaining.
 
BinaryStreamRef keep_back (uint64_t N) const
 Return a new BinaryStreamRef with only the last N elements remaining.
 
BinaryStreamRef drop_symmetric (uint64_t N) const
 Return a new BinaryStreamRef with the first and last N elements removed.
 
BinaryStreamRef slice (uint64_t Offset, uint64_t Len) const
 Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elements.
 
bool valid () const
 

Friends

class WritableBinaryStreamRef
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >
 BinaryStreamRefBase ()=default
 
 BinaryStreamRefBase (BinaryStream &BorrowedImpl)
 
 BinaryStreamRefBase (std::shared_ptr< BinaryStream > SharedImpl, uint64_t Offset, std::optional< uint64_t > Length)
 
 BinaryStreamRefBase (BinaryStream &BorrowedImpl, uint64_t Offset, std::optional< uint64_t > Length)
 
 BinaryStreamRefBase (const BinaryStreamRefBase &Other)=default
 
 BinaryStreamRefBase (BinaryStreamRefBase &&Other)=default
 
BinaryStreamRefBaseoperator= (const BinaryStreamRefBase &Other)=default
 
BinaryStreamRefBaseoperator= (BinaryStreamRefBase &&Other)=default
 
Error checkOffsetForRead (uint64_t Offset, uint64_t DataSize) const
 
- Protected Attributes inherited from llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >
std::shared_ptr< BinaryStreamSharedImpl
 
BinaryStreamBorrowedImpl
 
uint64_t ViewOffset
 
std::optional< uint64_tLength
 

Detailed Description

BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.

It provides copy-semantics and read only access to a "window" of the underlying BinaryStream. Note that BinaryStreamRef is not a BinaryStream. That is to say, it does not inherit and override the methods of BinaryStream. In general, you should not pass around pointers or references to BinaryStreams and use inheritance to achieve polymorphism. Instead, you should pass around BinaryStreamRefs by value and achieve polymorphism that way.

Definition at line 153 of file BinaryStreamRef.h.

Constructor & Destructor Documentation

◆ BinaryStreamRef() [1/8]

llvm::BinaryStreamRef::BinaryStreamRef ( )
default

◆ BinaryStreamRef() [2/8]

BinaryStreamRef::BinaryStreamRef ( BinaryStream Stream)

Definition at line 62 of file BinaryStreamRef.cpp.

◆ BinaryStreamRef() [3/8]

BinaryStreamRef::BinaryStreamRef ( BinaryStream Stream,
uint64_t  Offset,
std::optional< uint64_t Length 
)

Definition at line 64 of file BinaryStreamRef.cpp.

◆ BinaryStreamRef() [4/8]

BinaryStreamRef::BinaryStreamRef ( ArrayRef< uint8_t >  Data,
llvm::endianness  Endian 
)
explicit

Definition at line 67 of file BinaryStreamRef.cpp.

References Endian, and llvm::size().

◆ BinaryStreamRef() [5/8]

BinaryStreamRef::BinaryStreamRef ( StringRef  Data,
llvm::endianness  Endian 
)
explicit

Definition at line 70 of file BinaryStreamRef.cpp.

References Endian.

◆ BinaryStreamRef() [6/8]

llvm::BinaryStreamRef::BinaryStreamRef ( const BinaryStreamRef Other)
default

◆ BinaryStreamRef() [7/8]

llvm::BinaryStreamRef::BinaryStreamRef ( BinaryStreamRef &&  Other)
default

◆ BinaryStreamRef() [8/8]

llvm::BinaryStreamRef::BinaryStreamRef ( BinaryStreamRef S,
uint64_t  Offset,
uint64_t  Length 
)
delete

Member Function Documentation

◆ operator=() [1/2]

BinaryStreamRef & llvm::BinaryStreamRef::operator= ( BinaryStreamRef &&  Other)
default

◆ operator=() [2/2]

BinaryStreamRef & llvm::BinaryStreamRef::operator= ( const BinaryStreamRef Other)
default

◆ readBytes()

Error BinaryStreamRef::readBytes ( uint64_t  Offset,
uint64_t  Size,
ArrayRef< uint8_t > &  Buffer 
) const

Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream.

Returns
a success error code if the entire range of data is within the bounds of this BinaryStreamRef's view and the implementation could read the data, and an appropriate error code otherwise.

Definition at line 73 of file BinaryStreamRef.cpp.

References llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >::BorrowedImpl, llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >::checkOffsetForRead(), llvm::Offset, llvm::BinaryStream::readBytes(), Size, and llvm::BinaryStreamRefBase< BinaryStreamRef, BinaryStream >::ViewOffset.

Referenced by llvm::FixedStreamArray< T >::operator[](), llvm::BinaryStreamReader::peek(), llvm::BinaryStreamReader::readBytes(), and llvm::msf::MappedBlockStream::readLongestContiguousChunk().

◆ readLongestContiguousChunk()

Error BinaryStreamRef::readLongestContiguousChunk ( uint64_t  Offset,
ArrayRef< uint8_t > &  Buffer 
) const

Friends And Related Function Documentation

◆ WritableBinaryStreamRef

friend class WritableBinaryStreamRef
friend

Definition at line 156 of file BinaryStreamRef.h.


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