1/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2/* vim:set et sts=4: */
3/* bus - The Input Bus
4 * Copyright (C) 2008-2015 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2015 Red Hat, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 */
22
23#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24#error "Only <ibus.h> can be included directly"
25#endif
26
27#ifndef __IBUS_XML_H__
28#define __IBUS_XML_H__
29
30/**
31 * SECTION: ibusxml
32 * @short_description: XML handling functions for IBus.
33 * @stability: Stable
34 *
35 * IBusXML lists data structure and handling function for XML in IBus.
36 */
37
38#include <glib.h>
39#include <glib-object.h>
40
41#define IBUS_TYPE_XML (ibus_xml_get_type ())
42
43G_BEGIN_DECLS
44
45/**
46 * IBusXML:
47 * @name: Name of XML tag.
48 * @text: Text enclosed by XML start tag and end tag. i.e. <tag>text</tag>.
49 * @attributes: Attributes of the XML node.
50 * @sub_nodes: Children node of this XML node.
51 *
52 * A data type representing an XML node.
53 */
54typedef struct {
55 gchar *name;
56 gchar *text;
57 gchar **attributes;
58 GList *sub_nodes;
59} IBusXML;
60
61#define XMLNode IBusXML
62
63GType ibus_xml_get_type (void) G_GNUC_CONST;
64
65/**
66 * ibus_xml_copy:
67 * @node: Root node of an XML tree.
68 *
69 * Creates a copy of @node, which should be freed with
70 * ibus_xml_free(). Primarily used by language bindings,
71 * not that useful otherwise (since @node can just be copied
72 * by assignment in C).
73 *
74 * Returns: the newly allocated #IBusXML, which should
75 * be freed with ibus_xml_free(), or %NULL
76 * if @node was %NULL.
77 **/
78XMLNode *ibus_xml_copy (const XMLNode *node);
79
80/**
81 * ibus_xml_parse_file:
82 * @name: File name to be parsed.
83 *
84 * Parse an XML file and return a corresponding XML tree.
85 *
86 * Returns: Root node of parsed XML tree.
87 */
88XMLNode *ibus_xml_parse_file (const gchar *name);
89
90/**
91 * ibus_xml_parse_buffer:
92 * @buffer: Buffer to be parsed.
93 *
94 * Parse a string buffer which contains an XML-formatted string,
95 * and return a corresponding XML tree.
96 *
97 * Returns: Root node of parsed XML tree.
98 */
99XMLNode *ibus_xml_parse_buffer (const gchar *buffer);
100
101/**
102 * ibus_xml_free:
103 * @node: Root node of an XML tree.
104 *
105 * Free an XML tree.
106 */
107void ibus_xml_free (XMLNode *node);
108
109/**
110 * ibus_xml_output:
111 * @node: Root node of an XML tree.
112 * @output: GString which stores the output.
113 *
114 * Output an XML tree to a GString.
115 */
116void ibus_xml_output (const XMLNode *node,
117 GString *output);
118G_END_DECLS
119#endif
120