LLVM  6.0.0svn
Public Member Functions | List of all members
llvm::BinaryItemStream< T, Traits > Class Template Reference

BinaryItemStream represents a sequence of objects stored in some kind of external container but for which it is useful to view as a stream of contiguous bytes. More...

#include "llvm/Support/BinaryItemStream.h"

Inheritance diagram for llvm::BinaryItemStream< T, Traits >:
Inheritance graph
[legend]
Collaboration diagram for llvm::BinaryItemStream< T, Traits >:
Collaboration graph
[legend]

Public Member Functions

 BinaryItemStream (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...
 
void setItems (ArrayRef< T > ItemArray)
 
uint32_t getLength () override
 Return the number of bytes of data in this stream. More...
 
- Public Member Functions inherited from llvm::BinaryStream
virtual ~BinaryStream ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from llvm::BinaryStream
Error checkOffset (uint32_t Offset, uint32_t DataSize)
 

Detailed Description

template<typename T, typename Traits = BinaryItemTraits<T>>
class llvm::BinaryItemStream< T, Traits >

BinaryItemStream represents a sequence of objects stored in some kind of external container but for which it is useful to view as a stream of contiguous bytes.

An example of this might be if you have a collection of records and you serialize each one into a buffer, and store these serialized records in a container. The pointers themselves are not laid out contiguously in memory, but we may wish to read from or write to these records as if they were.

Definition at line 35 of file BinaryItemStream.h.

Constructor & Destructor Documentation

◆ BinaryItemStream()

template<typename T, typename Traits = BinaryItemTraits<T>>
llvm::BinaryItemStream< T, Traits >::BinaryItemStream ( llvm::support::endianness  Endian)
inlineexplicit

Definition at line 37 of file BinaryItemStream.h.

Member Function Documentation

◆ getEndian()

template<typename T, typename Traits = BinaryItemTraits<T>>
llvm::support::endianness llvm::BinaryItemStream< T, Traits >::getEndian ( ) const
inlineoverridevirtual

Implements llvm::BinaryStream.

Definition at line 40 of file BinaryItemStream.h.

◆ getLength()

template<typename T, typename Traits = BinaryItemTraits<T>>
uint32_t llvm::BinaryItemStream< T, Traits >::getLength ( )
inlineoverridevirtual

Return the number of bytes of data in this stream.

Implements llvm::BinaryStream.

Definition at line 70 of file BinaryItemStream.h.

References assert(), llvm::lower_bound(), and llvm::stream_too_short.

◆ readBytes()

template<typename T, typename Traits = BinaryItemTraits<T>>
Error llvm::BinaryItemStream< T, Traits >::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 BinaryItemStream.h.

References llvm::stream_too_short, llvm::Error::success(), and llvm::ArrayRef< T >::take_front().

◆ readLongestContiguousChunk()

template<typename T, typename Traits = BinaryItemTraits<T>>
Error llvm::BinaryItemStream< T, Traits >::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 56 of file BinaryItemStream.h.

References llvm::Error::success().

◆ setItems()

template<typename T, typename Traits = BinaryItemTraits<T>>
void llvm::BinaryItemStream< T, Traits >::setItems ( ArrayRef< T ItemArray)
inline

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