libdom
Loading...
Searching...
No Matches
element.h
Go to the documentation of this file.
1/*
2 * This file is part of libdom.
3 * Licensed under the MIT License,
4 * http://www.opensource.org/licenses/mit-license.php
5 * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
6 */
7
8#ifndef dom_internal_core_element_h_
9#define dom_internal_core_element_h_
10
11#include <stdbool.h>
12
13#include <dom/core/element.h>
14
15#include "core/node.h"
16
17struct dom_document;
18struct dom_element;
19struct dom_namednodemap;
20struct dom_node;
21struct dom_attr;
22struct dom_attr_list;
23struct dom_type_info;
24struct dom_hash_table;
25
43
45 dom_string *name, dom_string *namespace,
46 dom_string *prefix, struct dom_element **result);
47
49 struct dom_element *el, dom_string *name,
50 dom_string *namespace, dom_string *prefix);
51
52void _dom_element_finalise(struct dom_element *ele);
53
54void _dom_element_destroy(struct dom_element *element);
55
56
57/* The virtual functions of dom_element */
59 dom_string **name);
61 dom_string *name, dom_string **value);
63 dom_string *name, dom_string *value);
65 dom_string *name);
67 dom_string *name, struct dom_attr **result);
69 struct dom_attr *attr, struct dom_attr **result);
71 struct dom_attr *attr, struct dom_attr **result);
73 struct dom_element *element, dom_string *name,
74 struct dom_nodelist **result);
75
77 dom_string *namespace, dom_string *localname,
78 dom_string **value);
80 dom_string *namespace, dom_string *qname,
81 dom_string *value);
83 dom_string *namespace, dom_string *localname);
85 dom_string *namespace, dom_string *localname,
86 struct dom_attr **result);
88 struct dom_attr *attr, struct dom_attr **result);
90 struct dom_element *element, dom_string *namespace,
91 dom_string *localname, struct dom_nodelist **result);
93 dom_string *name, bool *result);
95 dom_string *namespace, dom_string *localname,
96 bool *result);
98 struct dom_type_info **result);
100 dom_string *name, bool is_id);
102 dom_string *namespace, dom_string *localname,
103 bool is_id);
105 struct dom_attr *id_attr, bool is_id);
107 lwc_string ***classes, uint32_t *n_classes);
109 lwc_string *name, bool *match);
110
111#define DOM_ELEMENT_VTABLE \
112 _dom_element_get_tag_name, \
113 _dom_element_get_attribute, \
114 _dom_element_set_attribute, \
115 _dom_element_remove_attribute, \
116 _dom_element_get_attribute_node, \
117 _dom_element_set_attribute_node, \
118 _dom_element_remove_attribute_node, \
119 _dom_element_get_elements_by_tag_name, \
120 _dom_element_get_attribute_ns, \
121 _dom_element_set_attribute_ns, \
122 _dom_element_remove_attribute_ns, \
123 _dom_element_get_attribute_node_ns, \
124 _dom_element_set_attribute_node_ns, \
125 _dom_element_get_elements_by_tag_name_ns, \
126 _dom_element_has_attribute, \
127 _dom_element_has_attribute_ns, \
128 _dom_element_get_schema_type_info, \
129 _dom_element_set_id_attribute, \
130 _dom_element_set_id_attribute_ns, \
131 _dom_element_set_id_attribute_node, \
132 _dom_element_get_classes, \
133 _dom_element_has_class
134
135/* Overloading dom_node functions */
137 struct dom_namednodemap **result);
139 bool *result);
142 dom_string *namespace, dom_string **result);
144 dom_string *namespace, bool *result);
146 dom_string *prefix, dom_string **result);
147#define DOM_NODE_VTABLE_ELEMENT \
148 _dom_node_try_destroy, \
149 _dom_node_get_node_name, \
150 _dom_node_get_node_value, \
151 _dom_node_set_node_value, \
152 _dom_node_get_node_type, \
153 _dom_node_get_parent_node, \
154 _dom_node_get_child_nodes, \
155 _dom_node_get_first_child, \
156 _dom_node_get_last_child, \
157 _dom_node_get_previous_sibling, \
158 _dom_node_get_next_sibling, \
159 _dom_element_get_attributes, /*overload*/\
160 _dom_node_get_owner_document, \
161 _dom_node_insert_before, \
162 _dom_node_replace_child, \
163 _dom_node_remove_child, \
164 _dom_node_append_child, \
165 _dom_node_has_child_nodes, \
166 _dom_node_clone_node, \
167 _dom_node_normalize, \
168 _dom_node_is_supported, \
169 _dom_node_get_namespace, \
170 _dom_node_get_prefix, \
171 _dom_node_set_prefix, \
172 _dom_node_get_local_name, \
173 _dom_element_has_attributes, /*overload*/\
174 _dom_node_get_base, \
175 _dom_node_compare_document_position, \
176 _dom_node_get_text_content, \
177 _dom_node_set_text_content, \
178 _dom_node_is_same, \
179 _dom_element_lookup_prefix, /*overload*/\
180 _dom_element_is_default_namespace, /*overload*/\
181 _dom_element_lookup_namespace, /*overload*/\
182 _dom_node_is_equal, \
183 _dom_node_get_feature, \
184 _dom_node_set_user_data, \
185 _dom_node_get_user_data
186
201
203
204/* Parse the attribute's value */
206 dom_string *name, dom_string *value,
207 dom_string **parsed)
208{
209 struct dom_node_internal *node = (struct dom_node_internal *) ele;
210 return ((dom_element_protected_vtable *) node->vtable)->
212}
213#define dom_element_parse_attribute(e, n, v, p) dom_element_parse_attribute( \
214 (dom_element *) (e), (dom_string *) (n), \
215 (dom_string *) (v), (dom_string **) (p))
216
217
218/* The protected virtual function */
221 dom_string **parsed);
224 dom_node_internal **copy);
225
226#define DOM_ELEMENT_PROTECT_VTABLE \
227 _dom_element_parse_attribute
228
229#define DOM_NODE_PROTECT_VTABLE_ELEMENT \
230 __dom_element_destroy, \
231 _dom_element_copy
232
233/* Helper functions*/
235 dom_element *new);
236#define dom_element_copy_internal(o, n) _dom_element_copy_internal( \
237 (dom_element *) (o), (dom_element *) (n))
238
240
241extern const struct dom_element_vtable _dom_element_vtable;
242
243#endif
dom_exception
Definition exceptions.h:24
dom_exception _dom_element_get_schema_type_info(struct dom_element *element, struct dom_type_info **result)
Definition element.c:1066
dom_exception _dom_element_set_attribute(struct dom_element *element, dom_string *name, dom_string *value)
Definition element.c:702
dom_exception _dom_element_has_class(struct dom_element *element, lwc_string *name, bool *match)
Definition element.c:1193
void _dom_element_finalise(struct dom_element *ele)
Definition element.c:617
dom_exception _dom_element_create(struct dom_document *doc, dom_string *name, dom_string *namespace, dom_string *prefix, struct dom_element **result)
Definition element.c:548
dom_exception _dom_element_get_classes(struct dom_element *element, lwc_string ***classes, uint32_t *n_classes)
Definition element.c:1165
dom_exception _dom_element_set_attribute_ns(struct dom_element *element, dom_string *namespace, dom_string *qname, dom_string *value)
Definition element.c:866
dom_exception _dom_element_normalize(dom_node_internal *node)
dom_exception _dom_element_get_attribute(struct dom_element *element, dom_string *name, dom_string **value)
Definition element.c:686
dom_exception _dom_element_copy(dom_node_internal *old, dom_node_internal **copy)
Definition element.c:1529
dom_exception _dom_element_lookup_prefix(dom_node_internal *node, dom_string *namespace, dom_string **result)
Definition element.c:1366
dom_exception _dom_element_get_attribute_node(struct dom_element *element, dom_string *name, struct dom_attr **result)
Definition element.c:734
dom_exception _dom_element_has_attributes(dom_node_internal *node, bool *result)
Definition element.c:1346
dom_exception _dom_element_parse_attribute(dom_element *ele, dom_string *name, dom_string *value, dom_string **parsed)
Definition element.c:1502
dom_exception _dom_element_get_id(struct dom_element *ele, dom_string **id)
Definition element.c:2210
dom_exception _dom_element_set_attribute_node_ns(struct dom_element *element, struct dom_attr *attr, struct dom_attr **result)
Definition element.c:967
dom_exception _dom_element_get_tag_name(struct dom_element *element, dom_string **name)
Definition element.c:667
dom_exception _dom_element_set_id_attribute(struct dom_element *element, dom_string *name, bool is_id)
Definition element.c:1090
dom_exception _dom_element_remove_attribute(struct dom_element *element, dom_string *name)
Definition element.c:716
dom_exception _dom_element_has_attribute_ns(struct dom_element *element, dom_string *namespace, dom_string *localname, bool *result)
Definition element.c:1048
dom_exception _dom_element_remove_attribute_node(struct dom_element *element, struct dom_attr *attr, struct dom_attr **result)
Definition element.c:778
dom_exception _dom_element_set_id_attribute_ns(struct dom_element *element, dom_string *namespace, dom_string *localname, bool is_id)
Definition element.c:1108
void _dom_element_destroy(struct dom_element *element)
Definition element.c:643
dom_exception _dom_element_set_id_attribute_node(struct dom_element *element, struct dom_attr *id_attr, bool is_id)
Definition element.c:1132
dom_exception _dom_element_is_default_namespace(dom_node_internal *node, dom_string *namespace, bool *result)
Definition element.c:1392
dom_exception _dom_element_get_attribute_node_ns(struct dom_element *element, dom_string *namespace, dom_string *localname, struct dom_attr **result)
Definition element.c:937
dom_exception _dom_element_get_elements_by_tag_name_ns(struct dom_element *element, dom_string *namespace, dom_string *localname, struct dom_nodelist **result)
Definition element.c:1003
#define dom_element_parse_attribute(e, n, v, p)
Definition element.h:213
dom_exception _dom_element_get_attributes(dom_node_internal *node, struct dom_namednodemap **result)
Definition element.c:1327
dom_exception _dom_element_get_elements_by_tag_name(struct dom_element *element, dom_string *name, struct dom_nodelist **result)
Definition element.c:797
const struct dom_element_vtable _dom_element_vtable
Definition element.c:35
dom_exception _dom_element_has_attribute(struct dom_element *element, dom_string *name, bool *result)
Definition element.c:1028
dom_exception _dom_element_get_attribute_ns(struct dom_element *element, dom_string *namespace, dom_string *localname, dom_string **value)
Definition element.c:830
dom_exception _dom_element_copy_internal(dom_element *old, dom_element *new)
Definition element.c:1550
dom_exception _dom_element_set_attribute_node(struct dom_element *element, struct dom_attr *attr, struct dom_attr **result)
Definition element.c:757
dom_exception _dom_element_remove_attribute_ns(struct dom_element *element, dom_string *namespace, dom_string *localname)
Definition element.c:914
dom_exception _dom_element_initialise(struct dom_document *doc, struct dom_element *el, dom_string *name, dom_string *namespace, dom_string *prefix)
Definition element.c:583
void __dom_element_destroy(dom_node_internal *node)
Definition element.c:1516
dom_exception _dom_element_lookup_namespace(dom_node_internal *node, dom_string *prefix, dom_string **result)
Definition element.c:1439
Definition element.c:53
Definition attr.c:31
Definition document.h:43
Definition element.h:190
dom_exception(* dom_element_parse_attribute)(dom_element *ele, dom_string *name, dom_string *value, dom_string **parsed)
Definition element.h:193
struct dom_node_protect_vtable base
Definition element.h:191
Definition element.h:24
Definition element.h:29
uint32_t n_classes
Definition element.h:41
dom_string * id_ns
Definition element.h:34
dom_string * id_name
Definition element.h:36
struct dom_node_internal base
Definition element.h:30
struct dom_attr_list * attributes
Definition element.h:32
struct dom_type_info * schema_type_info
Definition element.h:38
lwc_string ** classes
Definition element.h:40
Definition hashtable.c:29
Definition namednodemap.c:26
Definition node.h:54
dom_string * value
Definition node.h:61
const void * vtable
Definition node.h:56
dom_string * name
Definition node.h:58
Definition node.h:39
Definition node.h:79
Definition nodelist.c:26
Definition string.h:19
Definition typeinfo.c:14