25 #include <boost/range/iterator_range.hpp>
29 template<
typename To,
typename From>
32 return static_cast<To&
>(value);
39 class variant_value_base;
40 class variant_iterator;
43 #define IMPLEMENT_VALUE_TYPE(value) \
44 static constexpr auto value_type = value; \
45 formula_variant::type get_type() const override \
117 static constexpr
auto value_type = formula_variant::type::null;
133 virtual boost::iterator_range<variant_iterator>
make_iterator()
const;
246 value_ =
static_cast<int>(value);
251 }
else if(value < -0.5) {
315 virtual boost::iterator_range<variant_iterator>
make_iterator()
const override;
318 virtual void iterator_inc(utils::any& iter)
const override;
319 virtual void iterator_dec(utils::any& iter)
const override;
386 template<
typename Container>
426 virtual boost::iterator_range<variant_iterator>
make_iterator()
const override;
430 virtual bool iterator_equals(
const utils::any& first,
const utils::any& second)
const override;
451 return utils::any_cast<const_iterator&>(iter);
457 return utils::any_cast<const const_iterator&>(iter);
504 #undef IMPLEMENT_VALUE_TYPE
MacOS doesn't support std::any_cast when targing MacOS < 10.14 (currently we target 10....
void notify_dead() override
virtual bool equals(const 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
Required by variant_value_base.
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(const variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
Generalized interface for container variants.
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.
virtual void iterator_dec(utils::any &) const override
Implements the decrement functionality of variant_iterator for a value of this type.
typename Container::const_iterator const_iterator
variant_container(Container &&c)
virtual bool less_than(const variant_value_base &other) const override
Inherited from variant_value_base.
virtual bool is_empty() const override
Whether the stored value is considered empty or not.
virtual std::string get_debug_string(formula_seen_stack &seen, bool verbose) const override
Returns debug info for the variant value.
variant_container(const Container &c)
virtual boost::iterator_range< variant_iterator > make_iterator() const override
Creates an iterator pair that can be used for iteration.
virtual bool as_bool() const override
Returns a bool expression of the variant value.
virtual std::size_t num_elements() const override
Returns the number of elements in a type.
static const_iterator & as_container_iterator(utils::any &iter)
Casts opaque iter to a mutable const_iterator reference.
typename Container::iterator iterator
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 void iterator_inc(utils::any &) const override
Implements the increment functionality of variant_iterator for a value of this type.
virtual bool equals(const variant_value_base &other) const override
Inherited from variant_value_base.
const Container & get_container() const
static const const_iterator & as_container_iterator(const utils::any &iter)
Casts opaque iter to a constant const_iterator reference.
variant_decimal(int value)
std::string to_string_impl(const bool sign_value) const
Required by variant_value_base.
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.
variant build_range_variant(int limit) const
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 std::vector< variant > &vec)
virtual variant deref_iterator(const utils::any &) const override
Required by variant_value_base.
variant_list(std::vector< variant > &&vec)
virtual variant deref_iterator(const utils::any &) const override
Required by variant_value_base.
variant_map(std::map< variant, variant > &&map)
variant_map(const std::map< variant, variant > &map)
Base class for numeric variant values.
int get_numeric_value() const
virtual bool less_than(const variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
virtual bool equals(const 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 std::string string_cast() const override
Returns the stored variant value in plain string form.
virtual bool equals(const variant_value_base &other) const override
Called to determine if this variant is equal to another of the same type.
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.
variant_string(std::string &&str)
virtual bool is_empty() const override
Whether the stored value is considered empty or not.
virtual bool less_than(const variant_value_base &other) const override
Called to determine if this variant is less than another of the same type.
const std::string & get_string() const
std::string string_
Required by variant_value_base.
Base class for all variant types.
virtual bool equals(const variant_value_base &) const
Called to determine if this variant is equal to 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 formula_variant::type get_type() const
Returns the id of the variant type.
virtual bool less_than(const variant_value_base &) const
Called to determine if this variant is less than another of the same type.
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.
static constexpr auto value_type
Each 'final' derived class should define a static type flag.
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.
To & cast_as(To &, From &value)
std::string to_string(const Range &range, const Func &op)
std::string::const_iterator iterator
std::vector< const_formula_callable_ptr > formula_seen_stack
std::vector< formula_input > formula_input_vector
std::shared_ptr< const formula_callable > const_formula_callable_ptr
#define IMPLEMENT_VALUE_TYPE(value)