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

A RAII wrapper for Gumbo. More...

Public Member Functions

 Html (const char *buffer) noexcept
 Constructs an Html from a non-owning null-terminated string. More...
 
 Html (const char *buffer, std::size_t size) noexcept
 Constructs an Html from a non-owning pointer. More...
 
 ~Html () noexcept
 
 Html (Html &&) noexcept=default
 
Htmloperator= (Html &&) noexcept=default
 
const GumboNode * root () const noexcept
 Returns a non-owning pointer to the root node of the HTML document. More...
 

Detailed Description

A RAII wrapper for Gumbo.

All HTML is expected to be UTF-8 encoded. Gumbo will parse anything you throw at it. When given invalid or incomplete HTML it will even fix it for you.

Example:
Html page("<html><body>This is a string containing html</body></html>");
const GumboNode * root = page.root();
// root now points to the top most HTML element (<html>).
assert(root);
Rule html_root(HtmlTag::HTML);
assert(html_root.matches(root));
const GumboNode * root() const noexcept
Returns a non-owning pointer to the root node of the HTML document.
Html(const char *buffer) noexcept
Constructs an Html from a non-owning null-terminated string.
@ HTML
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html

Definition at line 46 of file Html.h.

Constructor & Destructor Documentation

◆ Html() [1/3]

hext::Html::Html ( const char *  buffer)
explicitnoexcept

Constructs an Html from a non-owning null-terminated string.

Warning
The buffer must stay alive until the destruction of this instance.
Parameters
bufferA null-terminated string containing HTML.

◆ Html() [2/3]

hext::Html::Html ( const char *  buffer,
std::size_t  size 
)
noexcept

Constructs an Html from a non-owning pointer.

Warning
The buffer must stay alive until the destruction of this instance.
Parameters
bufferA string containing HTML.
sizeThe length of the given buffer.

◆ ~Html()

hext::Html::~Html ( )
noexcept

◆ Html() [3/3]

hext::Html::Html ( Html &&  )
defaultnoexcept

Member Function Documentation

◆ operator=()

Html& hext::Html::operator= ( Html &&  )
defaultnoexcept

◆ root()

const GumboNode* hext::Html::root ( ) const
noexcept

Returns a non-owning pointer to the root node of the HTML document.

Warning
The pointer may not be used after the destruction of this instance.

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