Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/sfz/IDocumentHandler.h

raw
1 /*
2 * Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2023 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 23 февр. 2023 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_FMT_SFZ_IDOCUMENTHANDLER_H_
23 #define LSP_PLUG_IN_FMT_SFZ_IDOCUMENTHANDLER_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26
27 #include <lsp-plug.in/common/status.h>
28 #include <lsp-plug.in/fmt/sfz/PullParser.h>
29 #include <lsp-plug.in/io/IInStream.h>
30
31 namespace lsp
32 {
33 namespace sfz
34 {
35 /**
36 * SFZ document handler interface.
37 * It allows to handle and process SFZ data in a simple way.
38 */
39 class LSP_RUNTIME_LIB_PUBLIC IDocumentHandler
40 {
41 public:
42 IDocumentHandler();
43 virtual ~IDocumentHandler();
44
45 public:
46 /**
47 * Notify the handler about start of the document processing
48 * @return status of operation
49 */
50 virtual status_t begin();
51
52 /**
53 * Handle the control header content
54 * @param opcodes NULL-terminated list of all opcodes including the opcodes from parent headers
55 * @param values NULL-terminated list of all opcode values that match the opcodes
56 * @return status of operation
57 */
58 virtual status_t control(const char **opcodes, const char **values);
59
60 /**
61 * Handle the region header content. The merged values from <global>, <master>, <group> and <region>
62 * are passed to the method.
63 * @param opcodes NULL-terminated list of all opcodes including the opcodes from parent headers
64 * @param values NULL-terminated list of all opcode values that match the opcodes
65 * @return status of operation
66 */
67 virtual status_t region(const char **opcodes, const char **values);
68
69 /**
70 * Handle the sample data embedded into the SFZ file
71 * @param name name of the file
72 * @param data the stream that represents the contents of the file
73 * @param opcodes NULL-terminated list of all opcodes specific for this header only
74 * @param values NULL-terminated list of all opcode specific for this header only
75 * @return status of operation
76 */
77 virtual status_t sample(
78 const char *name, io::IInStream *data,
79 const char **opcodes, const char **values);
80
81 /**
82 * Handle the effect header content
83 * @param opcodes NULL-terminated list of all opcodes specific for this header only
84 * @param values NULL-terminated list of all opcode specific for this header only
85 * @return status of operation
86 */
87 virtual status_t effect(const char **opcodes, const char **values);
88
89 /**
90 * Handle the midi header content
91 * @param opcodes NULL-terminated list of all opcodes specific for this header only
92 * @param values NULL-terminated list of all opcode specific for this header only
93 * @return status of operation
94 */
95 virtual status_t midi(const char **opcodes, const char **values);
96
97 /**
98 * Handle the curve header content
99 * @param opcodes NULL-terminated list of all opcodes specific for this header only
100 * @param values NULL-terminated list of all opcode specific for this header only
101 * @return status of operation
102 */
103 virtual status_t curve(const char **opcodes, const char **values);
104
105 /**
106 * Handle another non-standard specific header content
107 * @param opcodes NULL-terminated list of all opcodes specific for this header only
108 * @param values NULL-terminated list of all opcode specific for this header only
109 * @return status of operation
110 */
111 virtual status_t custom_header(const char *name, const char **opcodes, const char **values);
112
113 /**
114 * Handle the include directive
115 * @param parser the parser that should be used to open or wrap file contents
116 * @param name the name of the file to include
117 * @return status of operation
118 */
119 virtual status_t include(PullParser *parser, const char *name);
120
121 /**
122 * Return the name of the root file (optional). Can be called when the document
123 * processor wraps the stream/memory chunk or SFZ file parser
124 * @return name of the root file associated with the handler or NULL
125 */
126 virtual const char *root_file_name();
127
128 /**
129 * Notify the handler about end of the document processing
130 * This callback is only called if no one error occurred during the processing
131 * @param result the oveall status of processing
132 * @return status of operation
133 */
134 virtual status_t end(status_t result);
135 };
136
137 } /* namespace sfz */
138 } /* namespace lsp */
139
140 #endif /* LSP_PLUG_IN_FMT_SFZ_IDOCUMENTHANDLER_H_ */