libdom
Loading...
Searching...
No Matches
tokenlist.c File Reference
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <dom/core/element.h>
#include <dom/core/nodelist.h>
#include <dom/core/tokenlist.h>
#include <dom/core/string.h>
#include <dom/events/event.h>
#include <dom/events/event_target.h>
#include <dom/events/event_listener.h>
#include <dom/events/mutation_event.h>
#include "core/element.h"
#include "core/document.h"
#include "utils/utils.h"

Classes

struct  dom_tokenlist
 

Macros

#define DOM_TOKENLIST_GROW_INCREMENT   4
 

Functions

dom_exception dom_tokenlist_create (dom_element *ele, dom_string *attr, dom_tokenlist **list)
 
void dom_tokenlist_ref (dom_tokenlist *list)
 
void dom_tokenlist_unref (dom_tokenlist *list)
 
dom_exception dom_tokenlist_get_length (dom_tokenlist *list, uint32_t *length)
 
dom_exception _dom_tokenlist_item (dom_tokenlist *list, uint32_t index, dom_string **value)
 
dom_exception dom_tokenlist_get_value (dom_tokenlist *list, dom_string **value)
 
dom_exception dom_tokenlist_set_value (dom_tokenlist *list, dom_string *value)
 
dom_exception dom_tokenlist_contains (dom_tokenlist *list, dom_string *value, bool *contains)
 
dom_exception dom_tokenlist_add (dom_tokenlist *list, dom_string *value)
 
dom_exception dom_tokenlist_remove (dom_tokenlist *list, dom_string *value)
 

Macro Definition Documentation

◆ DOM_TOKENLIST_GROW_INCREMENT

#define DOM_TOKENLIST_GROW_INCREMENT   4

Function Documentation

◆ _dom_tokenlist_item()

dom_exception _dom_tokenlist_item ( dom_tokenlist * list,
uint32_t index,
dom_string ** value )

Get a particular item from the tokenlist

Parameters
listThe list to retrieve the item from
indexThe index of the item to retrieve
valueThe value of the item returns here
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_add()

dom_exception dom_tokenlist_add ( dom_tokenlist * list,
dom_string * value )

Add the given value to the tokenlist

Parameters
listThe list to add to
valueThe value to add
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_contains()

dom_exception dom_tokenlist_contains ( dom_tokenlist * list,
dom_string * value,
bool * contains )

Check if the given value is in the tokenlist

Parameters
listThe list to scan for the given value
valueThe value to look for in the token list
containsThis will be set based on whether or not the value is present
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_create()

dom_exception dom_tokenlist_create ( dom_element * ele,
dom_string * attr,
dom_tokenlist ** list )

Create a tokenlist

Parameters
eleThe element which owns the tokenlist attribute
attrThe name of the attribute we are treating as a tokenlist
listThe tokenlist output which is set on success
Returns
DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion

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.

This list will take its own references to ::ele and ::attr

◆ dom_tokenlist_get_length()

dom_exception dom_tokenlist_get_length ( dom_tokenlist * list,
uint32_t * length )

Get the length of the tokenlist

Parameters
listThe list to get the length of
lengthLength of the list outputs here
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_get_value()

dom_exception dom_tokenlist_get_value ( dom_tokenlist * list,
dom_string ** value )

Retrieve the value of the tokenlist as a string

Parameters
listThe list to retrieve the value of
valueThe value of the list returns here
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_ref()

void dom_tokenlist_ref ( dom_tokenlist * list)

Claim a ref on a tokenlist

Parameters
listThe tokenlist to claim a ref on

◆ dom_tokenlist_remove()

dom_exception dom_tokenlist_remove ( dom_tokenlist * list,
dom_string * value )

Remove the given value from the tokenlist

Parameters
listThe list to remove from
valueThe value to remove
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_set_value()

dom_exception dom_tokenlist_set_value ( dom_tokenlist * list,
dom_string * value )

Set the value of the tokenlist as a string

Parameters
listThe list to set the value of
valueThe value to set
Returns
DOM_NO_ERR on success, otherwise the failure code

◆ dom_tokenlist_unref()

void dom_tokenlist_unref ( dom_tokenlist * list)

Release a ref on a tokenlist

Parameters
listThe list to release the reference of

If you release the last ref, this cleans up the tokenlist