xref: /php-src/ext/dom/private_data.h (revision 6980eba8)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | https://www.php.net/license/3_01.txt                                 |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Niels Dossche <nielsdos@php.net>                            |
14    +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PRIVATE_DATA_H
18 #define PRIVATE_DATA_H
19 
20 #include "xml_common.h"
21 
22 struct php_dom_libxml_ns_mapper {
23 	/* This is used almost all the time for HTML documents, so it makes sense to cache this. */
24 	xmlNsPtr html_ns;
25 	/* Used for every prefixless namespace declaration in XML, so also very common. */
26 	xmlNsPtr prefixless_xmlns_ns;
27 	HashTable uri_to_prefix_map;
28 };
29 
30 typedef struct php_dom_private_data {
31 	php_libxml_private_data_header header;
32 	struct php_dom_libxml_ns_mapper ns_mapper;
33 	HashTable *template_fragments;
34 } php_dom_private_data;
35 
36 typedef struct php_libxml_private_data_header php_libxml_private_data_header;
37 struct php_libxml_private_data_header;
38 
39 struct php_dom_private_data;
40 typedef struct php_dom_private_data php_dom_private_data;
41 
42 struct php_dom_libxml_ns_mapper;
43 typedef struct php_dom_libxml_ns_mapper php_dom_libxml_ns_mapper;
44 
45 php_libxml_private_data_header *php_dom_libxml_private_data_header(php_dom_private_data *private_data);
46 php_dom_libxml_ns_mapper *php_dom_ns_mapper_from_private(php_dom_private_data *private_data);
47 php_dom_private_data *php_dom_private_data_create(void);
48 void php_dom_private_data_destroy(php_dom_private_data *data);
49 void php_dom_add_templated_content(php_dom_private_data *private_data, const xmlNode *template_node, xmlNodePtr fragment);
50 xmlNodePtr php_dom_retrieve_templated_content(php_dom_private_data *private_data, const xmlNode *template_node);
51 xmlNodePtr php_dom_ensure_templated_content(php_dom_private_data *private_data, xmlNodePtr template_node);
52 void php_dom_remove_templated_content(php_dom_private_data *private_data, const xmlNode *template_node);
53 uint32_t php_dom_get_template_count(const php_dom_private_data *private_data);
54 void dom_add_element_ns_hook(php_dom_private_data *private_data, xmlNodePtr element);
55 
56 #endif
57