LLVM 22.0.0git
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"

Inheritance diagram for llvm::VarStreamArrayIterator< ValueType, Extractor >:
[legend]

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
IterTypeoperator+= (unsigned N)
uint32_t offset () const
uint32_t getRecordLength () const
Public Member Functions inherited from llvm::iterator_facade_base< VarStreamArrayIterator< ValueType, Extractor >, std::forward_iterator_tag, const ValueType >
VarStreamArrayIterator< ValueType, Extractor > operator+ (std::ptrdiff_t n) const
VarStreamArrayIterator< ValueType, Extractor > operator- (std::ptrdiff_t n) const
VarStreamArrayIterator< ValueType, Extractor > & operator++ ()
VarStreamArrayIterator< ValueType, Extractor > & operator-- ()
bool operator!= (const VarStreamArrayIterator< ValueType, Extractor > &RHS) const
bool operator> (const VarStreamArrayIterator< ValueType, Extractor > &RHS) const
bool operator<= (const VarStreamArrayIterator< ValueType, Extractor > &RHS) const
bool operator>= (const VarStreamArrayIterator< ValueType, Extractor > &RHS) const
PointerProxy operator-> () const
ReferenceProxy operator[] (std::ptrdiff_t n) const

Additional Inherited Members

Public Types inherited from llvm::iterator_facade_base< VarStreamArrayIterator< ValueType, Extractor >, std::forward_iterator_tag, const ValueType >
using iterator_category
using value_type
using difference_type
using pointer
using reference
Protected Types inherited from llvm::iterator_facade_base< VarStreamArrayIterator< ValueType, Extractor >, std::forward_iterator_tag, const ValueType >
enum  

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 156 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

Definition at line 163 of file BinaryStreamArray.h.

References llvm::consumeError(), E(), and llvm::Offset.

◆ 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 179 of file BinaryStreamArray.h.

References E().

◆ ~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 228 of file BinaryStreamArray.h.

◆ offset()

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

Definition at line 227 of file BinaryStreamArray.h.

◆ operator*()

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

Definition at line 197 of file BinaryStreamArray.h.

References assert().

◆ operator+=()

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

Definition at line 202 of file BinaryStreamArray.h.

References llvm::consumeError(), I, and N.

◆ operator==()

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

Definition at line 182 of file BinaryStreamArray.h.

References assert().


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