docs
Loading...
Searching...
No Matches
NodeList

#include <Ultralight/dom/NodeList.h>

Overview

A fixed list of nodes of any kind (eg, the results of Node::childNodes()).

The list is a snapshot, where the web's childNodes is live. Later changes to the page never add, remove, or reorder its entries, and a node removed from the page stays in the list and stays valid. Call childNodes() again when you need the current children.

for (dom::Node child : list.childNodes()) {
if (child.nodeType() == dom::NodeType::Text)
child.remove();
}
A reference to an item in the DOM tree.
Definition Node.h:147
NodeList childNodes() const
Get the node's children of every kind in order (childNodes).
Definition NodeList.h:171
@ Text
A text node.
Definition Node.h:70

A NodeList can be moved but not copied.

The list doesn't keep its page alive. Once the page goes away, the list keeps its length but its nodes fail safely (see dom::Element).

Classes

class  iterator
 A forward iterator over the list's nodes, so range-for works (for (dom::Node node : list)). More...

Static Public Member Functions

static NodeList Adopt (ULDOMNodeList handle)
 Wrap a C handle you own, taking ownership of it.

Public Member Functions

 NodeList ()=default
 Create an empty NodeList (length() is 0).
 NodeList (const NodeList &)=delete
NodeList & operator= (const NodeList &)=delete
 NodeList (NodeList &&other) noexcept
 Move constructor (other becomes empty).
NodeList & operator= (NodeList &&other) noexcept
 Move assignment (destroys the current list and other becomes empty).
 ~NodeList ()
 Destroy the list (nodes you got from it aren't affected).
size_t length () const
 Get the number of nodes in the list (length).
size_t size () const
 Get the number of nodes in the list (the same as length()).
bool empty () const
 Whether or not the list has no nodes (length() is 0).
Node item (size_t index) const
 Get the node at an index (item).
Node operator[] (size_t index) const
 Get the node at an index (the same as item()).
iterator begin () const
iterator end () const
ULDOMNodeList raw () const
 Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMNode.h> functions.
ULDOMNodeList LeakRef ()
 Give up ownership of the C handle and return it.

Protected Member Functions

 NodeList (ULDOMNodeList handle)

Constructor & Destructor Documentation

◆ NodeList() [1/4]

NodeList ( )
default

Create an empty NodeList (length() is 0).

◆ NodeList() [2/4]

NodeList ( const NodeList & )
delete

◆ NodeList() [3/4]

NodeList ( NodeList && other)
inlinenoexcept

Move constructor (other becomes empty).

Parameters
otherThe NodeList to move from.

◆ ~NodeList()

~NodeList ( )
inline

Destroy the list (nodes you got from it aren't affected).

◆ NodeList() [4/4]

NodeList ( ULDOMNodeList handle)
inlineexplicitprotected

Member Function Documentation

◆ Adopt()

NodeList Adopt ( ULDOMNodeList handle)
inlinestatic

Wrap a C handle you own, taking ownership of it.

Parameters
handleA handle from the C API that you would otherwise destroy with ulDestroyDOMNodeList() (NULL gives an empty NodeList).
Returns
Returns a NodeList that destroys handle when it's done.

◆ begin()

iterator begin ( ) const
inline

◆ empty()

bool empty ( ) const
inline

Whether or not the list has no nodes (length() is 0).

◆ end()

iterator end ( ) const
inline

◆ item()

Node item ( size_t index) const
inline

Get the node at an index (item).

Parameters
indexThe zero-based index.
Returns
Returns the node (empty if index is out of range).

◆ LeakRef()

ULDOMNodeList LeakRef ( )
inline

Give up ownership of the C handle and return it.

This NodeList becomes empty.

Returns
Returns the handle. You must call ulDestroyDOMNodeList() when finished.

◆ length()

size_t length ( ) const
inline

Get the number of nodes in the list (length).

Returns
Returns the number of nodes (0 for an empty NodeList).

◆ operator=() [1/2]

NodeList & operator= ( const NodeList & )
delete

◆ operator=() [2/2]

NodeList & operator= ( NodeList && other)
inlinenoexcept

Move assignment (destroys the current list and other becomes empty).

Parameters
otherThe NodeList to move from.
Returns
Returns this NodeList.

◆ operator[]()

Node operator[] ( size_t index) const
inline

Get the node at an index (the same as item()).

Parameters
indexThe zero-based index.
Returns
Returns the node (empty if index is out of range).

◆ raw()

ULDOMNodeList raw ( ) const
inline

Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMNode.h> functions.

Returns
Returns the handle (NULL for an empty NodeList). This NodeList still owns it, so don't destroy it.

◆ size()

size_t size ( ) const
inline

Get the number of nodes in the list (the same as length()).

Returns
Returns the number of nodes (0 for an empty NodeList).

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