Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::ElementTraversalGenerator< T > Class Template Reference

Selectors may need to traverse the tree in different ways to match, and this is abstracted away using C++20 coroutines. More...

#include "donner/base/element/ElementTraversalGenerators.h"

Classes

class  Promise
 Defines and controls the behavior of the coroutine itself, by implementing methods that are called by the C++ runtime during execution of the coroutine. More...
 

Public Types

using Handle = std::coroutine_handle<Promise>
 The internal handle used to store the coroutine, used to construct ElementTraversalGenerator from a co_yield expression.
 
using promise_type = Promise
 The internal object which stores the current value.
 

Public Member Functions

 ElementTraversalGenerator (Handle h)
 Construct a generator from a coroutine handle.
 
 ElementTraversalGenerator (const ElementTraversalGenerator &)=delete
 Copying generators is not allowed.
 
 ElementTraversalGenerator (ElementTraversalGenerator &&other) noexcept
 Move constructor.
 
ElementTraversalGeneratoroperator= (const ElementTraversalGenerator &)=delete
 Copying generators is not allowed.
 
ElementTraversalGeneratoroperator= (ElementTraversalGenerator &&other) noexcept
 Move assignment.
 
 ~ElementTraversalGenerator ()
 Destructor.
 
bool next ()
 Advance the generator to the next element, and return whether there is another element.
 
getValue ()
 Get the current value of the generator.
 

Detailed Description

template<typename T>
class donner::ElementTraversalGenerator< T >

Selectors may need to traverse the tree in different ways to match, and this is abstracted away using C++20 coroutines.

Each traversal order is a coroutine that yields elements lazily, so that the tree is traversed only as far as necessary.

See also
singleElementGenerator
parentsGenerator
previousSiblingsGenerator

Member Function Documentation

◆ getValue()

template<typename T >
T donner::ElementTraversalGenerator< T >::getValue ( )
inline

Get the current value of the generator.

Precondition
next() must have been called at least once, and returned true.

◆ next()

template<typename T >
bool donner::ElementTraversalGenerator< T >::next ( )
inline

Advance the generator to the next element, and return whether there is another element.

Returns
true if there is another element, false if the generator has finished.

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