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

Selector which match the element's class attribute, for example .foo matches an element with class foo. More...

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

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

Public Member Functions

 ClassSelector (const RcString &name)
 Create a ClassSelector with the given name.
 
 ~ClassSelector () noexcept=default
 Destructor.
 
 ClassSelector (ClassSelector &&)=default
 Move constructor.
 
ClassSelectoroperator= (ClassSelector &&)=default
 Move assignment operator.
 
 ClassSelector (const ClassSelector &)=default
 Copy constructor.
 
ClassSelectoroperator= (const ClassSelector &)=default
 Copy assignment operator.
 
bool isValid () const
 Returns true if this is a valid selector.
 
template<ElementLike T>
bool matches (const T &element) const
 Returns true if the provided element matches this selector, based on if the element's class attribute's whitespace-separated list of classes exactly contains this selector's name.
 

Public Attributes

RcString name
 The class to match, without the leading ..
 

Friends

std::ostream & operator<< (std::ostream &os, const ClassSelector &obj)
 Ostream output operator.
 

Detailed Description

Selector which match the element's class attribute, for example .foo matches an element with class foo.

See https://www.w3.org/TR/selectors-4/#class-html for the full definition.

Constructor & Destructor Documentation

◆ ClassSelector()

donner::css::ClassSelector::ClassSelector ( const RcString & name)
inlineexplicit

Create a ClassSelector with the given name.

Parameters
nameThe class to match, without the leading ..

Member Function Documentation

◆ matches()

template<ElementLike T>
bool donner::css::ClassSelector::matches ( const T & element) const
inline

Returns true if the provided element matches this selector, based on if the element's class attribute's whitespace-separated list of classes exactly contains this selector's name.

Comparison is case-sensitive.

Parameters
elementThe element to check.

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