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

Selector which match the element's id attribute, for example #foo matches an element with an id="foo" attribute. More...

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

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

Public Member Functions

 IdSelector (const RcString &name)
 Create an IdSelector with the given name.
 
 ~IdSelector () noexcept=default
 Destructor.
 
 IdSelector (IdSelector &&)=default
 Move constructor.
 
IdSelectoroperator= (IdSelector &&)=default
 Move assignment operator.
 
 IdSelector (const IdSelector &)=default
 Copy constructor.
 
IdSelectoroperator= (const IdSelector &)=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 a case-sensitive match of the provided id against the element's id attribute.
 

Public Attributes

RcString name
 The id to match, without the leading #.
 

Friends

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

Detailed Description

Selector which match the element's id attribute, for example #foo matches an element with an id="foo" attribute.

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

Constructor & Destructor Documentation

◆ IdSelector()

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

Create an IdSelector with the given name.

Parameters
nameThe id to match, without the leading #.

Member Function Documentation

◆ matches()

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

Returns true if the provided element matches this selector, based on a case-sensitive match of the provided id against the element's id attribute.

Parameters
elementThe element to check.

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