libdom
Loading...
Searching...
No Matches
Classes | Functions
attr.c File Reference
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <dom/core/attr.h>
#include <dom/core/document.h>
#include <dom/core/node.h>
#include <dom/core/string.h>
#include "core/attr.h"
#include "core/document.h"
#include "core/entity_ref.h"
#include "core/node.h"
#include "core/element.h"
#include "utils/utils.h"

Classes

struct  dom_attr
 

Functions

dom_exception _dom_attr_create (struct dom_document *doc, dom_string *name, dom_string *namespace, dom_string *prefix, bool specified, struct dom_attr **result)
 
dom_exception _dom_attr_initialise (dom_attr *a, struct dom_document *doc, dom_string *name, dom_string *namespace, dom_string *prefix, bool specified, struct dom_attr **result)
 
void _dom_attr_finalise (dom_attr *attr)
 
void _dom_attr_destroy (struct dom_attr *attr)
 
dom_attr_type dom_attr_get_type (dom_attr *a)
 
dom_exception dom_attr_get_integer (dom_attr *a, uint32_t *value)
 
dom_exception dom_attr_set_integer (dom_attr *a, uint32_t value)
 
dom_exception dom_attr_get_short (dom_attr *a, unsigned short *value)
 
dom_exception dom_attr_set_short (dom_attr *a, unsigned short value)
 
dom_exception dom_attr_get_bool (dom_attr *a, bool *value)
 
dom_exception dom_attr_set_bool (dom_attr *a, bool value)
 
void dom_attr_mark_readonly (dom_attr *a)
 
dom_exception _dom_attr_get_name (struct dom_attr *attr, dom_string **result)
 
dom_exception _dom_attr_get_specified (struct dom_attr *attr, bool *result)
 
dom_exception _dom_attr_get_value (struct dom_attr *attr, dom_string **result)
 
dom_exception _dom_attr_set_value (struct dom_attr *attr, dom_string *value)
 
dom_exception _dom_attr_get_owner (struct dom_attr *attr, struct dom_element **result)
 
dom_exception _dom_attr_get_schema_type_info (struct dom_attr *attr, struct dom_type_info **result)
 
dom_exception _dom_attr_is_id (struct dom_attr *attr, bool *result)
 
dom_exception _dom_attr_get_node_value (dom_node_internal *node, dom_string **result)
 
dom_exception _dom_attr_clone_node (dom_node_internal *node, bool deep, dom_node_internal **result)
 
dom_exception _dom_attr_set_prefix (dom_node_internal *node, dom_string *prefix)
 
dom_exception _dom_attr_lookup_prefix (dom_node_internal *node, dom_string *namespace, dom_string **result)
 
dom_exception _dom_attr_is_default_namespace (dom_node_internal *node, dom_string *namespace, bool *result)
 
dom_exception _dom_attr_lookup_namespace (dom_node_internal *node, dom_string *prefix, dom_string **result)
 
void __dom_attr_destroy (dom_node_internal *node)
 
dom_exception _dom_attr_copy (dom_node_internal *n, dom_node_internal **copy)
 
void _dom_attr_set_isid (struct dom_attr *attr, bool is_id)
 
void _dom_attr_set_specified (struct dom_attr *attr, bool specified)
 
bool _dom_attr_readonly (const dom_attr *a)
 

Function Documentation

◆ __dom_attr_destroy()

void __dom_attr_destroy ( dom_node_internal * node)

◆ _dom_attr_clone_node()

dom_exception _dom_attr_clone_node ( dom_node_internal * node,
bool deep,
dom_node_internal ** result )

◆ _dom_attr_copy()

dom_exception _dom_attr_copy ( dom_node_internal * n,
dom_node_internal ** copy )

◆ _dom_attr_create()

dom_exception _dom_attr_create ( struct dom_document * doc,
dom_string * name,
dom_string * namespace,
dom_string * prefix,
bool specified,
struct dom_attr ** result )

Create an attribute node

Parameters
docThe owning document
nameThe (local) name of the node to create
namespaceThe namespace URI of the attribute, or NULL
prefixThe namespace prefix of the attribute, or NULL
specifiedWhether this attribute is specified
resultPointer to location to receive created attribute
Returns
DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.

doc and name will have their reference counts increased. The caller should make sure that name is a valid NCName here.

The returned attribute will already be referenced.

◆ _dom_attr_destroy()

void _dom_attr_destroy ( struct dom_attr * attr)

Destroy an attribute node

Parameters
attrThe attribute to destroy

The contents of attr will be destroyed and attr will be freed

◆ _dom_attr_finalise()

void _dom_attr_finalise ( dom_attr * attr)

The destructor of dom_attr

Parameters
attrThe attribute
Todo
destroy schema type info

◆ _dom_attr_get_name()

dom_exception _dom_attr_get_name ( struct dom_attr * attr,
dom_string ** result )

Retrieve an attribute's name

Parameters
attrAttribute to retrieve name from
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure

The returned string will have its reference count increased. It is the responsibility of the caller to unref the string once it has finished with it.

◆ _dom_attr_get_node_value()

dom_exception _dom_attr_get_node_value ( dom_node_internal * node,
dom_string ** result )

◆ _dom_attr_get_owner()

dom_exception _dom_attr_get_owner ( struct dom_attr * attr,
struct dom_element ** result )

Retrieve the owning element of an attribute

