1 // Copyright 2021 Jean Pierre Cimalando
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
20 #include "ysfx_reader.hpp"
21 #include "ysfx_utils.hpp"
26 struct ysfx_section_t
;
27 struct ysfx_toplevel_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;
40 struct ysfx_toplevel_t
{
41 ysfx_section_u header
;
43 ysfx_section_u slider
;
45 ysfx_section_u sample
;
46 ysfx_section_u serialize
;
52 struct ysfx_parse_error
{
55 explicit operator bool() { return !message
.empty(); }
58 struct ysfx_slider_t
{
68 ysfx::string_list enum_names
;
70 bool initially_visible
= false;
73 struct ysfx_options_t
{
76 bool want_all_kb
= false;
77 bool no_meter
= false;
80 struct ysfx_header_t
{
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
{
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
);