libhext: C++ Library Documentation  1.0.8-3ad0ae4
Public Types | Public Member Functions | List of all members
hext::OnlyChildMatch Class Referencefinal

Matches HTML nodes that are the only child of their parent HTML element. More...

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

Public Types

enum  Option { AnyType = 1 << 1 , OfType = 1 << 2 }
 OnlyChildMatch's options. More...
 

Public Member Functions

 OnlyChildMatch (Option options=Option::AnyType) noexcept
 Constructs an OnlyChildMatch. More...
 
bool matches (const GumboNode *node) const noexcept override
 Returns true if node is the only child of its parent. More...
 
- Public Member Functions inherited from hext::Cloneable< OnlyChildMatch, 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 nodes that are the only child of their parent HTML element.

The intent is to mimic the CSS pseudo-classes only-child and only-child-of-type.

See https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child

Definition at line 37 of file OnlyChildMatch.h.

Member Enumeration Documentation

◆ Option

OnlyChildMatch's options.

Enumerator
AnyType 

Count siblings of any type (:only-child).

OfType 

Only count siblings of the same type (:only-child-of-type).

Definition at line 41 of file OnlyChildMatch.h.

Constructor & Destructor Documentation

◆ OnlyChildMatch()

hext::OnlyChildMatch::OnlyChildMatch ( Option  options = Option::AnyType)
explicitnoexcept

Constructs an OnlyChildMatch.

Parameters
optionsSee OnlyChildMatch::Option. Default: Count any element (:only-child).

Member Function Documentation

◆ matches()

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

Returns true if node is the only child of its parent.

Implements hext::Match.


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