1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2018 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef SPVXML_HELPERS_H
18 #define SPVXML_HELPERS_H 1
22 #include <libxml/xmlreader.h>
23 #include "libpspp/compiler.h"
24 #include "libpspp/hmap.h"
36 #define SPVXML_CONTEXT_INIT(CONTEXT) \
37 { HMAP_INITIALIZER ((CONTEXT).id_map), NULL, false }
39 char *spvxml_context_finish (struct spvxml_context *, struct spvxml_node *root)
42 struct spvxml_node_context
44 struct spvxml_context *up;
45 const xmlNode *parent;
47 struct spvxml_attribute *attrs;
51 void spvxml_node_context_uninit (struct spvxml_node_context *);
53 struct spvxml_node_class
56 void (*spvxml_node_free) (struct spvxml_node *);
57 void (*spvxml_node_collect_ids) (struct spvxml_context *,
58 struct spvxml_node *);
59 void (*spvxml_node_resolve_refs) (struct spvxml_context *,
60 struct spvxml_node *);
65 struct hmap_node id_node;
68 const struct spvxml_node_class *class_;
72 void spvxml_node_collect_id (struct spvxml_context *, struct spvxml_node *);
73 struct spvxml_node *spvxml_node_resolve_ref (
74 struct spvxml_context *, const xmlNode *, const char *attr_name,
75 const struct spvxml_node_class *const *, size_t n);
77 /* Attribute parsing. */
78 struct spvxml_attribute
85 void spvxml_parse_attributes (struct spvxml_node_context *);
86 void spvxml_attr_error (struct spvxml_node_context *, const char *format, ...)
95 int spvxml_attr_parse_enum (struct spvxml_node_context *,
96 const struct spvxml_attribute *,
97 const struct spvxml_enum[]);
98 int spvxml_attr_parse_bool (struct spvxml_node_context *,
99 const struct spvxml_attribute *);
100 bool spvxml_attr_parse_fixed (struct spvxml_node_context *,
101 const struct spvxml_attribute *,
102 const char *attr_value);
103 int spvxml_attr_parse_int (struct spvxml_node_context *,
104 const struct spvxml_attribute *);
105 int spvxml_attr_parse_color (struct spvxml_node_context *,
106 const struct spvxml_attribute *);
107 double spvxml_attr_parse_real (struct spvxml_node_context *,
108 const struct spvxml_attribute *);
109 double spvxml_attr_parse_dimension (struct spvxml_node_context *,
110 const struct spvxml_attribute *);
111 struct spvxml_node *spvxml_attr_parse_ref (struct spvxml_node_context *,
112 const struct spvxml_attribute *);
114 /* Content parsing. */
116 void spvxml_content_error (struct spvxml_node_context *, const xmlNode *,
117 const char *format, ...)
118 PRINTF_FORMAT (3, 4);
119 bool spvxml_content_parse_element (struct spvxml_node_context *, xmlNode **,
120 const char *elem_name, xmlNode **);
121 bool spvxml_content_parse_text (struct spvxml_node_context *, xmlNode **,
123 void spvxml_content_parse_etc (xmlNode **);
124 bool spvxml_content_parse_end (struct spvxml_node_context *, xmlNode *);
126 #endif /* output/spv/spvxml-helpers.h */