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

Matches HTML elements that have a certain amount of children of type element (excluding text nodes, document nodes and others). More...

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

Public Member Functions

 ChildCountMatch (unsigned int child_count) noexcept
 Construct a ChildCountMatch that matches HTML elements with a child_count amount of children. More...
 
bool matches (const GumboNode *node) const noexcept override
 Return true if node has child_count amount of children. More...
 
- Public Member Functions inherited from hext::Cloneable< ChildCountMatch, 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 HTML elements that have a certain amount of children of type element (excluding text nodes, document nodes and others).

Example:
GumboNode * none = ...; // <div>Text nodes are ignored</div>
GumboNode * two = ...; // <ul><li>first</li><li>last</li></ul>
ChildCountMatch m_none(/* child count *&zwj;/ 0);
ChildCountMatch m_two (/* child count *&zwj;/ 2);
assert( m_none.matches(none));
assert(!m_none.matches(two));
assert( m_two.matches(two));
assert(!m_two.matches(none));
ChildCountMatch(unsigned int child_count) noexcept
Construct a ChildCountMatch that matches HTML elements with a child_count amount of children.

Definition at line 48 of file ChildCountMatch.h.

Constructor & Destructor Documentation

◆ ChildCountMatch()

hext::ChildCountMatch::ChildCountMatch ( unsigned int  child_count)
explicitnoexcept

Construct a ChildCountMatch that matches HTML elements with a child_count amount of children.

Member Function Documentation

◆ matches()

bool hext::ChildCountMatch::matches ( const GumboNode *  node) const
overridevirtualnoexcept

Return true if node has child_count amount of children.

Parameters
nodeA pointer to a GumboNode of type GUMBO_NODE_ELEMENT.

Implements hext::Match.


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