Generalized implementation handling container variants. More...
#include <variant_value.hpp>
Public Member Functions | |
variant_container (const T &container) | |
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... | |
T & | get_container () |
const T & | get_container () const |
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... | |
Public Member Functions inherited from wfl::variant_value_base | |
virtual bool | equals (variant_value_base &) const |
Called to determine if this variant is equal to another of the same type. More... | |
virtual bool | less_than (variant_value_base &) const |
Called to determine if this variant is less than another of the same type. More... | |
virtual const 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 | mod_func_t = std::function< std::string(const variant &)> |
Protected Member Functions | |
virtual std::string | to_string_detail (const typename T::value_type &value, mod_func_t mod_func) const =0 |
Private Member Functions | |
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, and get_debug_string. More... | |
Private Attributes | |
T | container_ |
Generalized implementation handling container variants.
This class shouldn't usually be used directly. Instead, it's better to create a new derived class specialized to a specific container type.
Definition at line 415 of file variant_value.hpp.
|
protected |
Definition at line 471 of file variant_value.hpp.
|
inlineexplicit |
Definition at line 418 of file variant_value.hpp.
|
inlineoverridevirtual |
Returns a bool expression of the variant value.
Reimplemented from wfl::variant_value_base.
Definition at line 436 of file variant_value.hpp.
References wfl::variant_container< T >::is_empty().
|
inline |
Definition at line 457 of file variant_value.hpp.
References wfl::variant_container< T >::container_.
|
inline |
Definition at line 441 of file variant_value.hpp.
References wfl::variant_container< T >::container_.
Referenced by wfl::variant::operator+().
|
inline |
Definition at line 446 of file variant_value.hpp.
References wfl::variant_container< T >::container_.
|
overridevirtual |
Returns debug info for the variant value.
Reimplemented from wfl::variant_value_base.
Definition at line 261 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 255 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 426 of file variant_value.hpp.
References wfl::variant_container< T >::container_.
Referenced by wfl::variant_container< T >::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 279 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 285 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 273 of file variant_value.cpp.
|
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 267 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 431 of file variant_value.hpp.
References wfl::variant_container< T >::container_.
|
overridevirtual |
Returns the stored variant value in plain string form.
Reimplemented from wfl::variant_value_base.
Definition at line 249 of file variant_value.cpp.
References wfl::variant::string_cast().
|
protectedpure virtual |
|
private |
Implementation to handle string conversion for string_cast, get_serialized_string, and get_debug_string.
Derived classes should provide type-specific value handling by implementing to_string_detail.
Definition at line 216 of file variant_value.cpp.
|
private |
Definition at line 484 of file variant_value.hpp.
Referenced by wfl::variant_container< T >::contains(), wfl::variant_container< T >::get_container(), wfl::variant_container< T >::is_empty(), and wfl::variant_container< T >::num_elements().