libdom
Loading...
Searching...
No Matches
document.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_core_document_h_
9#define dom_core_document_h_
10
11#include <stdbool.h>
12#include <inttypes.h>
13#include <stddef.h>
14#include <stdint.h>
15
16#include <dom/core/exceptions.h>
18#include <dom/core/node.h>
19
20struct dom_attr;
23struct dom_comment;
24struct dom_configuration;
27struct dom_element;
29struct dom_node;
30struct dom_nodelist;
32struct dom_text;
33struct lwc_string_s;
34
36
45
46
47/* DOM Document vtable */
48typedef struct dom_document_vtable {
50
52 struct dom_document_type **result);
54 struct dom_document *doc,
55 dom_implementation **result);
57 struct dom_document *doc, struct dom_element **result);
59 dom_string *tag_name,
60 struct dom_element **result);
62 struct dom_document *doc,
63 struct dom_document_fragment **result);
65 dom_string *data, struct dom_text **result);
67 dom_string *data, struct dom_comment **result);
69 struct dom_document *doc, dom_string *data,
70 struct dom_cdata_section **result);
72 struct dom_document *doc, dom_string *target,
73 dom_string *data,
74 struct dom_processing_instruction **result);
76 dom_string *name, struct dom_attr **result);
78 struct dom_document *doc, dom_string *name,
79 struct dom_entity_reference **result);
81 struct dom_document *doc, dom_string *tagname,
82 struct dom_nodelist **result);
84 struct dom_node *node, bool deep,
85 struct dom_node **result);
87 struct dom_document *doc, dom_string *namespace,
88 dom_string *qname, struct dom_element **result);
90 struct dom_document *doc, dom_string *namespace,
91 dom_string *qname, struct dom_attr **result);
93 struct dom_document *doc, dom_string *namespace,
94 dom_string *localname,
95 struct dom_nodelist **result);
97 struct dom_document *doc, dom_string *id,
98 struct dom_element **result);
100 struct dom_document *doc, dom_string **result);
102 dom_string **result);
104 struct dom_document *doc, bool *result);
106 struct dom_document *doc, bool standalone);
108 dom_string **result);
110 dom_string *version);
112 struct dom_document *doc, bool *result);
114 struct dom_document *doc, bool strict);
116 dom_string **result);
118 dom_string *uri);
120 struct dom_node *node, struct dom_node **result);
122 struct dom_configuration **result);
125 struct dom_node *node, dom_string *namespace,
126 dom_string *qname, struct dom_node **result);
132
133static inline dom_exception dom_document_get_doctype(struct dom_document *doc,
134 struct dom_document_type **result)
135{
136 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
137 dom_document_get_doctype(doc, result);
138}
139#define dom_document_get_doctype(d, r) dom_document_get_doctype( \
140 (dom_document *) (d), (struct dom_document_type **) (r))
141
143 struct dom_document *doc, dom_implementation **result)
144{
145 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
147}
148#define dom_document_get_implementation(d, r) dom_document_get_implementation(\
149 (dom_document *) (d), (dom_implementation **) (r))
150
152 struct dom_document *doc, struct dom_element **result)
153{
154 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
156}
157#define dom_document_get_document_element(d, r) \
158 dom_document_get_document_element((dom_document *) (d), \
159 (struct dom_element **) (r))
160
162 struct dom_document *doc, dom_string *tag_name,
163 struct dom_element **result)
164{
165 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
166 dom_document_create_element(doc, tag_name, result);
167}
168#define dom_document_create_element(d, t, r) dom_document_create_element( \
169 (dom_document *) (d), (t), \
170 (struct dom_element **) (r))
171
173 struct dom_document *doc,
174 struct dom_document_fragment **result)
175{
176 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
178}
179#define dom_document_create_document_fragment(d, r) \
180 dom_document_create_document_fragment((dom_document *) (d), \
181 (struct dom_document_fragment **) (r))
182
184 struct dom_document *doc, dom_string *data,
185 struct dom_text **result)
186{
187 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
188 dom_document_create_text_node(doc, data, result);
189}
190#define dom_document_create_text_node(d, data, r) \
191 dom_document_create_text_node((dom_document *) (d), \
192 (data), (struct dom_text **) (r))
193
195 struct dom_document *doc, dom_string *data,
196 struct dom_comment **result)
197{
198 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
199 dom_document_create_comment(doc, data, result);
200}
201#define dom_document_create_comment(d, data, r) dom_document_create_comment( \
202 (dom_document *) (d), (data), \
203 (struct dom_comment **) (r))
204
206 struct dom_document *doc, dom_string *data,
207 struct dom_cdata_section **result)
208{
209 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
210 dom_document_create_cdata_section(doc, data, result);
211}
212#define dom_document_create_cdata_section(d, data, r) \
213 dom_document_create_cdata_section((dom_document *) (d), \
214 (data), (struct dom_cdata_section **) (r))
215
217 struct dom_document *doc, dom_string *target,
218 dom_string *data,
219 struct dom_processing_instruction **result)
220{
221 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
223 data, result);
224}
225#define dom_document_create_processing_instruction(d, t, data, r) \
226 dom_document_create_processing_instruction( \
227 (dom_document *) (d), (t), (data), \
228 (struct dom_processing_instruction **) (r))
229
231 struct dom_document *doc, dom_string *name,
232 struct dom_attr **result)
233{
234 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
235 dom_document_create_attribute(doc, name, result);
236}
237#define dom_document_create_attribute(d, n, r) dom_document_create_attribute( \
238 (dom_document *) (d), (n), \
239 (struct dom_attr **) (r))
240
242 struct dom_document *doc, dom_string *name,
243 struct dom_entity_reference **result)
244{
245 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
247 result);
248}
249#define dom_document_create_entity_reference(d, n, r) \
250 dom_document_create_entity_reference((dom_document *) (d), \
251 (n), (struct dom_entity_reference **) (r))
252
254 struct dom_document *doc, dom_string *tagname,
255 struct dom_nodelist **result)
256{
257 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
259 result);
260}
261#define dom_document_get_elements_by_tag_name(d, t, r) \
262 dom_document_get_elements_by_tag_name((dom_document *) (d), \
263 (t), (struct dom_nodelist **) (r))
264
265static inline dom_exception dom_document_import_node(struct dom_document *doc,
266 struct dom_node *node, bool deep, struct dom_node **result)
267{
268 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
269 dom_document_import_node(doc, node, deep, result);
270}
271#define dom_document_import_node(d, n, deep, r) dom_document_import_node( \
272 (dom_document *) (d), (dom_node *) (n), (bool) deep, \
273 (dom_node **) (r))
274
276 struct dom_document *doc, dom_string *namespace,
277 dom_string *qname, struct dom_element **result)
278{
279 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
280 dom_document_create_element_ns(doc, namespace,
281 qname, result);
282}
283#define dom_document_create_element_ns(d, n, q, r) \
284 dom_document_create_element_ns((dom_document *) (d), \
285 (n), (q), \
286 (struct dom_element **) (r))
287
289 (struct dom_document *doc, dom_string *namespace,
290 dom_string *qname, struct dom_attr **result)
291{
292 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
294 qname, result);
295}
296#define dom_document_create_attribute_ns(d, n, q, r) \
297 dom_document_create_attribute_ns((dom_document *) (d), \
298 (n), (q), (struct dom_attr **) (r))
299
301 struct dom_document *doc, dom_string *namespace,
302 dom_string *localname, struct dom_nodelist **result)
303{
304 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
306 namespace, localname, result);
307}
308#define dom_document_get_elements_by_tag_name_ns(d, n, l, r) \
309 dom_document_get_elements_by_tag_name_ns((dom_document *) (d),\
310 (n), (l), (struct dom_nodelist **) (r))
311
313 struct dom_document *doc, dom_string *id,
314 struct dom_element **result)
315{
316 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
317 dom_document_get_element_by_id(doc, id, result);
318}
319#define dom_document_get_element_by_id(d, i, r) \
320 dom_document_get_element_by_id((dom_document *) (d), \
321 (i), (struct dom_element **) (r))
322
324 struct dom_document *doc, dom_string **result)
325{
326 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
328}
329#define dom_document_get_input_encoding(d, r) dom_document_get_input_encoding(\
330 (dom_document *) (d), (r))
331
333 struct dom_document *doc, dom_string **result)
334{
335 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
337}
338#define dom_document_get_xml_encoding(d, r) dom_document_get_xml_encoding( \
339 (dom_document *) (d), (r))
340
342 struct dom_document *doc, bool *result)
343{
344 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
346}
347#define dom_document_get_xml_standalone(d, r) dom_document_get_xml_standalone(\
348 (dom_document *) (d), (bool *) (r))
349
351 struct dom_document *doc, bool standalone)
352{
353 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
354 dom_document_set_xml_standalone(doc, standalone);
355}
356#define dom_document_set_xml_standalone(d, s) dom_document_set_xml_standalone(\
357 (dom_document *) (d), (bool) (s))
358
360 struct dom_document *doc, dom_string **result)
361{
362 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
363 dom_document_get_xml_version(doc, result);
364}
365#define dom_document_get_xml_version(d, r) dom_document_get_xml_version( \
366 (dom_document *) (d), (r))
367
369 struct dom_document *doc, dom_string *version)
370{
371 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
372 dom_document_set_xml_version(doc, version);
373}
374#define dom_document_set_xml_version(d, v) dom_document_set_xml_version( \
375 (dom_document *) (d), (v))
376
378 struct dom_document *doc, bool *result)
379{
380 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
382}
383#define dom_document_get_strict_error_checking(d, r) \
384 dom_document_get_strict_error_checking((dom_document *) (d), \
385 (bool *) (r))
386
388 struct dom_document *doc, bool strict)
389{
390 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
392}
393#define dom_document_set_strict_error_checking(d, s) \
394 dom_document_set_strict_error_checking((dom_document *) (d), \
395 (bool) (s))
396
397static inline dom_exception dom_document_get_uri(struct dom_document *doc,
398 dom_string **result)
399{
400 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
401 dom_document_get_uri(doc, result);
402}
403#define dom_document_get_uri(d, r) dom_document_get_uri((dom_document *) (d), \
404 (r))
405
406static inline dom_exception dom_document_set_uri(struct dom_document *doc,
407 dom_string *uri)
408{
409 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
410 dom_document_set_uri(doc, uri);
411}
412#define dom_document_set_uri(d, u) dom_document_set_uri((dom_document *) (d), \
413 (u))
414
415static inline dom_exception dom_document_adopt_node(struct dom_document *doc,
416 struct dom_node *node, struct dom_node **result)
417{
418 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
419 dom_document_adopt_node(doc, node, result);
420}
421#define dom_document_adopt_node(d, n, r) dom_document_adopt_node( \
422 (dom_document *) (d), (dom_node *) (n), (dom_node **) (r))
423
425 struct dom_document *doc, struct dom_configuration **result)
426{
427 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
428 dom_document_get_dom_config(doc, result);
429}
430#define dom_document_get_dom_config(d, r) dom_document_get_dom_config( \
431 (dom_document *) (d), (struct dom_configuration **) (r))
432
433static inline dom_exception dom_document_normalize(struct dom_document *doc)
434{
435 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
437}
438#define dom_document_normalize(d) dom_document_normalize((dom_document *) (d))
439
440static inline dom_exception dom_document_rename_node(struct dom_document *doc,
441 struct dom_node *node,
442 dom_string *namespace, dom_string *qname,
443 struct dom_node **result)
444{
445 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
446 dom_document_rename_node(doc, node, namespace, qname,
447 result);
448}
449#define dom_document_rename_node(d, n, ns, q, r) dom_document_rename_node( \
450 (dom_document *) (d), (ns), \
451 (q), (dom_node **) (r))
452
455{
456 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
457 get_quirks_mode(doc, result);
458}
459#define dom_document_get_quirks_mode(d, r) \
460 dom_document_get_quirks_mode((dom_document *) (d), (r))
461
464{
465 return ((dom_document_vtable *) ((dom_node *) doc)->vtable)->
466 set_quirks_mode(doc, quirks);
467}
468#define dom_document_set_quirks_mode(d, q) \
469 dom_document_set_quirks_mode((dom_document *) (d), (q))
470
471#endif
dom_exception
Definition exceptions.h:24
const char dom_implementation
Definition implementation.h:20
#define dom_document_get_doctype(d, r)
Definition document.h:139
#define dom_document_get_uri(d, r)
Definition document.h:403
#define dom_document_create_comment(d, data, r)
Definition document.h:201
#define dom_document_create_entity_reference(d, n, r)
Definition document.h:249
#define dom_document_get_strict_error_checking(d, r)
Definition document.h:383
#define dom_document_set_xml_standalone(d, s)
Definition document.h:356
#define dom_document_get_element_by_id(d, i, r)
Definition document.h:319
#define dom_document_set_xml_version(d, v)
Definition document.h:374
#define dom_document_create_attribute_ns(d, n, q, r)
Definition document.h:296
#define dom_document_create_text_node(d, data, r)
Definition document.h:190
#define dom_document_create_element(d, t, r)
Definition document.h:168
#define dom_document_get_document_element(d, r)
Definition document.h:157
#define dom_document_get_input_encoding(d, r)
Definition document.h:329
#define dom_document_set_uri(d, u)
Definition document.h:412
#define dom_document_create_document_fragment(d, r)
Definition document.h:179
#define dom_document_get_quirks_mode(d, r)
Definition document.h:459
#define dom_document_create_attribute(d, n, r)
Definition document.h:237
#define dom_document_create_cdata_section(d, data, r)
Definition document.h:212
#define dom_document_get_xml_encoding(d, r)
Definition document.h:338
#define dom_document_adopt_node(d, n, r)
Definition document.h:421
#define dom_document_import_node(d, n, deep, r)
Definition document.h:271
#define dom_document_create_element_ns(d, n, q, r)
Definition document.h:283
#define dom_document_get_xml_standalone(d, r)
Definition document.h:347
#define dom_document_get_elements_by_tag_name(d, t, r)
Definition document.h:261
#define dom_document_get_dom_config(d, r)
Definition document.h:430
struct dom_document_vtable dom_document_vtable
#define dom_document_set_quirks_mode(d, q)
Definition document.h:468
#define dom_document_set_strict_error_checking(d, s)
Definition document.h:393
#define dom_document_normalize(d)
Definition document.h:438
#define dom_document_get_implementation(d, r)
Definition document.h:148
#define dom_document_rename_node(d, n, ns, q, r)
Definition document.h:449
#define dom_document_create_processing_instruction(d, t, data, r)
Definition document.h:225
#define dom_document_get_xml_version(d, r)
Definition document.h:365
dom_document_quirks_mode
Definition document.h:40
@ DOM_DOCUMENT_QUIRKS_MODE_LIMITED
Definition document.h:42
@ DOM_DOCUMENT_QUIRKS_MODE_FULL
Definition document.h:43
@ DOM_DOCUMENT_QUIRKS_MODE_NONE
Definition document.h:41
#define dom_document_get_elements_by_tag_name_ns(d, n, l, r)
Definition document.h:308
Definition attr.c:31
Definition cdatasection.c:19
Definition characterdata.h:18
Definition comment.c:20
Definition doc_fragment.c:21
Definition document_type.c:23
Definition document.h:48
dom_exception(* dom_document_get_xml_standalone)(struct dom_document *doc, bool *result)
Definition document.h:103
dom_exception(* dom_document_get_strict_error_checking)(struct dom_document *doc, bool *result)
Definition document.h:111
dom_exception(* dom_document_create_document_fragment)(struct dom_document *doc, struct dom_document_fragment **result)
Definition document.h:61
dom_exception(* dom_document_normalize)(struct dom_document *doc)
Definition document.h:123
dom_exception(* set_quirks_mode)(dom_document *doc, dom_document_quirks_mode quirks)
Definition document.h:129
dom_exception(* dom_document_set_strict_error_checking)(struct dom_document *doc, bool strict)
Definition document.h:113
dom_exception(* get_quirks_mode)(dom_document *doc, dom_document_quirks_mode *result)
Definition document.h:127
dom_exception(* dom_document_get_xml_encoding)(struct dom_document *doc, dom_string **result)
Definition document.h:101
dom_exception(* dom_document_import_node)(struct dom_document *doc, struct dom_node *node, bool deep, struct dom_node **result)
Definition document.h:83
dom_exception(* dom_document_set_xml_version)(struct dom_document *doc, dom_string *version)
Definition document.h:109
dom_exception(* dom_document_create_attribute)(struct dom_document *doc, dom_string *name, struct dom_attr **result)
Definition document.h:75
dom_exception(* dom_document_set_uri)(struct dom_document *doc, dom_string *uri)
Definition document.h:117
dom_exception(* dom_document_get_dom_config)(struct dom_document *doc, struct dom_configuration **result)
Definition document.h:121
dom_exception(* dom_document_create_text_node)(struct dom_document *doc, dom_string *data, struct dom_text **result)
Definition document.h:64
dom_exception(* dom_document_create_attribute_ns)(struct dom_document *doc, dom_string *namespace, dom_string *qname, struct dom_attr **result)
Definition document.h:89
dom_exception(* dom_document_create_element_ns)(struct dom_document *doc, dom_string *namespace, dom_string *qname, struct dom_element **result)
Definition document.h:86
dom_exception(* dom_document_get_input_encoding)(struct dom_document *doc, dom_string **result)
Definition document.h:99
dom_exception(* dom_document_get_implementation)(struct dom_document *doc, dom_implementation **result)
Definition document.h:53
dom_exception(* dom_document_set_xml_standalone)(struct dom_document *doc, bool standalone)
Definition document.h:105
dom_exception(* dom_document_get_document_element)(struct dom_document *doc, struct dom_element **result)
Definition document.h:56
dom_exception(* dom_document_get_doctype)(struct dom_document *doc, struct dom_document_type **result)
Definition document.h:51
dom_exception(* dom_document_create_entity_reference)(struct dom_document *doc, dom_string *name, struct dom_entity_reference **result)
Definition document.h:77
dom_exception(* dom_document_get_elements_by_tag_name)(struct dom_document *doc, dom_string *tagname, struct dom_nodelist **result)
Definition document.h:80
dom_exception(* dom_document_get_xml_version)(struct dom_document *doc, dom_string **result)
Definition document.h:107
dom_exception(* dom_document_create_element)(struct dom_document *doc, dom_string *tag_name, struct dom_element **result)
Definition document.h:58
dom_exception(* dom_document_get_element_by_id)(struct dom_document *doc, dom_string *id, struct dom_element **result)
Definition document.h:96
dom_exception(* dom_document_create_cdata_section)(struct dom_document *doc, dom_string *data, struct dom_cdata_section **result)
Definition document.h:68
dom_exception(* dom_document_adopt_node)(struct dom_document *doc, struct dom_node *node, struct dom_node **result)
Definition document.h:119
dom_exception(* dom_document_create_processing_instruction)(struct dom_document *doc, dom_string *target, dom_string *data, struct dom_processing_instruction **result)
Definition document.h:71
dom_exception(* dom_document_get_elements_by_tag_name_ns)(struct dom_document *doc, dom_string *namespace, dom_string *localname, struct dom_nodelist **result)
Definition document.h:92
dom_exception(* dom_document_rename_node)(struct dom_document *doc, struct dom_node *node, dom_string *namespace, dom_string *qname, struct dom_node **result)
Definition document.h:124
struct dom_node_vtable base
Definition document.h:49
dom_exception(* dom_document_get_uri)(struct dom_document *doc, dom_string **result)
Definition document.h:115
dom_exception(* dom_document_create_comment)(struct dom_document *doc, dom_string *data, struct dom_comment **result)
Definition document.h:66
Definition document.h:43
Definition element.h:29
Definition entity_ref.c:19
Definition node.h:85
Definition node.h:79
const void * vtable
Definition node.h:80
Definition nodelist.c:26
Definition pi.c:19
Definition string.h:19
Definition text.h:23