All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
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 noexceptoverride
 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
 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 36 of file OnlyChildMatch.h.

Member Enumeration Documentation

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 40 of file OnlyChildMatch.h.

Constructor & Destructor Documentation

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

Constructs an OnlyChildMatch.

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

Member Function Documentation

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: