15 const std::out_of_range& e,
const std::size_t& key,
const std::vector<std::any>& data
38 TokenList(
const std::vector<std::any>& data,
size_t nextIndex = 0);
44 TokenList(
const std::initializer_list<std::any>& initList);
62 [[nodiscard]]
bool empty()
const;
70 template<
typename ReturnType>
73 ReturnType ret {get<ReturnType>(0)};
74 data_.erase(data_.begin());
82 [[nodiscard]]
size_t size()
const;
92 template<
typename ReturnType>
93 [[nodiscard]] ReturnType&
get(
const size_t& idx)
97 return std::any_cast<ReturnType&>(data_.at(idx));
99 catch (
const std::bad_any_cast& e)
101 logBadAnyCast<ReturnType>(e, idx, data_);
104 catch (
const std::out_of_range& e)
118 template<
typename ReturnType>
121 ReturnType& retValue = get<ReturnType&>(nextIndex_);
134 template<
typename ReturnType>
135 [[nodiscard]]
const ReturnType&
get(
const size_t& idx)
const
139 return std::any_cast<const ReturnType&>(data_.at(idx));
141 catch (
const std::bad_any_cast& e)
143 logBadAnyCast<ReturnType>(e, idx, data_);
146 catch (
const std::out_of_range& e)
160 template<
typename ReturnType>
163 const ReturnType& retValue = get<ReturnType>(nextIndex_);
175 [[nodiscard]] std::vector<std::any>&
tokens();
180 std::vector<std::any> data_;
181 mutable size_t nextIndex_;
A class representing a list of tokens.
ReturnType popFront()
Removes first entry of TokenList and returns it.
size_t size() const
Retrieves the size of the token list.
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.
TokenList(const std::vector< std::any > &data, size_t nextIndex=0)
Construct a TokenList object from a vector of std::any.
const ReturnType & next() const
Retrieves the value associated with the nextIndex, casting it to the specified type.
ReturnType & next()
Retrieves the value associated with the nextIndex, casting it to the specified type.
bool empty() const
Checks if the token list is empty.
void remove(size_t index)
Removes a value from the token list based on the specified index.
const ReturnType & get(const size_t &idx) const
Retrieves the value associated with the given index, casting it to the specified type.
std::vector< std::any > & tokens()
TokenList(const TokenList &)
std::any & operator[](const size_t &idx)
Retrieves the value associated with the given index.
ReturnType & get(const size_t &idx)
Retrieves the value associated with the given index, casting it to the specified type.
void logOutRange(const std::out_of_range &e, const std::string &key, const std::unordered_map< std::string, std::any > &data)