Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/fmt/lspc/util/config.h

raw
1 /*
2 * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2025 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 24 окт. 2022 г.
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_LSPC_UTIL_CONFIG_H_
23 #define LSP_PLUG_IN_FMT_LSPC_UTIL_CONFIG_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/lspc/File.h>
29 #include <lsp-plug.in/mm/types.h>
30 #include <lsp-plug.in/io/IInStream.h>
31 #include <lsp-plug.in/io/Path.h>
32 #include <lsp-plug.in/runtime/LSPString.h>
33
34 namespace lsp
35 {
36 namespace lspc
37 {
38 /**
39 * Write configuration entry to the LSPC file
40 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
41 * @param file the LSPC file to write the chunk
42 * @param path the location of configuration file to write
43 * @param buf_size size of buffer for I/O operations
44 * @return status of operation
45 */
46 LSP_RUNTIME_LIB_PUBLIC
47 status_t write_config(chunk_id_t *chunk_id, File *file, const char *path, size_t buf_size = 0x1000);
48
49 LSP_RUNTIME_LIB_PUBLIC
50 status_t write_config(chunk_id_t *chunk_id, File *file, const io::Path *path, size_t buf_size = 0x1000);
51
52 LSP_RUNTIME_LIB_PUBLIC
53 status_t write_config(chunk_id_t *chunk_id, File *file, const LSPString *path, size_t buf_size = 0x1000);
54
55 /**
56 * Write the contents of the passed stream to the LSPC file as a configuration chunk
57 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
58 * @param file the LSPC file to write the chunk
59 * @param is input stream that provides data to write
60 * @param buf_size size of buffer for I/O operations
61 * @return status of operation
62 */
63 LSP_RUNTIME_LIB_PUBLIC
64 status_t write_config(chunk_id_t *chunk_id, File *file, io::IInStream *is, size_t buf_size = 0x1000);
65
66 /**
67 * Create configuration entry in the LSPC file and return chunk writer that will allow to write to the entry
68 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
69 * @param file the LSPC file to write the chunk
70 * @param writer pointer to store the created chunk writer that should be deleted after use
71 * @return status of operation
72 */
73 LSP_RUNTIME_LIB_PUBLIC
74 status_t write_config(chunk_id_t *chunk_id, File *file, lspc::ChunkWriter **writer);
75
76 /**
77 * Create configuration entry in the LSPC file and return chunk writer that will allow to write to the entry
78 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
79 * @param file the LSPC file to write the chunk
80 * @param os pointer to store the created output stream that should be deleted after use
81 * @return status of operation
82 */
83 LSP_RUNTIME_LIB_PUBLIC
84 status_t write_config(chunk_id_t *chunk_id, File *file, io::IOutStream **os);
85
86 /**
87 * Write configuration entry data to the LSPC file
88 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
89 * @param file the LSPC file to write the chunk
90 * @param data the text configuration data to write to the file
91 * @param buf_size size of buffer for I/O operations
92 * @return status of operation
93 */
94 LSP_RUNTIME_LIB_PUBLIC
95 status_t write_config_data(chunk_id_t *chunk_id, File *file, const char *data, size_t buf_size = 0x1000);
96
97 LSP_RUNTIME_LIB_PUBLIC
98 status_t write_config_data(chunk_id_t *chunk_id, File *file, const LSPString *data, size_t buf_size = 0x1000);
99
100 /**
101 * Write configuration entry data to the LSPC file
102 * @param chunk_id pointer to store allocated chunk identifier, can be NULL
103 * @param file the LSPC file to write the chunk
104 * @param data the binary data to write to the file
105 * @param bytes the size of data in bytes
106 * @param buf_size size of buffer for I/O operations
107 * @return status of operation
108 */
109 LSP_RUNTIME_LIB_PUBLIC
110 status_t write_config_data(chunk_id_t *chunk_id, File *file, const void *data, size_t bytes, size_t buf_size = 0x1000);
111
112 /**
113 * Read configuration chunk to the file
114 * @param chunk_id chunk identifier
115 * @param file the LSPC file to read the chunk
116 * @param path target file name
117 * @param buf_size size of buffer for I/O operations
118 * @return status of operation
119 */
120 LSP_RUNTIME_LIB_PUBLIC
121 status_t read_config(chunk_id_t chunk_id, File *file, const char *path, size_t buf_size = 0x1000);
122
123 LSP_RUNTIME_LIB_PUBLIC
124 status_t read_config(chunk_id_t chunk_id, File *file, const io::Path *path, size_t buf_size = 0x1000);
125
126 LSP_RUNTIME_LIB_PUBLIC
127 status_t read_config(chunk_id_t chunk_id, File *file, const LSPString *path, size_t buf_size = 0x1000);
128
129 /**
130 * Read configuration chunk to the output stream
131 * @param chunk_id chunk identifier
132 * @param file the LSPC file to read the chunk
133 * @param os target output stream to read data
134 * @param buf_size size of buffer for I/O operations
135 * @return status of operation
136 */
137 LSP_RUNTIME_LIB_PUBLIC
138 status_t read_config(chunk_id_t chunk_id, File *file, io::IOutStream *os, size_t buf_size = 0x1000);
139
140 /**
141 * Read configuration chunk and return pointer to the input stream
142 * @param chunk_id chunk identifier
143 * @param file the LSPC file to read the chunk
144 * @param is pointer to store the resulting stream, should be deleted after use
145 * @return status of operation
146 */
147 LSP_RUNTIME_LIB_PUBLIC
148 status_t read_config(chunk_id_t chunk_id, File *file, io::IInStream **is);
149
150 /**
151 * Read configuration chunk into the memory and return pointer to the allocated string
152 * @param chunk_id chunk identifier
153 * @param file the LSPC file to read the chunk
154 * @param data pointer to store the resulting string, should be free()'d by the caller after use
155 * @param buf_size size of buffer for I/O operations
156 * @return status of operation
157 */
158 LSP_RUNTIME_LIB_PUBLIC
159 status_t read_config_data(chunk_id_t chunk_id, File *file, char **data, size_t buf_size = 0x1000);
160
161 /**
162 * Read configuration chunk into the string
163 * @param chunk_id chunk identifier
164 * @param file the LSPC file to read the chunk
165 * @param data string to store the result
166 * @param buf_size size of buffer for I/O operations
167 * @return status of operation
168 */
169 LSP_RUNTIME_LIB_PUBLIC
170 status_t read_config_data(chunk_id_t chunk_id, File *file, LSPString *data, size_t buf_size = 0x1000);
171
172 /**
173 * Read configuration chunk into the memory and return it's size
174 * @param chunk_id chunk identifier
175 * @param file the LSPC file to read the chunk
176 * @param data pointer to store the address of the buffer, should be free()'d by the caller after use
177 * @param size pointer to return the size of read data
178 * @param buf_size size of buffer for I/O operations
179 * @return status of operation
180 */
181 LSP_RUNTIME_LIB_PUBLIC
182 status_t read_config_data(chunk_id_t chunk_id, File *file, void **data, size_t *size, size_t buf_size = 0x1000);
183
184 } /* namespace lspc */
185 } /* namespace lsp */
186
187
188 #endif /* LSP_PLUG_IN_FMT_LSPC_UTIL_CONFIG_H_ */