libhext: C++ Library Documentation  1.0.12-3ea013c
Public Member Functions | List of all members
hext::FunctionMatch Class Referencefinal

Matches if the result of applying a given MatchFunction to an HTML node returns true. More...

Inheritance diagram for hext::FunctionMatch:
Inheritance graph
[legend]
Collaboration diagram for hext::FunctionMatch:
Collaboration graph
[legend]

Public Member Functions

 FunctionMatch (MatchFunction func)
 Constructs a FunctionMatch that matches HTML nodes for which a given MatchFunction returns true. More...
 
bool matches (const GumboNode *node) const override
 Returns true if the result of calling the given MatchFunction with node as its first argument returns true. More...
 
- Public Member Functions inherited from hext::Cloneable< FunctionMatch, Match >
virtual std::unique_ptr< Matchclone () const override
 Clones objects of template type Derived and returns an owning pointer to the newly allocated Base. More...
 
- Public Member Functions inherited from hext::Match
 Match () noexcept=default
 
 Match (const Match &)=default
 
 Match (Match &&) noexcept=default
 
Matchoperator= (const Match &)=default
 
Matchoperator= (Match &&) noexcept=default
 
virtual ~Match () noexcept=default
 

Detailed Description

Matches if the result of applying a given MatchFunction to an HTML node returns true.

Example:
GumboNode * div = ...; // <div>This is a div!</div>
GumboNode * span = ...; // <span>This is a span!</span>
MatchFunction is_div = [](const GumboNode * node) {
return node->type == GUMBO_NODE_ELEMENT &&
node->v.element.tag == GUMBO_TAG_DIV;
};
FunctionMatch m_is_div(is_div);
assert( m_is_div.matches(div));
assert(!m_is_div.matches(span));
FunctionMatch(MatchFunction func)
Constructs a FunctionMatch that matches HTML nodes for which a given MatchFunction returns true.
std::function< bool(const GumboNode *)> MatchFunction
A type of std::function that receives an HTML element and returns a bool.
Definition: MatchFunction.h:30

Definition at line 50 of file FunctionMatch.h.

Constructor & Destructor Documentation

◆ FunctionMatch()

hext::FunctionMatch::FunctionMatch ( MatchFunction  func)
explicit

Constructs a FunctionMatch that matches HTML nodes for which a given MatchFunction returns true.

Parameters
funcThe MatchFunction that will be applied to an HTML node.

Member Function Documentation

◆ matches()

bool hext::FunctionMatch::matches ( const GumboNode *  node) const
overridevirtual

Returns true if the result of calling the given MatchFunction with node as its first argument returns true.

Parameters
nodeThe node which is to be matched.

Implements hext::Match.


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