libdom
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
attr.h File Reference
#include <stdbool.h>
#include <dom/core/exceptions.h>
#include <dom/core/node.h>

Go to the source code of this file.

Classes

struct  dom_attr_vtable
 

Macros

#define dom_attr_get_name(a, r)   dom_attr_get_name((struct dom_attr *) (a), (r))
 
#define dom_attr_get_specified(a, r)
 
#define dom_attr_get_value(a, r)   dom_attr_get_value((struct dom_attr *) (a), (r))
 
#define dom_attr_set_value(a, v)   dom_attr_set_value((struct dom_attr *) (a), (v))
 
#define dom_attr_get_owner_element(a, r)
 
#define dom_attr_get_schema_type_info(a, r)
 
#define dom_attr_is_id(a, r)
 

Typedefs

typedef struct dom_attr dom_attr
 
typedef struct dom_attr_vtable dom_attr_vtable
 

Enumerations

enum  dom_attr_type {
  DOM_ATTR_UNSET = 0 , DOM_ATTR_STRING , DOM_ATTR_BOOL , DOM_ATTR_SHORT ,
  DOM_ATTR_INTEGER
}
 

Functions

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)
 

Macro Definition Documentation

◆ dom_attr_get_name

#define dom_attr_get_name ( a,
r )   dom_attr_get_name((struct dom_attr *) (a), (r))

◆ dom_attr_get_owner_element

#define dom_attr_get_owner_element ( a,
r )
Value:
(struct dom_attr *) (a), (struct dom_element **) (r))
#define dom_attr_get_owner_element(a, r)
Definition attr.h:92
Definition attr.c:31
Definition element.h:29

◆ dom_attr_get_schema_type_info

#define dom_attr_get_schema_type_info ( a,
r )
Value:
(struct dom_attr *) (a), (struct dom_type_info **) (r))
#define dom_attr_get_schema_type_info(a, r)
Definition attr.h:101
Definition typeinfo.c:14

◆ dom_attr_get_specified

#define dom_attr_get_specified ( a,
r )
Value:
(struct dom_attr *) (a), (bool *) (r))
#define dom_attr_get_specified(a, r)
Definition attr.h:67

◆ dom_attr_get_value

#define dom_attr_get_value ( a,
r )   dom_attr_get_value((struct dom_attr *) (a), (r))

◆ dom_attr_is_id

#define dom_attr_is_id ( a,
r )
Value:
dom_attr_is_id((struct dom_attr *) (a), \
(bool *) (r))
#define dom_attr_is_id(a, r)
Definition attr.h:109

◆ dom_attr_set_value

#define dom_attr_set_value ( a,
v )   dom_attr_set_value((struct dom_attr *) (a), (v))

Typedef Documentation

◆ dom_attr

typedef struct dom_attr dom_attr

◆ dom_attr_vtable

typedef struct dom_attr_vtable dom_attr_vtable

Enumeration Type Documentation

◆ dom_attr_type

The attribute type

Enumerator
DOM_ATTR_UNSET 
DOM_ATTR_STRING 
DOM_ATTR_BOOL 
DOM_ATTR_SHORT 
DOM_ATTR_INTEGER 

Function Documentation

◆ 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)

Following are our implementation specific APIs.

These APIs are defined for the purpose that there are some attributes in HTML and other DOM module whose type is not DOMString, but uint32_t or boolean, for those types of attributes, clients should call one of the following APIs to set it.

When an Attr node is created, its type is unset and it can be turned into any of the four types. Once the type is fixed by calling any of the four APIs: dom_attr_set_value dom_attr_set_integer dom_attr_set_short dom_attr_set_bool it can't be modified in future.

For integer/short/bool type of attributes, we provide no string repensentation of them, so when you call dom_attr_get_value on these three type of attribute nodes, you will always get a empty dom_string. If you want to do something with Attr node, you must know its type firstly by calling dom_attr_get_type before you decide to call other dom_attr_get_* functions.

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