17 const std::out_of_range& e,
const std::size_t& key,
const std::vector<std::any>& data
40 TokenList(
const std::vector<std::any>& data,
size_t nextIndex = 0);
46 TokenList(
const std::initializer_list<std::any>& initList);
64 [[nodiscard]]
bool empty()
const;
72 template<
typename ReturnType>
75 ReturnType ret {get<ReturnType>(0)};
76 data_.erase(data_.begin());
84 [[nodiscard]]
size_t size()
const;
94 template<
typename ReturnType>
95 [[nodiscard]] ReturnType&
get(
const size_t& idx)
99 return std::any_cast<ReturnType&>(data_.at(idx));
101 catch (
const std::bad_any_cast& e)
103 logBadAnyCast<ReturnType>(e, idx, data_);
106 catch (
const std::out_of_range& e)
120 template<
typename ReturnType>
123 ReturnType& retValue = get<ReturnType&>(nextIndex_);
136 template<
typename ReturnType>
137 [[nodiscard]]
const ReturnType&
get(
const size_t& idx)
const
141 return std::any_cast<const ReturnType&>(data_.at(idx));
143 catch (
const std::bad_any_cast& e)
145 logBadAnyCast<ReturnType>(e, idx, data_);
148 catch (
const std::out_of_range& e)
162 template<
typename ReturnType>
165 const ReturnType& retValue = get<ReturnType>(nextIndex_);
177 [[nodiscard]] std::vector<std::any>&
tokens();
182 std::vector<std::any> data_;
183 mutable size_t nextIndex_;
A class representing a list of tokens.
bool empty() const
Checks if the token list is empty.
size_t size() const
Retrieves the size of the token list.
ReturnType popFront()
Removes first entry of TokenList and returns it.
ReturnType & get(const size_t &idx)
Retrieves the value associated with the given index, casting it to the specified type.
std::vector< std::any > & tokens()
const ReturnType & get(const size_t &idx) const
Retrieves the value associated with the given index, casting it to the specified type.
std::any & operator[](const size_t &idx)
Retrieves the value associated with the given index.
void insert(const std::any &value)
Inserts a value into the token list.
ReturnType & next()
Retrieves the value associated with the nextIndex, casting it to the specified type.
TokenList(const TokenList &)
TokenList(const std::initializer_list< std::any > &initList)
Construct a TokenList object from an initializer list of std::any.
void remove(size_t index)
Removes a value from the token list based on the specified index.
const ReturnType & next() const
Retrieves the value associated with the nextIndex, casting it to the specified type.
TokenList(const std::vector< std::any > &data, size_t nextIndex=0)
Construct a TokenList object from a vector of std::any.
void logOutRange(const std::out_of_range &e, const std::string &key, const std::unordered_map< std::string, std::any > &data)