Matches HTML elements having an HTML attribute with a certain name and, optionally, whose value is matched by a ValueTest.
More...
Matches HTML elements having an HTML attribute with a certain name and, optionally, whose value is matched by a ValueTest.
- Example:
GumboNode * node_row = ...;
GumboNode * node_desolation = ...;
"data-row"
);
attr_row.matches(node_row);
attr_row.matches(node_desolation);
"data-row",
std::make_unique<EqualsTest>("desolation")
);
assert(attr_desolation.matches(node_desolation));
assert(!attr_desolation.matches(node_row));
AttributeMatch(std::string attr_name, std::unique_ptr< ValueTest > value_test={}) noexcept
Constructs an AttributeMatch with an optional ValueTest.
Definition at line 59 of file AttributeMatch.h.
◆ AttributeMatch() [1/3]
hext::AttributeMatch::AttributeMatch |
( |
std::string |
attr_name, |
|
|
std::unique_ptr< ValueTest > |
value_test = {} |
|
) |
| |
|
explicitnoexcept |
Constructs an AttributeMatch with an optional ValueTest.
- Parameters
-
attr_name | The name of the HTML attribute. |
value_test | An optional ValueTest which, if given, must return true for the matched HTML attribute's value. |
◆ ~AttributeMatch()
hext::AttributeMatch::~AttributeMatch |
( |
| ) |
|
|
overridedefaultnoexcept |
◆ AttributeMatch() [2/3]
◆ AttributeMatch() [3/3]
◆ matches()
bool hext::AttributeMatch::matches |
( |
const GumboNode * |
node | ) |
const |
|
overridevirtual |
Return true if node has an HTML attribute called attr_name (as given in the constructor).
If a ValueTest was supplied, the ValueTest must return true for the attribute's value.
- Parameters
-
node | A pointer to a GumboNode of type GUMBO_NODE_ELEMENT. |
Implements hext::Match.
◆ operator=() [1/2]
◆ operator=() [2/2]
The documentation for this class was generated from the following file: