Immutable, random access wrapper over a ScannedTokens data structure.
More...
#include <ScannedTokens.hpp>
|
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...
|
|
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
-
TokenT | the language token enum type |
unsigned | int the offset unsigned integer type |
◆ RandomAccessScannedTokens()
Instantiate a random access scanned tokens data structure.
Code spans for all the scanned tokens will be created during construction.
◆ determineCodeSpan() [1/2]
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
-
IndexOutOfRangeException | if 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()
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: