]> icculus.org git repositories - mikachu/openbox.git/blob - obt/parse.h
add obt_parse_save_file() method to the obt parse library
[mikachu/openbox.git] / obt / parse.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/parse.h for the Openbox window manager
4    Copyright (c) 2003-2007   Dana Jansens
5
6    This program 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; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef __obt_parse_h
20 #define __obt_parse_h
21
22 #include <libxml/parser.h>
23 #include <glib.h>
24
25 G_BEGIN_DECLS
26
27 typedef struct _ObtParseInst ObtParseInst;
28
29 typedef void (*ObtParseCallback)(xmlNodePtr node, gpointer data);
30
31 ObtParseInst* obt_parse_instance_new(void);
32 void obt_parse_instance_ref(ObtParseInst *inst);
33 void obt_parse_instance_unref(ObtParseInst *inst);
34
35 gboolean obt_parse_load_file(ObtParseInst *inst,
36                              const gchar *path,
37                              const gchar *root_node);
38 gboolean obt_parse_load_config_file(ObtParseInst *inst,
39                                     const gchar *domain,
40                                     const gchar *filename,
41                                     const gchar *root_node);
42 gboolean obt_parse_load_data_file(ObtParseInst *inst,
43                                   const gchar *domain,
44                                   const gchar *filename,
45                                   const gchar *root_node);
46 gboolean obt_parse_load_theme_file(ObtParseInst *inst,
47                                    const gchar *theme,
48                                    const gchar *domain,
49                                    const gchar *filename,
50                                    const gchar *root_node);
51 gboolean obt_parse_load_mem(ObtParseInst *inst,
52                             gpointer data, guint len, const gchar *root_node);
53
54 gboolean obt_parse_save_file(ObtParseInst *inst,
55                              const gchar *path,
56                              gboolean pretty);
57
58 xmlDocPtr obt_parse_doc(ObtParseInst *inst);
59 xmlNodePtr obt_parse_root(ObtParseInst *inst);
60
61 void obt_parse_close(ObtParseInst *inst);
62
63 void obt_parse_register(ObtParseInst *inst, const gchar *tag,
64                         ObtParseCallback func, gpointer data);
65 void obt_parse_tree(ObtParseInst *i, xmlNodePtr node);
66 void obt_parse_tree_from_root(ObtParseInst *i);
67
68
69 /* helpers */
70
71 xmlNodePtr obt_parse_find_node(xmlNodePtr node, const gchar *name);
72
73 gboolean obt_parse_node_contains (xmlNodePtr node, const gchar *val);
74 gchar   *obt_parse_node_string   (xmlNodePtr node);
75 gint     obt_parse_node_int      (xmlNodePtr node);
76 gboolean obt_parse_node_bool     (xmlNodePtr node);
77
78 gboolean obt_parse_attr_contains (xmlNodePtr node, const gchar *name,
79                                   const gchar *val);
80 gboolean obt_parse_attr_string   (xmlNodePtr node, const gchar *name,
81                                   gchar **value);
82 gboolean obt_parse_attr_int      (xmlNodePtr node, const gchar *name,
83                                   gint *value);
84 gboolean obt_parse_attr_bool     (xmlNodePtr node, const gchar *name,
85                                   gboolean *value);
86
87 G_END_DECLS
88
89 #endif