NetSurf
libdom.h
Go to the documentation of this file.
1/*
2 * Copyright 2011 John-Mark Bell <jmb@netsurf-browser.org>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20/** \file
21 * libdom utilities (implementation).
22 */
23
24#ifndef NETSURF_UTILS_LIBDOM_H_
25#define NETSURF_UTILS_LIBDOM_H_
26
27#include <stdbool.h>
28#include <stdio.h>
29
30#include <dom/dom.h>
31
32#include <dom/bindings/hubbub/parser.h>
33#include <dom/bindings/hubbub/errors.h>
34
35/**
36 * Search children of a node for first named element
37 * \param parent dom_node to search children of, or NULL
38 * \param element_name name of element to find
39 * \return first child of node which is an element and matches name, or
40 * NULL if not found or parameter node is NULL
41 */
42dom_node *libdom_find_first_element(dom_node *parent, lwc_string *element_name);
43
44typedef nserror (*libdom_iterate_cb)(dom_node *node, void *ctx);
45
47 libdom_iterate_cb cb, void *ctx);
48
49nserror libdom_parse_file(const char *filename, const char *encoding,
50 dom_document **doc);
51
52/**
53 * Convert libdom hubbub binding errors to nserrors.
54 *
55 * \param error The hubbub binding error to convert
56 * \return The appropriate nserror
57 */
58nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error);
59
60/**
61 * Walk though a DOM (sub)tree, in depth first order, printing DOM structure.
62 *
63 * \param node The root node to start from.
64 * \param f The file to write output into.
65 * \param depth The depth of 'node' in the (sub)tree.
66 */
67nserror libdom_dump_structure(dom_node *node, FILE *f, int depth);
68
69#endif
wimp_w parent
Definition: dialog.c:88
nserror
Enumeration of error codes.
Definition: errors.h:29
nserror libdom_iterate_child_elements(dom_node *parent, libdom_iterate_cb cb, void *ctx)
Definition: libdom.c:76
dom_node * libdom_find_first_element(dom_node *parent, lwc_string *element_name)
Search children of a node for first named element.
Definition: libdom.c:33
nserror libdom_parse_file(const char *filename, const char *encoding, dom_document **doc)
Definition: libdom.c:381
nserror libdom_hubbub_error_to_nserror(dom_hubbub_error error)
Convert libdom hubbub binding errors to nserrors.
Definition: libdom.c:122
nserror libdom_dump_structure(dom_node *node, FILE *f, int depth)
Walk though a DOM (sub)tree, in depth first order, printing DOM structure.
Definition: libdom.c:331
nserror(* libdom_iterate_cb)(dom_node *node, void *ctx)
Definition: libdom.h:44