Parameters
attrThe attribute to extract owning element from
resultPointer to location to receive result
Returns
DOM_NO_ERR.

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

◆ _dom_attr_get_schema_type_info()

dom_exception _dom_attr_get_schema_type_info ( struct dom_attr * attr,
struct dom_type_info ** result )

Retrieve an attribute's type information

Parameters
attrThe attribute to extract type information from
resultPointer to location to receive result
Returns
DOM_NOT_SUPPORTED_ERR, we don't support this API now.

The returned type info will have its reference count increased. The caller should unref it once it has finished with it.

◆ _dom_attr_get_specified()

dom_exception _dom_attr_get_specified ( struct dom_attr * attr,
bool * result )

Determine if attribute was specified or default

Parameters
attrAttribute to inspect
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_attr_get_value()

dom_exception _dom_attr_get_value ( struct dom_attr * attr,
dom_string ** result )

Retrieve an attribute's value

Parameters
attrAttribute to retrieve value from
resultPointer to location to receive result
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure

The returned string will have its reference count increased. It is the responsibility of the caller to unref the string once it has finished with it.

◆ _dom_attr_initialise()

dom_exception _dom_attr_initialise ( dom_attr * a,
struct dom_document * doc,
dom_string * name,
dom_string * namespace,
dom_string * prefix,
bool specified,
struct dom_attr ** result )

Initialise a dom_attr

Parameters
aThe dom_attr
docThe document
nameThe name of this attribute node
namespaceThe namespace of this attribute
prefixThe prefix
specifiedWhether this node is a specified one
resultThe returned node
Returns
DOM_NO_ERR on success, appropriate dom_exception on failure.

◆ _dom_attr_is_default_namespace()

dom_exception _dom_attr_is_default_namespace ( dom_node_internal * node,
dom_string * namespace,
bool * result )

◆ _dom_attr_is_id()

dom_exception _dom_attr_is_id ( struct dom_attr * attr,
bool * result )

Determine if an attribute if of type ID

Parameters
attrThe attribute to inspect
resultPointer to location to receive result
Returns
DOM_NO_ERR.

◆ _dom_attr_lookup_namespace()

dom_exception _dom_attr_lookup_namespace ( dom_node_internal * node,
dom_string * prefix,
dom_string ** result )

◆ _dom_attr_lookup_prefix()

dom_exception _dom_attr_lookup_prefix ( dom_node_internal * node,
dom_string * namespace,
dom_string ** result )

◆ _dom_attr_readonly()

bool _dom_attr_readonly ( const dom_attr * a)

Whether this attribute node is readonly

Parameters
aThe node
Returns
true if this Attr is readonly, false otherwise

◆ _dom_attr_set_isid()

void _dom_attr_set_isid ( struct dom_attr * attr,
bool is_id )

Set/Unset whether this attribute is a ID attribute

Parameters
attrThe attribute
is_idWhether it is a ID attribute

◆ _dom_attr_set_prefix()

dom_exception _dom_attr_set_prefix ( dom_node_internal * node,
dom_string * prefix )

◆ _dom_attr_set_specified()

void _dom_attr_set_specified ( struct dom_attr * attr,
bool specified )

Set/Unset whether the attribute is a specified one.

Parameters
attrThe attribute node
specifiedWhether this attribute is a specified one

◆ _dom_attr_set_value()

dom_exception _dom_attr_set_value ( struct dom_attr * attr,
dom_string * value )

Set an attribute's value

Parameters
attrAttribute to retrieve value from
valueNew value for attribute
Returns
DOM_NO_ERR on success, DOM_NO_MODIFICATION_ALLOWED_ERR if attribute is readonly.

◆ dom_attr_get_bool()

dom_exception dom_attr_get_bool ( dom_attr * a,
bool * value )

Get the bool value of this attribute

Parameters
aThe attribute object
valueThe returned value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool attribute

◆ dom_attr_get_integer()

dom_exception dom_attr_get_integer ( dom_attr * a,
uint32_t * value )

Get the integer value of this attribute

Parameters
aThe attribute object
valueThe returned value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer attribute

◆ dom_attr_get_short()

dom_exception dom_attr_get_short ( dom_attr * a,
unsigned short * value )

Get the short value of this attribute

Parameters
aThe attribute object
valueThe returned value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short attribute

◆ dom_attr_get_type()

dom_attr_type dom_attr_get_type ( dom_attr * a)

Get the Attr Node type

Parameters
aThe attribute node
Returns
the type

◆ dom_attr_mark_readonly()

void dom_attr_mark_readonly ( dom_attr * a)

Set the node as a readonly attribute

Parameters
aThe attribute

◆ dom_attr_set_bool()

dom_exception dom_attr_set_bool ( dom_attr * a,
bool value )

Set the bool value of this attribute

Parameters
aThe attribute object
valueThe new value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a bool attribute

◆ dom_attr_set_integer()

dom_exception dom_attr_set_integer ( dom_attr * a,
uint32_t value )

Set the integer value of this attribute

Parameters
aThe attribute object
valueThe new value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a integer attribute

◆ dom_attr_set_short()

dom_exception dom_attr_set_short ( dom_attr * a,
unsigned short value )

Set the short value of this attribute

Parameters
aThe attribute object
valueThe new value
Returns
DOM_NO_ERR on success, DOM_ATTR_WRONG_TYPE_ERR if the attribute node is not a short attribute