Parent Directory | Revision Log
Quick'n dirty XML parser
1 | harbaum | 39 | /* |
2 | * Copyright (C) 2008 Till Harbaum <till@harbaum.org>. | ||
3 | * | ||
4 | * This file is part of OSM2Go. | ||
5 | * | ||
6 | * OSM2Go 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 3 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * OSM2Go 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 | * You should have received a copy of the GNU General Public License | ||
17 | * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #ifndef QND_XML_H | ||
21 | #define QND_XML_H | ||
22 | |||
23 | typedef struct qnd_xml_attribute_s { | ||
24 | char *name, *value; | ||
25 | struct qnd_xml_attribute_s *next; | ||
26 | } qnd_xml_attribute_t; | ||
27 | |||
28 | typedef struct qnd_xml_stack_s { | ||
29 | struct qnd_xml_entry_s *entry; | ||
30 | gpointer userdata[4]; | ||
31 | |||
32 | struct qnd_xml_stack_s *prev; | ||
33 | struct qnd_xml_stack_s *next; | ||
34 | } qnd_xml_stack_t; | ||
35 | |||
36 | typedef gboolean(*qnd_xml_callback_t)(qnd_xml_stack_t *, | ||
37 | qnd_xml_attribute_t *, gpointer); | ||
38 | |||
39 | typedef struct qnd_xml_entry_s { | ||
40 | char *name; | ||
41 | |||
42 | qnd_xml_callback_t cb; | ||
43 | |||
44 | int num_children; | ||
45 | struct qnd_xml_entry_s **children; | ||
46 | } qnd_xml_entry_t; | ||
47 | |||
48 | #define QND_XML_CHILDREN(a) (sizeof(a)/sizeof(qnd_xml_entry_t *)), a | ||
49 | #define QND_XML_LEAF 0, NULL | ||
50 | |||
51 | gpointer qnd_xml_parse(char *name, qnd_xml_entry_t *root, gpointer userdata); | ||
52 | char *qnd_xml_get_prop(qnd_xml_attribute_t *attr, char *name); | ||
53 | gboolean qnd_xml_get_prop_double(qnd_xml_attribute_t *, char *, double *); | ||
54 | gboolean qnd_xml_get_prop_gulong(qnd_xml_attribute_t *, char *, gulong *); | ||
55 | gboolean qnd_xml_get_prop_is(qnd_xml_attribute_t *, char *, char *); | ||
56 | char *qnd_xml_get_prop_str(qnd_xml_attribute_t *attr, char *name); | ||
57 | |||
58 | #endif // QND_XML_H |