26 #include <boost/range/iterator_range.hpp>
30 class variant_value_base;
31 class variant_iterator;
47 std::shared_ptr<T> res = std::dynamic_pointer_cast<T>(ptr);
60 return dynamic_cast<T&
>(ptr);
61 }
catch(
const std::bad_cast&) {
147 virtual boost::iterator_range<variant_iterator>
make_iterator()
const;
212 return value_ == value_ref_cast<variant_numeric>(other).value_;
217 return value_ < value_ref_cast<variant_numeric>(other).value_;
234 return std::to_string(
value_);
263 value_ =
static_cast<int>(value);
268 }
else if(value < -0.5) {
338 virtual boost::iterator_range<variant_iterator>
make_iterator()
const override;
341 virtual void iterator_inc(utils::any& iter)
const override;
342 virtual void iterator_dec(utils::any& iter)
const override;
390 return string_ == value_ref_cast<variant_string>(other).string_;
395 return string_ < value_ref_cast<variant_string>(other).string_;
422 static_assert((std::is_same_v<variant_vector, T> || std::is_same_v<variant_map_raw, T>),
423 "variant_container only accepts vector or map specifications.");
459 return utils::contains<T, variant>(
container_, member);
464 virtual boost::iterator_range<variant_iterator>
make_iterator()
const override;
468 virtual bool iterator_equals(
const utils::any& first,
const utils::any& second)
const override;
512 return mod_func(container_val);
MacOS doesn't support std::any_cast when targing MacOS < 10.14 (currently we target 10....
void notify_dead() override
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
virtual std::string get_debug_string(formula_seen_stack &seen, bool verbose) const override
Returns debug info for the variant value.
variant_callable(const_formula_callable_ptr callable)
virtual bool as_bool() const override
Returns a bool expression of the variant value.
virtual bool iterator_equals(const utils::any &, const utils::any &) const override
Implements the equality functionality of variant_iterator for a value of this type.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
virtual variant deref_iterator(const utils::any &iter) const override
Implements the dereference functionality of variant_iterator for a value of this type.
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
virtual void iterator_inc(utils::any &iter) const override
Implements the increment functionality of variant_iterator for a value of this type.
virtual std::size_t num_elements() const override
Returns the number of elements in a type.
virtual boost::iterator_range< variant_iterator > make_iterator() const override
Creates an iterator pair that can be used for iteration.
formula_input_vector inputs
virtual void iterator_dec(utils::any &iter) const override
Implements the decrement functionality of variant_iterator for a value of this type.
const_formula_callable_ptr callable_
const_formula_callable_ptr get_callable() const
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
Generalized implementation handling container variants.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
std::string to_string_impl(bool annotate, bool annotate_empty, mod_func_t mod_func) const
Implementation to handle string conversion for string_cast, get_serialized_string,...
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
virtual void iterator_dec(utils::any &) const override
Implements the decrement functionality of variant_iterator for a value of this type.
virtual std::size_t num_elements() const override
Returns the number of elements in a type.
virtual std::string get_debug_string(formula_seen_stack &seen, bool verbose) const override
Returns debug info for the variant value.
virtual boost::iterator_range< variant_iterator > make_iterator() const override
Creates an iterator pair that can be used for iteration.
const T & get_container() const
virtual bool is_empty() const override
Whether the stored value is considered empty or not.
std::function< std::string(const variant &)> mod_func_t
virtual bool as_bool() const override
Returns a bool expression of the variant value.
virtual bool iterator_equals(const utils::any &first, const utils::any &second) const override
Implements the equality functionality of variant_iterator for a value of this type.
virtual std::string to_string_detail(const typename T::value_type &value, mod_func_t mod_func) const =0
virtual void iterator_inc(utils::any &) const override
Implements the increment functionality of variant_iterator for a value of this type.
bool contains(const variant &member) const
variant_container(const T &container)
variant_decimal(int value)
std::string to_string_impl(const bool sign_value) const
variant_decimal(double value)
virtual std::string get_debug_string(formula_seen_stack &, bool) const override
Returns debug info for the variant value.
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
variant build_range_variant(int limit) const
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
virtual std::string get_debug_string(formula_seen_stack &, bool) const override
Returns debug info for the variant value.
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
variant_list(const variant_vector &vec)
virtual variant deref_iterator(const utils::any &) const override
Implements the dereference functionality of variant_iterator for a value of this type.
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
virtual std::string to_string_detail(const variant_vector::value_type &container_val, mod_func_t mod_func) const override
variant list_op(value_base_ptr second, const std::function< variant(variant &, variant &)> &op_func)
Applies the provided function to the corresponding variants in this and another list.
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
variant_map(const variant_map_raw &map)
virtual std::string to_string_detail(const variant_map_raw::value_type &container_val, mod_func_t mod_func) const override
virtual variant deref_iterator(const utils::any &) const override
Implements the dereference functionality of variant_iterator for a value of this type.
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
Base class for numeric variant values.
int get_numeric_value() const
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
virtual bool as_bool() const override
Returns a bool expression of the variant value.
variant_numeric(int value)
virtual std::string get_serialized_string() const override
Returns the stored variant value in formula syntax.
virtual bool as_bool() const override
Returns a bool expression of the variant value.
virtual const formula_variant::type & get_type() const override
Returns the id of the variant type.
virtual std::string string_cast() const override
Returns the stored variant value in plain string form.
variant_string(const std::string &str)
virtual std::string get_debug_string(formula_seen_stack &, bool) const override
Returns debug info for the variant value.
virtual bool is_empty() const override
Whether the stored value is considered empty or not.
virtual bool equals(variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
const std::string & get_string() const
virtual bool less_than(variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
Base class for all variant types.
virtual bool less_than(variant_value_base &) const
Called to determine if this variant is less than another of the same type.
virtual std::string get_debug_string(formula_seen_stack &, bool) const
Returns debug info for the variant value.
virtual bool iterator_equals(const utils::any &, const utils::any &) const
Implements the equality functionality of variant_iterator for a value of this type.
virtual boost::iterator_range< variant_iterator > make_iterator() const
Creates an iterator pair that can be used for iteration.
virtual bool as_bool() const
Returns a bool expression of the variant value.
virtual variant deref_iterator(const utils::any &iter) const
Implements the dereference functionality of variant_iterator for a value of this type.
virtual std::string string_cast() const
Returns the stored variant value in plain string form.
virtual void iterator_dec(utils::any &) const
Implements the decrement functionality of variant_iterator for a value of this type.
virtual const formula_variant::type & get_type() const
Returns the id of the variant type.
virtual bool equals(variant_value_base &) const
Called to determine if this variant is equal to another of the same type.
virtual void iterator_inc(utils::any &) const
Implements the increment functionality of variant_iterator for a value of this type.
virtual std::size_t num_elements() const
Returns the number of elements in a type.
virtual ~variant_value_base()
virtual std::string get_serialized_string() const
Returns the stored variant value in formula syntax.
virtual bool is_empty() const
Whether the stored value is considered empty or not.
static std::shared_ptr< T > value_cast(value_base_ptr ptr)
Casts a variant_value_base shared pointer to a new derived type.
std::shared_ptr< variant_value_base > value_base_ptr
std::vector< variant > variant_vector
std::vector< const_formula_callable_ptr > formula_seen_stack
std::vector< formula_input > formula_input_vector
std::map< variant, variant > variant_map_raw
std::shared_ptr< const formula_callable > const_formula_callable_ptr
static T & value_ref_cast(variant_value_base &ptr)
Casts a variant_value_base reference to a new derived type.
Base class for all the errors encountered by the engine.
type_error(const std::string &str)