|
|
Donner
C++20 SVG rendering library
|
Selectors which match against element attributes, such as a[href^="https://"] or h1[title]. More...
#include "donner/css/selectors/AttributeSelector.h"
Classes | |
| struct | Matcher |
| Matcher condition for an attribute selector. More... | |
Public Member Functions | |
| AttributeSelector (WqName name) | |
| Create an AttributeSelector with the given name. | |
| ~AttributeSelector () noexcept=default | |
| Destructor. | |
| AttributeSelector (AttributeSelector &&) noexcept=default | |
| Move constructor. | |
| AttributeSelector & | operator= (AttributeSelector &&) noexcept=default |
| Move assignment operator. | |
| AttributeSelector (const AttributeSelector &) noexcept=default | |
| Copy constructor. | |
| AttributeSelector & | operator= (const AttributeSelector &) noexcept=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. | |
Public Attributes | |
| WqName | name |
| Attribute name. | |
| std::optional< Matcher > | matcher |
| Optional matcher condition. If this is not specified, the attribute existing is sufficient for a match. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const AttributeSelector &obj) |
| Ostream output operator, which outputs a debug string, e.g. AttributeSelector(name Eq(=) value). | |
Selectors which match against element attributes, such as a[href^="https://"] or h1[title].
See https://www.w3.org/TR/selectors-4/#attribute-selectors for the full definition.
Attribute selectors start with a square bracket, specify an attribute name, and an optional Matcher condition to allow matching against the attribute contents.
| struct donner::css::AttributeSelector::Matcher |
Matcher condition for an attribute selector.
This is set when the selector includes a match operator, such as ^= or =, and includes a string and an optional case-insensitive flag.
For a standard case-sensitive matcher, this appears in the source as:
For a case-insensitive matcher, an "i" suffix is added:
| Class Members | ||
|---|---|---|
| bool | caseInsensitive = false | Whether to match case-insensitively. |
| AttrMatcher | op | The match operator. |
| RcString | value | The value to match against. |
|
inlineexplicit |
Create an AttributeSelector with the given name.
| name | The attribute name. |
|
inline |
Returns true if the provided element matches this selector.
| element | The element to check. |