All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
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));

Definition at line 44 of file Html.h.

Constructor & Destructor Documentation

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.
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.
hext::Html::~Html ( )
noexcept
hext::Html::Html ( Html &&  )
defaultnoexcept

Member Function Documentation

Html& hext::Html::operator= ( Html &&  )
defaultnoexcept
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: