libdom
Loading...
Searching...
No Matches
nodelist.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <dom/core/node.h>
#include <dom/core/document.h>
#include <dom/core/nodelist.h>
#include <dom/core/string.h>
#include "core/document.h"
#include "core/node.h"
#include "core/nodelist.h"
#include "utils/utils.h"

Classes

struct  dom_nodelist
 

Functions

dom_exception _dom_nodelist_create (dom_document *doc, nodelist_type type, dom_node_internal *root, dom_string *tagname, dom_string *namespace, dom_string *localname, dom_nodelist **list)
 
void dom_nodelist_ref (dom_nodelist *list)
 
void dom_nodelist_unref (dom_nodelist *list)
 
dom_exception dom_nodelist_get_length (dom_nodelist *list, uint32_t *length)
 
dom_exception _dom_nodelist_item (dom_nodelist *list, uint32_t index, dom_node **node)
 
bool _dom_nodelist_match (dom_nodelist *list, nodelist_type type, dom_node_internal *root, dom_string *tagname, dom_string *namespace, dom_string *localname)
 
bool _dom_nodelist_equal (dom_nodelist *l1, dom_nodelist *l2)
 

Function Documentation

◆ _dom_nodelist_create()

dom_exception _dom_nodelist_create ( dom_document * doc,
nodelist_type type,
dom_node_internal * root,
dom_string * tagname,
dom_string * namespace,
dom_string * localname,
dom_nodelist ** list )

Create a nodelist

Parameters
docOwning document
typeThe type of the NodeList
rootRoot node of subtree that list applies to
tagnameName of nodes in list (or NULL)
namespaceNamespace part of nodes in list (or NULL)
localnameLocal part of nodes in list (or NULL)
listPointer to location to receive list
Returns
DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion

::root must be a node owned by ::doc

The returned list will already be referenced, so the client need not do so explicitly. The client must unref the list once finished with it.

◆ _dom_nodelist_equal()

bool _dom_nodelist_equal ( dom_nodelist * l1,
dom_nodelist * l2 )

Test whether the two NodeList are equal

Parameters
l1One list
l2The other list \reutrn true for equal, false otherwise.

◆ _dom_nodelist_item()

dom_exception _dom_nodelist_item ( dom_nodelist * list,
uint32_t index,
dom_node ** node )

Retrieve an item from a node list

Parameters
listThe list to retrieve the item from
indexThe list index to retrieve
nodePointer to location to receive item
Returns
DOM_NO_ERR.

::index is a zero-based index into list. ::index lies in the range [0, length-1]

The returned node will have had its reference count increased. The client should unref the node once it has finished with it.

NOTE: If node contains a node pointer already, it will NOT be unreffed. Managing the lifetime of that is up to the caller.

◆ _dom_nodelist_match()

bool _dom_nodelist_match ( dom_nodelist * list,
nodelist_type type,
dom_node_internal * root,
dom_string * tagname,
dom_string * namespace,
dom_string * localname )

Match a nodelist instance against a set of nodelist creation parameters

Parameters
listList to match
typeThe type of the NodeList
rootRoot node of subtree that list applies to
tagnameName of nodes in list (or NULL)
namespaceNamespace part of nodes in list (or NULL)
localnameLocal part of nodes in list (or NULL)
Returns
true if list matches, false otherwise

◆ dom_nodelist_get_length()

dom_exception dom_nodelist_get_length ( dom_nodelist * list,
uint32_t * length )

Retrieve the length of a node list

Parameters
listList to retrieve length of
lengthPointer to location to receive length
Returns
DOM_NO_ERR.

◆ dom_nodelist_ref()

void dom_nodelist_ref ( dom_nodelist * list)

Claim a reference on a DOM node list

Parameters
listThe list to claim a reference on

◆ dom_nodelist_unref()

void dom_nodelist_unref ( dom_nodelist * list)

Release a reference on a DOM node list

Parameters
listThe list to release the reference from

If the reference count reaches zero, any memory claimed by the list will be released