NeoN
A framework for CFD software
Loading...
Searching...
No Matches
NeoN::TokenList Class Reference

A class representing a list of tokens. More...

#include <tokenList.hpp>

Public Member Functions

 TokenList ()
 TokenList (const TokenList &)
 TokenList (const std::vector< std::any > &data, sizeType nextIndex=0)
 Construct a TokenList object from a vector of std::any.
 TokenList (const std::initializer_list< std::any > &initList)
 Construct a TokenList object from an initializer list of std::any.
void insert (const std::any &value)
 Inserts a value into the token list.
void remove (sizeType index)
 Removes a value from the token list based on the specified index.
bool empty () const
 Checks if the token list is empty.
template<typename ReturnType>
ReturnType popFront ()
 Removes first entry of TokenList and returns it.
sizeType size () const
 Retrieves the size of the token list.
void reset () const
 Rewind the read cursor used by next<>() so the list can be iterated again from the beginning.
template<typename ReturnType>
ReturnType & get (const sizeType &idx)
 Retrieves the value associated with the given index, casting it to the specified type.
template<typename ReturnType>
ReturnType & next ()
 Retrieves the value associated with the nextIndex, casting it to the specified type.
template<typename ReturnType>
const ReturnType & get (const sizeType &idx) const
 Retrieves the value associated with the given index, casting it to the specified type.
template<typename ReturnType>
const ReturnType & next () const
 Retrieves the value associated with the nextIndex, casting it to the specified type.
template<typename ReturnType>
bool peekIs () const
 Checks whether the next token (the one a subsequent next() would return) holds a value of the given type. Does not advance the index and does not emit any logging — safe to use as a speculative peek when the caller wants to consume the token conditionally.
std::any & operator[] (const sizeType &idx)
 Retrieves the value associated with the given index.
std::vector< std::any > & tokens ()

Detailed Description

A class representing a list of tokens.

The TokenList class provides functionality to store and manipulate a list of tokens. It supports insertion, removal, and retrieval of tokens of any type using std::any.

Definition at line 31 of file tokenList.hpp.

Constructor & Destructor Documentation

◆ TokenList() [1/4]

NeoN::TokenList::TokenList ( )

◆ TokenList() [2/4]

NeoN::TokenList::TokenList ( const TokenList & )

◆ TokenList() [3/4]

NeoN::TokenList::TokenList ( const std::vector< std::any > & data,
sizeType nextIndex = 0 )

Construct a TokenList object from a vector of std::any.

Parameters
dataA vector of std::any.

◆ TokenList() [4/4]

NeoN::TokenList::TokenList ( const std::initializer_list< std::any > & initList)

Construct a TokenList object from an initializer list of std::any.

Parameters
initListAn initializer list of std::any.

Member Function Documentation

◆ empty()

bool NeoN::TokenList::empty ( ) const
nodiscard

Checks if the token list is empty.

Returns
True if the token list is empty, false otherwise.

◆ get() [1/2]

template<typename ReturnType>
ReturnType & NeoN::TokenList::get ( const sizeType & idx)
inlinenodiscard

Retrieves the value associated with the given index, casting it to the specified type.

Template Parameters
TThe type to cast the value to.
Parameters
idxThe index to retrieve the value for.
Returns
A reference to the value associated with the index, casted to type T.

Definition at line 104 of file tokenList.hpp.

◆ get() [2/2]

template<typename ReturnType>
const ReturnType & NeoN::TokenList::get ( const sizeType & idx) const
inlinenodiscard

Retrieves the value associated with the given index, casting it to the specified type.

Template Parameters
TThe type to cast the value to.
Parameters
idxThe index to retrieve the value for.
Returns
A const reference to the value associated with the index, casted to type T.

Definition at line 146 of file tokenList.hpp.

◆ insert()

void NeoN::TokenList::insert ( const std::any & value)

Inserts a value into the token list.

Parameters
valueThe value to insert.

◆ next() [1/2]

template<typename ReturnType>
ReturnType & NeoN::TokenList::next ( )
inline

Retrieves the value associated with the nextIndex, casting it to the specified type.

Template Parameters
TThe type to cast the value to.
Returns
A reference to the value associated with the index, casted to type T.

Definition at line 130 of file tokenList.hpp.

◆ next() [2/2]

template<typename ReturnType>
const ReturnType & NeoN::TokenList::next ( ) const
inline

Retrieves the value associated with the nextIndex, casting it to the specified type.

Template Parameters
TThe type to cast the value to.
Returns
A const reference to the value associated with the index, casted to type T.

Definition at line 172 of file tokenList.hpp.

◆ operator[]()

std::any & NeoN::TokenList::operator[] ( const sizeType & idx)
nodiscard

Retrieves the value associated with the given index.

Parameters
idxThe index to retrieve the value for.
Returns
A reference to the value associated with the index.

◆ peekIs()

template<typename ReturnType>
bool NeoN::TokenList::peekIs ( ) const
inlinenodiscard

Checks whether the next token (the one a subsequent next() would return) holds a value of the given type. Does not advance the index and does not emit any logging — safe to use as a speculative peek when the caller wants to consume the token conditionally.

Definition at line 186 of file tokenList.hpp.

◆ popFront()

template<typename ReturnType>
ReturnType NeoN::TokenList::popFront ( )
inline

Removes first entry of TokenList and returns it.

Template Parameters
TThe type to cast the value to.
Returns
The first value.

Definition at line 76 of file tokenList.hpp.

◆ remove()

void NeoN::TokenList::remove ( sizeType index)

Removes a value from the token list based on the specified index.

Parameters
indexThe index of the value to remove.

◆ reset()

void NeoN::TokenList::reset ( ) const
inline

Rewind the read cursor used by next<>() so the list can be iterated again from the beginning.

Definition at line 93 of file tokenList.hpp.

◆ size()

sizeType NeoN::TokenList::size ( ) const
nodiscard

Retrieves the size of the token list.

Returns
The size of the token list.

◆ tokens()

std::vector< std::any > & NeoN::TokenList::tokens ( )
nodiscard

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