Static Public Member Functions | Public Member Functions | List of all members
RandomAccessScannedTokens< TokenT > Class Template Reference

Immutable, random access wrapper over a ScannedTokens data structure. More...

#include <ScannedTokens.hpp>

Static Public Member Functions

static CodeSpan determineCodeSpan (const ScannedTokens< TokenT > &scannedTokens, unsigned int index)
 Utility to determine the overall code span for the specified index. More...
 
static CodeSpan determineCodeSpan (const std::string &text, const std::vector< TokenT > &tokens, const std::vector< unsigned int > &startOffsets, unsigned int index)
 Utility to determine the overall code span for the specified index. More...
 

Public Member Functions

 RandomAccessScannedTokens (ScannedTokens< TokenT > &&scannedTokens_)
 Instantiate a random access scanned tokens data structure. More...
 
const std::vector< CodeSpan > & getCodeSpans () const
 Get the pre-calculated code spans of each scanned token. More...
 
const ScannedTokens< TokenT > & getScannedTokens () const
 Get the scanned tokens structure that this random access wrapper contains. More...
 
std::string && moveTextOut ()
 Move the input text string to its final destination. More...
 

Detailed Description

template<typename TokenT>
class Balau::Lang::RandomAccessScannedTokens< TokenT >

Immutable, random access wrapper over a ScannedTokens data structure.

This class has a memory overhead which is greater than that of the ScannedTokens data structure due to the code span information.

Template Parameters
TokenTthe language token enum type
unsignedint the offset unsigned integer type

Constructor & Destructor Documentation

◆ RandomAccessScannedTokens()

RandomAccessScannedTokens ( ScannedTokens< TokenT > &&  scannedTokens_)
inlineexplicit

Instantiate a random access scanned tokens data structure.

Code spans for all the scanned tokens will be created during construction.

Member Function Documentation

◆ determineCodeSpan() [1/2]

static CodeSpan determineCodeSpan ( const ScannedTokens< TokenT > &  scannedTokens,
unsigned int  index 
)
inlinestatic

Utility to determine the overall code span for the specified index.

This method will iterate through all the tokens in order to build the code span.

Returns
the overall code span for the supplied scanned tokens

◆ determineCodeSpan() [2/2]

static CodeSpan determineCodeSpan ( const std::string &  text,
const std::vector< TokenT > &  tokens,
const std::vector< unsigned int > &  startOffsets,
unsigned int  index 
)
inlinestatic

Utility to determine the overall code span for the specified index.

This method will iterate through all the tokens in order to build the code span.

Exceptions
IndexOutOfRangeExceptionif the specified index is greater or equal to the vector size

◆ getCodeSpans()

const std::vector<CodeSpan>& getCodeSpans ( ) const
inline

Get the pre-calculated code spans of each scanned token.

Returns
the pre-calculated code spans of each scanned token

◆ getScannedTokens()

const ScannedTokens<TokenT>& getScannedTokens ( ) const
inline

Get the scanned tokens structure that this random access wrapper contains.

Returns
the scanned tokens structure that this random access wrapper contains

◆ moveTextOut()

std::string&& moveTextOut ( )
inline

Move the input text string to its final destination.

The scanned tokens instance must not be used after the move is performed.

Returns
the input text string as an rvalue

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