Base class for all variant types. More...
#include <variant_value.hpp>
Public Member Functions | |
| virtual std::size_t | num_elements () const |
| Returns the number of elements in a type. More... | |
| virtual bool | is_empty () const |
| Whether the stored value is considered empty or not. More... | |
| virtual std::string | string_cast () const |
| Returns the stored variant value in plain string form. More... | |
| virtual std::string | get_serialized_string () const |
| Returns the stored variant value in formula syntax. More... | |
| virtual std::string | get_debug_string (formula_seen_stack &, bool) const |
| Returns debug info for the variant value. More... | |
| virtual bool | as_bool () const |
| Returns a bool expression of the variant value. More... | |
| virtual bool | equals (const variant_value_base &) const |
| Called to determine if this variant is equal to another of the same type. More... | |
| virtual bool | less_than (const variant_value_base &) const |
| Called to determine if this variant is less than another of the same type. More... | |
| virtual formula_variant::type | get_type () const |
| Returns the id of the variant type. More... | |
| virtual boost::iterator_range< variant_iterator > | make_iterator () const |
| Creates an iterator pair that can be used for iteration. More... | |
| virtual variant | deref_iterator (const utils::any &iter) const |
| Implements the dereference functionality of variant_iterator for a value of this type. More... | |
| virtual void | iterator_inc (utils::any &) const |
| Implements the increment functionality of variant_iterator for a value of this type. More... | |
| virtual void | iterator_dec (utils::any &) const |
| Implements the decrement functionality of variant_iterator for a value of this type. More... | |
| virtual bool | iterator_equals (const utils::any &, const utils::any &) const |
| Implements the equality functionality of variant_iterator for a value of this type. More... | |
| virtual | ~variant_value_base () |
Static Public Attributes | |
| static constexpr auto | value_type = formula_variant::type::null |
| Each 'final' derived class should define a static type flag. More... | |
Base class for all variant types.
This provides a common interface for all type classes to implement, as well as giving variant a base pointer type for its value member. It also serves as the implementation of the 'null' variant value.
Do note this class should not implement any data members.
Definition at line 59 of file variant_value.hpp.
|
inlinevirtual |
Definition at line 173 of file variant_value.hpp.
|
inlinevirtual |
Returns a bool expression of the variant value.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_string, wfl::variant_callable, and wfl::variant_numeric.
Definition at line 93 of file variant_value.hpp.
|
virtual |
Implements the dereference functionality of variant_iterator for a value of this type.
| iter | The opaque reference that was passed to the variant_iterator by make_iterator. |
Reimplemented in wfl::variant_callable, wfl::variant_map, and wfl::variant_list.
Definition at line 45 of file variant_value.cpp.
Referenced by wfl::variant_iterator::operator*().
|
inlinevirtual |
Called to determine if this variant is equal to another of the same type.
This function is only called if get_type() returns the same result for both arguments.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_string, wfl::variant_callable, and wfl::variant_numeric.
Definition at line 102 of file variant_value.hpp.
|
inlinevirtual |
Returns debug info for the variant value.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_callable, wfl::variant_string, wfl::variant_decimal, and wfl::variant_int.
Definition at line 87 of file variant_value.hpp.
References get_serialized_string().
|
inlinevirtual |
Returns the stored variant value in formula syntax.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_string, wfl::variant_callable, wfl::variant_decimal, and wfl::variant_int.
Definition at line 81 of file variant_value.hpp.
Referenced by get_debug_string().
|
inlinevirtual |
Returns the id of the variant type.
Definition at line 120 of file variant_value.hpp.
References value_type.
|
inlinevirtual |
Whether the stored value is considered empty or not.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, and wfl::variant_string.
Definition at line 69 of file variant_value.hpp.
|
inlinevirtual |
Implements the decrement functionality of variant_iterator for a value of this type.
The parameter is an opaque reference that was passed to the variant_iterator by make_iterator.
Reimplemented in wfl::variant_callable, wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, and wfl::variant_container< std::map< variant, variant > >.
Definition at line 157 of file variant_value.hpp.
Referenced by wfl::variant_iterator::operator--().
|
inlinevirtual |
Implements the equality functionality of variant_iterator for a value of this type.
Note that this is only called if the two iterators are already known to be of the same type.
The first parameter is an opaque reference that was passed to the variant_iterator by make_iterator. The second parameter is an opaque reference that was passed to the variant_iterator by make_iterator.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, and wfl::variant_callable.
Definition at line 168 of file variant_value.hpp.
Referenced by wfl::variant_iterator::operator==().
|
inlinevirtual |
Implements the increment functionality of variant_iterator for a value of this type.
The parameter is an opaque reference that was passed to the variant_iterator by make_iterator.
Reimplemented in wfl::variant_callable, wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, and wfl::variant_container< std::map< variant, variant > >.
Definition at line 149 of file variant_value.hpp.
Referenced by wfl::variant_iterator::operator++().
|
inlinevirtual |
Called to determine if this variant is less than another of the same type.
This function is only called if get_type() returns the same result for both arguments.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_string, wfl::variant_callable, and wfl::variant_numeric.
Definition at line 111 of file variant_value.hpp.
|
virtual |
Creates an iterator pair that can be used for iteration.
For an iterable type, it should use the two-argument constructor of variant-iterator, passing the underlying iterator as the utils::any parameter.
This creates both the begin and end iterator, but the variant implementation discards one of the two.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, and wfl::variant_callable.
Definition at line 40 of file variant_value.cpp.
Referenced by wfl::variant_callable::make_iterator().
|
inlinevirtual |
Returns the number of elements in a type.
Not relevant for every derivative.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, and wfl::variant_callable.
Definition at line 63 of file variant_value.hpp.
|
inlinevirtual |
Returns the stored variant value in plain string form.
Reimplemented in wfl::variant_container< Container >, wfl::variant_container< std::vector< variant > >, wfl::variant_container< std::map< variant, variant > >, wfl::variant_string, wfl::variant_callable, wfl::variant_decimal, and wfl::variant_int.
Definition at line 75 of file variant_value.hpp.
|
staticconstexpr |
Each 'final' derived class should define a static type flag.
Definition at line 117 of file variant_value.hpp.
Referenced by get_type().