summaryrefslogtreecommitdiff
path: root/tools/audio/xml.h
blob: dabfbcfefe10021972beebb6d1d425e2d82226a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * SPDX-FileCopyrightText: Copyright (C) 2024 ZeldaRET
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
#ifndef XML_H
#define XML_H

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>

#include <libxml/parser.h>

#define XMLSTR_TO_STR(s) ((const char *)(s))

typedef void (*xml_parser_func)(const char *, void *);

typedef struct {
    const char *name;
    bool optional;
    xml_parser_func parser_func;
    size_t offset;
} xml_attr_spec[];

void
xml_parse_int(const char *value, void *out);
void
xml_parse_uint(const char *value, void *out);
void
xml_parse_s16(const char *value, void *out);
void
xml_parse_u8(const char *value, void *out);
void
xml_parse_s8(const char *value, void *out);
void
xml_parse_note_number(const char *value, void *out);
void
xml_parse_string(const char *value, void *out);
void
xml_parse_c_identifier(const char *value, void *out);
void
xml_parse_bool(const char *value, void *out);
void
xml_parse_float(const char *value, void *out);
void
xml_parse_double(const char *value, void *out);

void
xml_get_single_property(void *out, const xmlNodePtr node, const char *name, xml_parser_func parser);

void
xml_parse_node_by_spec(void *out, const xmlNodePtr node, const xml_attr_spec spec, size_t spec_length);

void
xml_print_tree(xmlDocPtr document);

#endif