Nui
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Nui::Dom::Element Class Reference

#include <element.hpp>

Inheritance diagram for Nui::Dom::Element:
Inheritance graph
[legend]
Collaboration diagram for Nui::Dom::Element:
Collaboration graph
[legend]

Public Types

using collection_type = std::vector< std::shared_ptr< Element > >
 
using iterator = collection_type::iterator
 
using const_iterator = collection_type::const_iterator
 
using value_type = collection_type::value_type
 

Public Member Functions

 Element (HtmlElement const &elem)
 
 Element (Nui::val val)
 This constructor takes ownership of a val. More...
 
 Element ()
 
 Element (Element const &)=delete
 
 Element (Element &&)=delete
 
Elementoperator= (Element const &)=delete
 
Elementoperator= (Element &&)=delete
 
 ~Element ()
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void appendElement (std::invocable< Element &, Renderer const & > auto &&fn)
 
auto appendElement (HtmlElement const &element)
 
auto slotFor (value_type const &value)
 
void replaceElement (std::invocable< Element &, Renderer const & > auto &&fn)
 
auto replaceElement (HtmlElement const &element)
 
auto emplaceElement (HtmlElement const &element)
 
auto emplaceElement (std::invocable< Element &, Renderer const & > auto &&fn)
 
void setTextContent (std::string const &text)
 
void setTextContent (char const *text)
 
void setTextContent (std::string_view text)
 
void appendElements (std::vector< std::function< std::shared_ptr< Element >(Element &, Renderer const &)>> const &elements)
 
auto insert (iterator where, HtmlElement const &element)
 
void setup (HtmlElement const &element)
 Relies on weak_from_this and cannot be used from the constructor. More...
 
auto insert (std::size_t where, HtmlElement const &element)
 
auto & operator[] (std::size_t index)
 
auto const & operator[] (std::size_t index) const
 
auto erase (iterator where)
 
auto erase (iterator first, iterator last)
 
void clearChildren ()
 
bool hasChildren () const
 
std::size_t childCount () const
 
std::string tagName () const
 
- Public Member Functions inherited from Nui::Dom::ChildlessElement
 ChildlessElement (HtmlElement const &elem)
 
 ChildlessElement (Nui::val val)
 
void setProperty (std::string_view key, std::string const &value)
 
void setProperty (std::string_view key, std::string_view value)
 
void setProperty (std::string_view key, char const *value)
 
void setProperty (std::string_view key, std::invocable< Nui::val > auto &&value)
 
template<typename T >
void setProperty (std::string_view key, std::optional< T > const &value)
 
void setProperty (std::string_view key, bool value)
 
template<typename... List>
void setProperty (std::string_view key, std::variant< List... > const &variant)
 
template<typename T >
requires std::integral< T > void setProperty (std::string_view key, T value)
 
template<typename T >
requires std::floating_point< T > void setProperty (std::string_view key, T value)
 
void addEventListener (std::string_view event, std::invocable< Nui::val > auto &&callback)
 
void setAttribute (std::string_view key, std::string const &value)
 
void setAttribute (std::string_view key, std::string_view value)
 
void setAttribute (std::string_view key, std::invocable< Nui::val > auto &&value)
 
void setAttribute (std::string_view key, char const *value)
 
void setAttribute (std::string_view key, bool value)
 
template<typename T >
requires std::integral< T > void setAttribute (std::string_view key, T value)
 
template<typename T >
requires std::floating_point< T > void setAttribute (std::string_view key, T value)
 
void setAttribute (std::string_view key, Nui::val value)
 
template<typename T >
void setAttribute (std::string_view key, std::optional< T > const &value)
 
template<typename... List>
void setAttribute (std::string_view key, std::variant< List... > const &variant)
 
void setNodeValue (std::string_view value)
 
void setNodeValue (std::string const &value)
 
- Public Member Functions inherited from Nui::Dom::BasicElement
 BasicElement (Nui::val val)
 
virtual ~BasicElement ()=default
 
Nui::val const & val () const
 
Nui::valval ()
 
 operator Nui::val const & () const
 
 operator Nui::val & ()
 
 operator Nui::val && () &&
 
template<class Derived >
std::shared_ptr< Derived > shared_from_base ()
 
template<class Derived >
std::weak_ptr< Derived > weak_from_base ()
 
std::string tagName () const
 
std::optional< std::string > namespaceUri () const
 

Static Public Member Functions

static std::shared_ptr< ElementmakeElement (HtmlElement const &element)
 

Additional Inherited Members

- Protected Member Functions inherited from Nui::Dom::ChildlessElement
 ChildlessElement ()
 
- Protected Member Functions inherited from Nui::Dom::BasicElement
 BasicElement ()
 
