37 TokenList(
const std::initializer_list<std::any>& initList);
55 [[nodiscard]]
bool empty()
const;
63 template<
typename ReturnType>
66 ReturnType ret {get<ReturnType>(0)};
67 data_.erase(data_.begin());
75 [[nodiscard]]
size_t size()
const;
85 template<
typename ReturnType>
86 [[nodiscard]] ReturnType&
get(
const size_t& idx)
90 return std::any_cast<ReturnType&>(data_.at(idx));
92 catch (
const std::bad_any_cast& e)
94 logBadAnyCast<ReturnType>(e, idx, data_);
108 template<
typename ReturnType>
109 [[nodiscard]]
const ReturnType&
get(
const size_t& idx)
const
113 return std::any_cast<const ReturnType&>(data_.at(idx));
115 catch (
const std::bad_any_cast& e)
117 logBadAnyCast<ReturnType>(e, idx, data_);
129 [[nodiscard]] std::vector<std::any>&
tokens();
134 std::vector<std::any> data_;
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.
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.
TokenList(const std::vector< std::any > &data)
Construct a TokenList object from a vector of std::any.
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()
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.