The Battle for Wesnoth  1.15.2+dev
Public Member Functions | List of all members
wfl::variant_value_base Class Reference

Base class for all variant types. More...

#include <variant_value.hpp>

Inheritance diagram for wfl::variant_value_base:
Inheritance graph

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 (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 VARIANT_TYPE & get_type () const
 Returns the id of the variant type. More...
 
virtual boost::iterator_range< variant_iteratormake_iterator () const
 Creates an iterator pair that can be used for iteration. More...
 
virtual variant deref_iterator (const boost::any &iter) const
 Implements the dereference functionality of variant_iterator for a value of this type. More...
 
virtual void iterator_inc (boost::any &) const
 Implements the increment functionality of variant_iterator for a value of this type. More...
 
virtual void iterator_dec (boost::any &) const
 Implements the decrement functionality of variant_iterator for a value of this type. More...
 
virtual bool iterator_equals (const boost::any &, const boost::any &) const
 Implements the equality functionality of variant_iterator for a value of this type. More...
 
virtual ~variant_value_base ()
 

Detailed Description

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 89 of file variant_value.hpp.

Constructor & Destructor Documentation

◆ ~variant_value_base()

virtual wfl::variant_value_base::~variant_value_base ( )
inlinevirtual

Definition at line 201 of file variant_value.hpp.

Member Function Documentation

◆ as_bool()

virtual bool wfl::variant_value_base::as_bool ( ) const
inlinevirtual

◆ deref_iterator()

variant wfl::variant_value_base::deref_iterator ( const boost::any &  iter) const
virtual

Implements the dereference functionality of variant_iterator for a value of this type.

Parameters
iterThe opaque reference that was passed to the variant_iterator by make_iterator.

Reimplemented in wfl::variant_map, wfl::variant_list, and wfl::variant_callable.

Definition at line 28 of file variant_value.cpp.

Referenced by wfl::variant_iterator::operator*().

◆ equals()

virtual bool wfl::variant_value_base::equals ( variant_value_base ) const
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_map, wfl::variant_list, wfl::variant_string, wfl::variant_callable, and wfl::variant_numeric.

Definition at line 132 of file variant_value.hpp.

◆ get_debug_string()

virtual std::string wfl::variant_value_base::get_debug_string ( formula_seen_stack ,
bool   
) const
inlinevirtual

◆ get_serialized_string()

virtual std::string wfl::variant_value_base::get_serialized_string ( ) const
inlinevirtual

◆ get_type()

virtual const VARIANT_TYPE& wfl::variant_value_base::get_type ( ) const
inlinevirtual

Returns the id of the variant type.

Reimplemented in wfl::variant_map, wfl::variant_list, wfl::variant_string, wfl::variant_callable, wfl::variant_decimal, and wfl::variant_int.

Definition at line 147 of file variant_value.hpp.

◆ is_empty()

virtual bool wfl::variant_value_base::is_empty ( ) const
inlinevirtual

Whether the stored value is considered empty or not.

Reimplemented in wfl::variant_container< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_string.

Definition at line 99 of file variant_value.hpp.

◆ iterator_dec()

virtual void wfl::variant_value_base::iterator_dec ( boost::any &  ) const
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_container< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_callable.

Definition at line 185 of file variant_value.hpp.

Referenced by wfl::variant_iterator::operator--().

◆ iterator_equals()

virtual bool wfl::variant_value_base::iterator_equals ( const boost::any &  ,
const boost::any &   
) const
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< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_callable.

Definition at line 196 of file variant_value.hpp.

Referenced by wfl::variant_iterator::operator==().

◆ iterator_inc()

virtual void wfl::variant_value_base::iterator_inc ( boost::any &  ) const
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_container< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_callable.

Definition at line 177 of file variant_value.hpp.

Referenced by wfl::variant_iterator::operator++().

◆ less_than()

virtual bool wfl::variant_value_base::less_than ( variant_value_base ) const
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_map, wfl::variant_list, wfl::variant_string, wfl::variant_callable, and wfl::variant_numeric.

Definition at line 141 of file variant_value.hpp.

◆ make_iterator()

boost::iterator_range< variant_iterator > wfl::variant_value_base::make_iterator ( ) const
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 boost::any parameter.

This creates both the begin and end iterator, but the variant implementation discards one of the two.

Reimplemented in wfl::variant_container< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_callable.

Definition at line 23 of file variant_value.cpp.

Referenced by wfl::variant_callable::make_iterator().

◆ num_elements()

virtual std::size_t wfl::variant_value_base::num_elements ( ) const
inlinevirtual

Returns the number of elements in a type.

Not relevant for every derivative.

Reimplemented in wfl::variant_container< T >, wfl::variant_container< variant_map_raw >, wfl::variant_container< variant_vector >, and wfl::variant_callable.

Definition at line 93 of file variant_value.hpp.

Referenced by wfl::variant_list::equals(), and wfl::variant_list::less_than().

◆ string_cast()

virtual std::string wfl::variant_value_base::string_cast ( ) const
inlinevirtual

The documentation for this class was generated from the following files: