|
Ultralight C++ API 2.0.0
|
#include <Ultralight/dom/ElementList.h>
A fixed list of DOM elements returned by a query or an Element::children() call.
Calls like dom::Document::querySelectorAll() and Element::children() return an ElementList to hold matching elements from a page. You use it in native code to inspect and update groups of elements, such as rows in a table or controls in a form.
Querying a table for rows and iterating over the results looks like this:
An ElementList is a snapshot of elements at the time of the query, unlike live collections on the web. Later changes to the page never add, remove, or reorder entries in the list. Call dom::Document::querySelectorAll() again when you need the current elements.
Removing an element from the page leaves it in the list, and its handle stays valid. Collections like Element::children(), HTMLSelectElement::selectedOptions(), and HTMLFormElement::elements() are live on the web, but return snapshots in the library.
Classes | |
| class | iterator |
| A forward iterator over the list's elements, so range-for works (for (dom::Element el : list)). More... | |
Static Public Member Functions | |
| static ElementList | Adopt (ULDOMElementList handle) |
| Wrap a C handle you own, taking ownership of it. | |
Public Member Functions | |
| ElementList ()=default | |
| Create an empty ElementList (length() is 0). | |
| ElementList (const ElementList &)=delete | |
| ElementList & | operator= (const ElementList &)=delete |
| ElementList (ElementList &&other) noexcept | |
| Move constructor (other becomes empty). | |
| ElementList & | operator= (ElementList &&other) noexcept |
| Move assignment (destroys the current list and other becomes empty). | |
| ~ElementList () | |
| Destroy the list (elements you got from it aren't affected). | |
| size_t | length () const |
| Get the number of elements in the list (length). | |
| size_t | size () const |
| Get the number of elements in the list (the same as length()). | |
| bool | empty () const |
| Whether or not the list has no elements (length() is 0). | |
| Element | item (size_t index) const |
| Get the element at an index (item). | |
| Element | operator[] (size_t index) const |
| Get the element at an index (the same as item()). | |
| iterator | begin () const |
| iterator | end () const |
| ULDOMElementList | raw () const |
| Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMElement.h> functions. | |
| ULDOMElementList | LeakRef () |
| Give up ownership of the C handle and return it. | |
Protected Member Functions | |
| ElementList (ULDOMElementList handle) | |
|
default |
Create an empty ElementList (length() is 0).
|
delete |
|
inlinenoexcept |
Move constructor (other becomes empty).
| other | The ElementList to move from. |
|
inline |
Destroy the list (elements you got from it aren't affected).
|
inlineexplicitprotected |
|
inlinestatic |
Wrap a C handle you own, taking ownership of it.
| handle | A handle from the C API that you would otherwise destroy with ulDestroyDOMElementList() (NULL gives an empty ElementList). |
|
inline |
|
inline |
Whether or not the list has no elements (length() is 0).
|
inline |
|
inline |
Get the element at an index (item).
| index | The zero-based index. |
|
inline |
Give up ownership of the C handle and return it.
This ElementList becomes empty.
|
inline |
Get the number of elements in the list (length).
|
delete |
|
inlinenoexcept |
Move assignment (destroys the current list and other becomes empty).
| other | The ElementList to move from. |
|
inline |
Get the element at an index (the same as item()).
| index | The zero-based index. |
|
inline |
Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMElement.h> functions.
|
inline |
Get the number of elements in the list (the same as length()).