Generalized interface for container variants. More...
#include <variant_value.hpp>
Public Member Functions | |
| virtual bool | is_empty () const override |
| Whether the stored value is considered empty or not. More... | |
| virtual std::size_t | num_elements () const override |
| Returns the number of elements in a type. More... | |
| virtual bool | as_bool () const override |
| Returns a bool expression of the variant value. More... | |
| virtual std::string | string_cast () const override |
| Returns the stored variant value in plain string form. More... | |
| virtual std::string | get_serialized_string () const override |
| Returns the stored variant value in formula syntax. More... | |
| virtual std::string | get_debug_string (formula_seen_stack &seen, bool verbose) const override |
| Returns debug info for the variant value. More... | |
| bool | contains (const variant &member) const |
| virtual boost::iterator_range< variant_iterator > | make_iterator () const override |
| Creates an iterator pair that can be used for iteration. More... | |
| virtual void | iterator_inc (utils::any &) const override |
| Implements the increment functionality of variant_iterator for a value of this type. More... | |
| virtual void | iterator_dec (utils::any &) const override |
| Implements the decrement functionality of variant_iterator for a value of this type. More... | |
| 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. More... | |
| virtual bool | equals (const variant_value_base &other) const override |
| Inherited from variant_value_base. More... | |
| virtual bool | less_than (const variant_value_base &other) const override |
| Inherited from variant_value_base. More... | |
Public Member Functions inherited from wfl::variant_value_base | |
| virtual formula_variant::type | get_type () const |
| Returns the id of the variant type. 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 | ~variant_value_base () |
Protected Types | |
| using | to_string_op = std::function< std::string(const variant &)> |
Protected Member Functions | |
| variant_container ()=default | |
| Only derived classes can instantiate this class. More... | |
Private Member Functions | |
| std::string | to_string_impl (bool annotate, bool annotate_empty, const to_string_op &mod_func) const |
| String conversion helper for string_cast, get_serialized_string, and get_debug_string. More... | |
| const auto & | container () const |
| Read-only access to the underlying container. More... | |
Static Private Member Functions | |
| static const auto & | container_for (const variant_value_base &value) |
| Helper to call get_container for the derived class. More... | |
Generalized interface for container variants.
Definition at line 408 of file variant_value.hpp.
|
protected |
Definition at line 462 of file variant_value.hpp.
|
protecteddefault |
Only derived classes can instantiate this class.
|
inlineoverridevirtual |
Returns a bool expression of the variant value.
Reimplemented from wfl::variant_value_base.
Definition at line 425 of file variant_value.hpp.
References wfl::variant_container< Derived >::is_empty().
|
inlineprivate |
Read-only access to the underlying container.
Definition at line 476 of file variant_value.hpp.
References wfl::variant_container< Derived >::container_for().
Referenced by wfl::variant_container< Derived >::contains(), wfl::variant_container< Derived >::is_empty(), and wfl::variant_container< Derived >::num_elements().
|
inlinestaticprivate |
Helper to call get_container for the derived class.
Definition at line 482 of file variant_value.hpp.
Referenced by wfl::variant_container< Derived >::container(), wfl::variant_container< Derived >::equals(), and wfl::variant_container< Derived >::less_than().
|
inline |
Definition at line 436 of file variant_value.hpp.
References wfl::variant_container< Derived >::container(), and utils::contains().
|
inlineoverridevirtual |
Inherited from variant_value_base.
Reimplemented from wfl::variant_value_base.
Definition at line 450 of file variant_value.hpp.
References wfl::variant_container< Derived >::container_for().
|
overridevirtual |
Returns debug info for the variant value.
Reimplemented from wfl::variant_value_base.
Definition at line 263 of file variant_value.cpp.
References wfl::variant::to_debug_string().
|
overridevirtual |
Returns the stored variant value in formula syntax.
Reimplemented from wfl::variant_value_base.
Definition at line 257 of file variant_value.cpp.
References wfl::variant::serialize_to_string().
|
inlineoverridevirtual |
Whether the stored value is considered empty or not.
Reimplemented from wfl::variant_value_base.
Definition at line 415 of file variant_value.hpp.
References wfl::variant_container< Derived >::container().
Referenced by wfl::variant_container< Derived >::as_bool().
|
overridevirtual |
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 from wfl::variant_value_base.
Definition at line 284 of file variant_value.cpp.
|
overridevirtual |
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 from wfl::variant_value_base.
Definition at line 290 of file variant_value.cpp.
|
overridevirtual |
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 from wfl::variant_value_base.
Definition at line 278 of file variant_value.cpp.
|
inlineoverridevirtual |
Inherited from variant_value_base.
Reimplemented from wfl::variant_value_base.
Definition at line 456 of file variant_value.hpp.
References wfl::variant_container< Derived >::container_for().
|
overridevirtual |
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 from wfl::variant_value_base.
Definition at line 269 of file variant_value.cpp.
|
inlineoverridevirtual |
Returns the number of elements in a type.
Not relevant for every derivative.
Reimplemented from wfl::variant_value_base.
Definition at line 420 of file variant_value.hpp.
References wfl::variant_container< Derived >::container().
|
overridevirtual |
Returns the stored variant value in plain string form.
Reimplemented from wfl::variant_value_base.
Definition at line 251 of file variant_value.cpp.
References wfl::variant::string_cast().
|
private |
String conversion helper for string_cast, get_serialized_string, and get_debug_string.
Derived classes should implement container-specific handling by defining a static to_string_detail function which takes the container's value_type as its first parameter and a to_string_op functor as its second.
Definition at line 218 of file variant_value.cpp.