Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::css::CompoundSelector Struct Reference

A compound selector is a sequence of simple selectors, which represents a set of conditions that are combined to match a single element. More...

#include "donner/css/selectors/CompoundSelector.h"

Collaboration diagram for donner::css::CompoundSelector:
[legend]

Public Types

using Entry
 A single entry in a compound selector, which can be any of the simple selectors in this variant.
 

Public Member Functions

 CompoundSelector ()=default
 Default constructor.
 
 ~CompoundSelector () noexcept=default
 Destructor.
 
 CompoundSelector (const CompoundSelector &)=default
 Copy constructor.
 
 CompoundSelector (CompoundSelector &&)=default
 Move constructor.
 
CompoundSelectoroperator= (const CompoundSelector &)=default
 Copy assignment operator.
 
CompoundSelectoroperator= (CompoundSelector &&)=default
 Move assignment operator.
 
bool isValid () const
 Return true if this selector is valid and supported by this implementation.
 
template<ElementLike T>
bool matches (const T &element, bool requirePrimary, const SelectorMatchOptions< T > &options) const
 Returns true if the provided element matches this selector.
 

Public Attributes

std::vector< Entryentries
 The list of simple selectors in this compound selector.
 

Friends

std::ostream & operator<< (std::ostream &os, const CompoundSelector &obj)
 Ostream output operator, outputs a debug string, e.g. CompoundSelector(TypeSelector(name)).
 

Detailed Description

A compound selector is a sequence of simple selectors, which represents a set of conditions that are combined to match a single element.

For example, the selector div#foo.bar is a compound selector, while div > #foo is two compound selectors separated by a combinator. Combinators are handled as part of ComplexSelector.

Member Typedef Documentation

◆ Entry

Initial value:
std::variant<PseudoElementSelector, TypeSelector, IdSelector, ClassSelector,
PseudoClassSelector, AttributeSelector>

A single entry in a compound selector, which can be any of the simple selectors in this variant.

Member Function Documentation

◆ isValid()

bool donner::css::CompoundSelector::isValid ( ) const
inline

Return true if this selector is valid and supported by this implementation.

See also
https://www.w3.org/TR/selectors-4/#invalid

◆ matches()

template<ElementLike T>
bool donner::css::CompoundSelector::matches ( const T & element,
bool requirePrimary,
const SelectorMatchOptions< T > & options ) const
inline

Returns true if the provided element matches this selector.

Template Parameters
TA type that fulfills the ElementLike concept, to enable traversing the tree to match the selector.
Parameters
elementThe element to check.
requirePrimaryIf true, only primary selectors are considered.
optionsOptions to control matching.

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