LLVM  14.0.0git
Public Member Functions | List of all members
llvm::VarStreamArrayIterator< ValueType, Extractor > Class Template Reference

VarStreamArray represents an array of variable length records backed by a stream. More...

#include "llvm/Support/BinaryStreamArray.h"

Public Member Functions

 VarStreamArrayIterator (const ArrayType &Array, const Extractor &E, uint32_t Offset, bool *HadError)
 
 VarStreamArrayIterator ()=default
 
 VarStreamArrayIterator (const Extractor &E)
 
 ~VarStreamArrayIterator ()=default
 
bool operator== (const IterType &R) const
 
const ValueTypeoperator* () const
 
ValueTypeoperator* ()
 
IterTypeoperator+= (unsigned N)
 
uint32_t offset () const
 
uint32_t getRecordLength () const
 

Detailed Description

template<typename ValueType, typename Extractor>
class llvm::VarStreamArrayIterator< ValueType, Extractor >

VarStreamArray represents an array of variable length records backed by a stream.

This could be a contiguous sequence of bytes in memory, it could be a file on disk, or it could be a PDB stream where bytes are stored as discontiguous blocks in a file. Usually it is desirable to treat arrays as contiguous blocks of memory, but doing so with large PDB files, for example, could mean allocating huge amounts of memory just to allow re-ordering of stream data to be contiguous before iterating over it. By abstracting this out, we need not duplicate this memory, and we can iterate over arrays in arbitrarily formatted streams. Elements are parsed lazily on iteration, so there is no upfront cost associated with building or copying a VarStreamArray, no matter how large it may be.

You create a VarStreamArray by specifying a ValueType and an Extractor type. If you do not specify an Extractor type, you are expected to specialize VarStreamArrayExtractor<T> for your ValueType.

By default an Extractor is default constructed in the class, but in some cases you might find it useful for an Extractor to maintain state across extractions. In this case you can provide your own Extractor through a secondary constructor. The following examples show various ways of creating a VarStreamArray.

  // Will use VarStreamArrayExtractor<MyType> as the extractor.
  VarStreamArray<MyType> MyTypeArray;

  // Will use a default-constructed MyExtractor as the extractor.
  VarStreamArray<MyType, MyExtractor> MyTypeArray2;

  // Will use the specific instance of MyExtractor provided.
  // MyExtractor need not be default-constructible in this case.
  MyExtractor E(SomeContext);
  VarStreamArray<MyType, MyExtractor> MyTypeArray3(E);

Definition at line 88 of file BinaryStreamArray.h.

Constructor & Destructor Documentation

◆ VarStreamArrayIterator() [1/3]

template<typename ValueType , typename Extractor >
llvm::VarStreamArrayIterator< ValueType, Extractor >::VarStreamArrayIterator ( const ArrayType Array,
const Extractor &  E,
uint32_t  Offset,
bool *  HadError 
)
inline

◆ VarStreamArrayIterator() [2/3]

template<typename ValueType , typename Extractor >
llvm::VarStreamArrayIterator< ValueType, Extractor >::VarStreamArrayIterator ( )
default

◆ VarStreamArrayIterator() [3/3]

template<typename ValueType , typename Extractor >
llvm::VarStreamArrayIterator< ValueType, Extractor >::VarStreamArrayIterator ( const Extractor &  E)
inlineexplicit

Definition at line 177 of file BinaryStreamArray.h.

◆ ~VarStreamArrayIterator()

template<typename ValueType , typename Extractor >
llvm::VarStreamArrayIterator< ValueType, Extractor >::~VarStreamArrayIterator ( )
default

Member Function Documentation

◆ getRecordLength()

template<typename ValueType , typename Extractor >
uint32_t llvm::VarStreamArrayIterator< ValueType, Extractor >::getRecordLength ( ) const
inline

Definition at line 231 of file BinaryStreamArray.h.

◆ offset()

template<typename ValueType , typename Extractor >
uint32_t llvm::VarStreamArrayIterator< ValueType, Extractor >::offset ( ) const
inline

Definition at line 230 of file BinaryStreamArray.h.

◆ operator*() [1/2]

template<typename ValueType , typename Extractor >
ValueType& llvm::VarStreamArrayIterator< ValueType, Extractor >::operator* ( )
inline

Definition at line 200 of file BinaryStreamArray.h.

References assert().

◆ operator*() [2/2]

template<typename ValueType , typename Extractor >
const ValueType& llvm::VarStreamArrayIterator< ValueType, Extractor >::operator* ( ) const
inline

Definition at line 195 of file BinaryStreamArray.h.

References assert().

◆ operator+=()

template<typename ValueType , typename Extractor >
IterType& llvm::VarStreamArrayIterator< ValueType, Extractor >::operator+= ( unsigned  N)
inline

◆ operator==()

template<typename ValueType , typename Extractor >
bool llvm::VarStreamArrayIterator< ValueType, Extractor >::operator== ( const IterType R) const
inline

Definition at line 180 of file BinaryStreamArray.h.

References assert().


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