libtreestore

view src/xmltree.h @ 0:740fec9866b1

treestore initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 11 Apr 2014 08:56:46 +0300
parents
children
line source
1 #ifndef COMMON_XMLTREE_H_
2 #define COMMON_XMLTREE_H_
4 #include <stdio.h>
6 enum {
7 ATYPE_STR,
8 ATYPE_INT,
9 ATYPE_FLT,
10 ATYPE_VEC
11 };
13 struct xml_attr {
14 char *name;
15 char *str;
17 int type;
18 int ival;
19 float fval;
20 float vval[4];
22 struct xml_attr *next;
23 };
25 struct xml_node {
26 char *name;
27 char *cdata;
28 struct xml_attr *attr; /* attribute list */
30 int chld_count;
32 struct xml_node *up; /* parent pointer */
33 struct xml_node *chld, *chld_tail; /* children list */
34 struct xml_node *next; /* next sibling */
35 };
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 struct xml_attr *xml_create_attr(const char *name, const char *val);
42 void xml_free_attr(struct xml_attr *attr);
43 void xml_free_attr_list(struct xml_attr *alist);
45 struct xml_attr *xml_get_attr(struct xml_node *node, const char *attr_name);
47 struct xml_node *xml_create_tree(void);
48 void xml_free_tree(struct xml_node *x);
50 struct xml_node *xml_read_tree(const char *fname);
51 struct xml_node *xml_read_tree_file(FILE *fp);
53 int xml_write_tree(struct xml_node *x, const char *fname);
54 int xml_write_tree_file(struct xml_node *x, FILE *fp);
56 void xml_add_child(struct xml_node *x, struct xml_node *chld);
57 void xml_remove_subtree(struct xml_node *sub);
59 #ifdef __cplusplus
60 }
61 #endif
63 #endif /* COMMON_XMLTREE_H_ */