- Static Protected Member Functions inherited from Nui::Dom::ChildlessElement
static Nui::val createElement (HtmlElement const &element)
 
- Protected Attributes inherited from Nui::Dom::BasicElement
Nui::val element_
 

Member Typedef Documentation

◆ collection_type

using Nui::Dom::Element::collection_type = std::vector<std::shared_ptr<Element> >

◆ const_iterator

using Nui::Dom::Element::const_iterator = collection_type::const_iterator

◆ iterator

using Nui::Dom::Element::iterator = collection_type::iterator

◆ value_type

using Nui::Dom::Element::value_type = collection_type::value_type

Constructor & Destructor Documentation

◆ Element() [1/5]

Nui::Dom::Element::Element ( HtmlElement const &  elem)
inlineexplicit

◆ Element() [2/5]

Nui::Dom::Element::Element ( Nui::val  val)
inlineexplicit

This constructor takes ownership of a val.

This val must not be managed by any other element.

Parameters
val

◆ Element() [3/5]

Nui::Dom::Element::Element ( )
inlineexplicit

◆ Element() [4/5]

Nui::Dom::Element::Element ( Element const &  )
delete

◆ Element() [5/5]

Nui::Dom::Element::Element ( Element &&  )
delete

◆ ~Element()

Nui::Dom::Element::~Element ( )
inline

Member Function Documentation

◆ appendElement() [1/2]

auto Nui::Dom::Element::appendElement ( HtmlElement const &  element)
inline

◆ appendElement() [2/2]

void Nui::Dom::Element::appendElement ( std::invocable< Element &, Renderer const & > auto &&  fn)
inline

◆ appendElements()

void Nui::Dom::Element::appendElements ( std::vector< std::function< std::shared_ptr< Element >(Element &, Renderer const &)>> const &  elements)
inline

◆ begin() [1/2]

iterator Nui::Dom::Element::begin ( )
inline

◆ begin() [2/2]

const_iterator Nui::Dom::Element::begin ( ) const
inline

◆ childCount()

std::size_t Nui::Dom::Element::childCount ( ) const
inline

◆ clearChildren()

void Nui::Dom::Element::clearChildren ( )
inline

◆ emplaceElement() [1/2]

auto Nui::Dom::Element::emplaceElement ( HtmlElement const &  element)
inline

◆ emplaceElement() [2/2]

auto Nui::Dom::Element::emplaceElement ( std::invocable< Element &, Renderer const & > auto &&  fn)
inline

◆ end() [1/2]

iterator Nui::Dom::Element::end ( )
inline

◆ end() [2/2]

const_iterator Nui::Dom::Element::end ( ) const
inline

◆ erase() [1/2]

auto Nui::Dom::Element::erase ( iterator  first,
iterator  last 
)
inline

◆ erase() [2/2]

auto Nui::Dom::Element::erase ( iterator  where)
inline

◆ hasChildren()

bool Nui::Dom::Element::hasChildren ( ) const
inline

◆ insert() [1/2]

auto Nui::Dom::Element::insert ( iterator  where,
HtmlElement const &  element 
)
inline

◆ insert() [2/2]

auto Nui::Dom::Element::insert ( std::size_t  where,
HtmlElement const &  element 
)
inline

◆ makeElement()

static std::shared_ptr<Element> Nui::Dom::Element::makeElement ( HtmlElement const &  element)
inlinestatic

◆ operator=() [1/2]

Element& Nui::Dom::Element::operator= ( Element &&  )
delete

◆ operator=() [2/2]

Element& Nui::Dom::Element::operator= ( Element const &  )
delete

◆ operator[]() [1/2]

auto& Nui::Dom::Element::operator[] ( std::size_t  index)
inline

◆ operator[]() [2/2]

auto const& Nui::Dom::Element::operator[] ( std::size_t  index) const
inline

◆ replaceElement() [1/2]

auto Nui::Dom::Element::replaceElement ( HtmlElement const &  element)
inline

◆ replaceElement() [2/2]

void Nui::Dom::Element::replaceElement ( std::invocable< Element &, Renderer const & > auto &&  fn)
inline

◆ setTextContent() [1/3]

void Nui::Dom::Element::setTextContent ( char const *  text)
inline

◆ setTextContent() [2/3]

void Nui::Dom::Element::setTextContent ( std::string const &  text)
inline

◆ setTextContent() [3/3]

void Nui::Dom::Element::setTextContent ( std::string_view  text)
inline

◆ setup()

void Nui::Dom::Element::setup ( HtmlElement const &  element)
inline

Relies on weak_from_this and cannot be used from the constructor.

◆ slotFor()

auto Nui::Dom::Element::slotFor ( value_type const &  value)
inline

◆ tagName()

std::string Nui::Dom::Element::tagName ( ) const
inline

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