The Battle for Wesnoth  1.19.5+dev
Public Types | Public Member Functions | Private Attributes | List of all members
wfl::variant_iterator Class Reference

Iterator class for the variant. More...

#include <variant.hpp>

Public Types

typedef variant value_type
 
typedef std::bidirectional_iterator_tag iterator_category
 
typedef variantreference
 
typedef variantpointer
 
typedef int difference_type
 

Public Member Functions

 variant_iterator ()
 Constructor for a no-op iterator. More...
 
 variant_iterator (const variant_value_base *value, const utils::any &iter)
 Constructor for a generic iterator. More...
 
variant operator* () const
 
variant_iteratoroperator++ ()
 
variant_iterator operator++ (int)
 
variant_iteratoroperator-- ()
 
variant_iterator operator-- (int)
 
bool operator== (const variant_iterator &that) const
 
bool operator!= (const variant_iterator &that) const
 

Private Attributes

formula_variant::type type_
 
const variant_value_basecontainer_
 
utils::any iter_
 

Detailed Description

Iterator class for the variant.

Depending on the type_ the list_iterator_ and the map_iterator_ are a valid iterator or singular. Since most actions on singular iterators result in Undefined Behavior care should be taken when copying the list_iterator_ and map_iterator_.

Definition at line 186 of file variant.hpp.

Member Typedef Documentation

◆ difference_type

Definition at line 193 of file variant.hpp.

◆ iterator_category

typedef std::bidirectional_iterator_tag wfl::variant_iterator::iterator_category

Definition at line 190 of file variant.hpp.

◆ pointer

Definition at line 192 of file variant.hpp.

◆ reference

Definition at line 191 of file variant.hpp.

◆ value_type

Definition at line 189 of file variant.hpp.

Constructor & Destructor Documentation

◆ variant_iterator() [1/2]

wfl::variant_iterator::variant_iterator ( )

Constructor for a no-op iterator.

Definition at line 60 of file variant.cpp.

◆ variant_iterator() [2/2]

wfl::variant_iterator::variant_iterator ( const variant_value_base value,
const utils::any &  iter 
)

Constructor for a generic iterator.

Precondition
iter is not singular.
Parameters
valueA pointer to a variant value representing the container.
iterAn underlying iterator for the underlying container.

Definition at line 67 of file variant.cpp.

Member Function Documentation

◆ operator!=()

bool wfl::variant_iterator::operator!= ( const variant_iterator that) const

Definition at line 134 of file variant.cpp.

References operator==().

◆ operator*()

variant wfl::variant_iterator::operator* ( ) const

Definition at line 74 of file variant.cpp.

References container_, wfl::variant_value_base::deref_iterator(), and iter_.

◆ operator++() [1/2]

variant_iterator & wfl::variant_iterator::operator++ ( )

Definition at line 83 of file variant.cpp.

References container_, iter_, and wfl::variant_value_base::iterator_inc().

◆ operator++() [2/2]

variant_iterator wfl::variant_iterator::operator++ ( int  )

Definition at line 92 of file variant.cpp.

References container_, iter_, and wfl::variant_value_base::iterator_inc().

◆ operator--() [1/2]

variant_iterator & wfl::variant_iterator::operator-- ( )

Definition at line 102 of file variant.cpp.

References container_, iter_, and wfl::variant_value_base::iterator_dec().

◆ operator--() [2/2]

variant_iterator wfl::variant_iterator::operator-- ( int  )

Definition at line 111 of file variant.cpp.

References container_, iter_, and wfl::variant_value_base::iterator_dec().

◆ operator==()

bool wfl::variant_iterator::operator== ( const variant_iterator that) const

Definition at line 121 of file variant.cpp.

References container_, iter_, and wfl::variant_value_base::iterator_equals().

Referenced by operator!=().

Member Data Documentation

◆ container_

const variant_value_base* wfl::variant_iterator::container_
private

Definition at line 219 of file variant.hpp.

Referenced by operator*(), operator++(), operator--(), and operator==().

◆ iter_

utils::any wfl::variant_iterator::iter_
private

Definition at line 220 of file variant.hpp.

Referenced by operator*(), operator++(), operator--(), and operator==().

◆ type_

formula_variant::type wfl::variant_iterator::type_
private

Definition at line 218 of file variant.hpp.


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