LLVM  8.0.1
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]
Collaboration diagram for llvm::BinaryByteStream:
Collaboration graph
[legend]

Public Member Functions

 BinaryByteStream ()=default
 
 BinaryByteStream (ArrayRef< uint8_t > Data, llvm::support::endianness Endian)
 
 BinaryByteStream (StringRef Data, llvm::support::endianness Endian)
 
llvm::support::endianness getEndian () const override
 
Error readBytes (uint32_t Offset, uint32_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. More...
 
Error readLongestContiguousChunk (uint32_t Offset, ArrayRef< uint8_t > &Buffer) override
 Given an offset into the stream, read as much as possible without copying any data. More...
 
uint32_t getLength () override
 Return the number of bytes of data in this stream. More...
 
ArrayRef< uint8_t > data () const
 
StringRef str () const
 
- Public Member Functions inherited from llvm::BinaryStream
virtual ~BinaryStream ()=default
 
virtual BinaryStreamFlags getFlags () const
 Return the properties of this stream. More...
 

Protected Attributes

llvm::support::endianness Endian
 
ArrayRef< uint8_t > Data
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::BinaryStream
Error checkOffsetForRead (uint32_t Offset, uint32_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 32 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::support::endianness  Endian 
)
inline

Definition at line 35 of file BinaryByteStream.h.

◆ BinaryByteStream() [3/3]

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

Definition at line 37 of file BinaryByteStream.h.

Member Function Documentation

◆ data()

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

Definition at line 60 of file BinaryByteStream.h.

References Data.

◆ getEndian()

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

Implements llvm::BinaryStream.

Definition at line 40 of file BinaryByteStream.h.

References Endian.

◆ getLength()

uint32_t llvm::BinaryByteStream::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 58 of file BinaryByteStream.h.

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

Referenced by llvm::object::WindowsResource::getHeadEntry(), and llvm::AppendingBinaryByteStream::writeBytes().

◆ readBytes()

Error llvm::BinaryByteStream::readBytes ( uint32_t  Offset,
uint32_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 42 of file BinaryByteStream.h.

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

◆ readLongestContiguousChunk()

Error llvm::BinaryByteStream::readLongestContiguousChunk ( uint32_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 50 of file BinaryByteStream.h.

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

◆ str()

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

Definition at line 62 of file BinaryByteStream.h.

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

Member Data Documentation

◆ Data

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

◆ Endian

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

Definition at line 68 of file BinaryByteStream.h.

Referenced by getEndian(), and llvm::AppendingBinaryByteStream::getEndian().


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