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

Returned by Selector::matches to indicate whether the selector matched, and if so, the specificity of the match. More...

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

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

Public Member Functions

 operator bool () const
 Returns true if the selector matched.
 

Static Public Member Functions

static constexpr SelectorMatchResult None ()
 Create a SelectorMatchResult indicating that the selector did not match.
 
static constexpr SelectorMatchResult Match (Specificity specificity)
 Create a SelectorMatchResult indicating that the selector matched, with the given specificity.
 

Public Attributes

bool matched = false
 True if the selector matched.
 
Specificity specificity
 The specificity of the match, if matched.
 

Detailed Description

Returned by Selector::matches to indicate whether the selector matched, and if so, the specificity of the match.

The bool operator can be used to check if the selector matched:

if (auto match = selector.matches(element); match) {
// ...
}

To construct, use the static methods: None() and Match().

Examples
custom_css_parser.cc.

Member Function Documentation

◆ Match()

static constexpr SelectorMatchResult donner::css::SelectorMatchResult::Match ( Specificity specificity)
inlinestaticconstexpr

Create a SelectorMatchResult indicating that the selector matched, with the given specificity.

Parameters
specificityThe specificity of the match.

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