summaryrefslogtreecommitdiff
path: root/src/core/node.h
blob: 277c4411514685fda83b92fe70ea3bbf73748aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * This file is part of libdom.
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
 */

#ifndef dom_internal_core_node_h_
#define dom_internal_core_node_h_

#include <stdbool.h>

#include <dom/core/node.h>

struct dom_string;

/**
 * User data context attached to a DOM node
 */
struct dom_user_data {
	struct dom_string *key;		/**< Key for data */
	void *data;			/**< Client-specific data */
	dom_user_data_handler handler;	/**< Callback function */

	struct dom_user_data *next;	/**< Next in list */
	struct dom_user_data *prev;	/**< Previous in list */
};

/**
 * DOM node object
 *
 * DOM nodes are reference counted
 */
struct dom_node {
	struct dom_string *name;	/**< Node name (this is the local part 
					 * of a QName in the cases where a 
					 * namespace exists) */
	struct dom_string *value;	/**< Node value */
	dom_node_type type;		/**< Node type */
	struct dom_node *parent;	/**< Parent node */
	struct dom_node *first_child;	/**< First child node */
	struct dom_node *last_child;	/**< Last child node */
	struct dom_node *previous;	/**< Previous sibling */
	struct dom_node *next;		/**< Next sibling */

	struct dom_document *owner;	/**< Owning document */

	struct dom_string *namespace;	/**< Namespace URI */
	struct dom_string *prefix;	/**< Namespace prefix */

	struct dom_user_data *user_data;	/**< User data list */

	uint32_t refcnt;		/**< Reference count */
};

void dom_node_destroy(struct dom_node *node);

dom_exception dom_node_initialise(struct dom_node *node,
		struct dom_document *doc, dom_node_type type,
		struct dom_string *name, struct dom_string *value,
		struct dom_string *namespace, struct dom_string *prefix);

void dom_node_finalise(struct dom_document *doc, struct dom_node *node);

bool _dom_node_readonly(const struct dom_node *node);

#endif