Add initial bits for Qt6 support
[carla.git] / source / modules / ysfx / sources / ysfx_parse.hpp
blobcfbae62ac9070d8b1d438187710547b462b1c5fe
1 // Copyright 2021 Jean Pierre Cimalando
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 // SPDX-License-Identifier: Apache-2.0
18 #pragma once
19 #include "ysfx.h"
20 #include "ysfx_reader.hpp"
21 #include "ysfx_utils.hpp"
22 #include <string>
23 #include <vector>
24 #include <cstdint>
26 struct ysfx_section_t;
27 struct ysfx_toplevel_t;
28 struct ysfx_slider_t;
29 struct ysfx_header_t;
30 using ysfx_section_u = std::unique_ptr<ysfx_section_t>;
31 using ysfx_toplevel_u = std::unique_ptr<ysfx_toplevel_t>;
32 using ysfx_slider_u = std::unique_ptr<ysfx_slider_t>;
33 using ysfx_header_u = std::unique_ptr<ysfx_header_t>;
35 struct ysfx_section_t {
36 uint32_t line_offset = 0;
37 std::string text;
40 struct ysfx_toplevel_t {
41 ysfx_section_u header;
42 ysfx_section_u init;
43 ysfx_section_u slider;
44 ysfx_section_u block;
45 ysfx_section_u sample;
46 ysfx_section_u serialize;
47 ysfx_section_u gfx;
48 uint32_t gfx_w = 0;
49 uint32_t gfx_h = 0;
52 struct ysfx_parse_error {
53 uint32_t line = 0;
54 std::string message;
55 explicit operator bool() { return !message.empty(); }
58 struct ysfx_slider_t {
59 uint32_t id = 0;
60 bool exists = false;
61 ysfx_real def = 0;
62 ysfx_real min = 0;
63 ysfx_real max = 0;
64 ysfx_real inc = 0;
65 std::string var;
66 std::string path;
67 bool is_enum = false;
68 ysfx::string_list enum_names;
69 std::string desc;
70 bool initially_visible = false;
73 struct ysfx_options_t {
74 std::string gmem;
75 uint32_t maxmem = 0;
76 bool want_all_kb = false;
77 bool no_meter = false;
80 struct ysfx_header_t {
81 std::string desc;
82 std::string author;
83 ysfx::string_list tags;
84 ysfx::string_list imports;
85 ysfx::string_list in_pins;
86 ysfx::string_list out_pins;
87 bool explicit_pins = false;
88 ysfx::string_list filenames;
89 ysfx_options_t options;
90 ysfx_slider_t sliders[ysfx_max_sliders];
93 struct ysfx_parsed_filename_t {
94 uint32_t index;
95 std::string filename;
98 bool ysfx_parse_toplevel(ysfx::text_reader &reader, ysfx_toplevel_t &toplevel, ysfx_parse_error *error);
99 bool ysfx_parse_slider(const char *line, ysfx_slider_t &slider);
100 bool ysfx_parse_filename(const char *line, ysfx_parsed_filename_t &filename);
101 void ysfx_parse_header(ysfx_section_t *section, ysfx_header_t &header);