Debian Codegraph @

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

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 30 апр. 2020 г.
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_CONFIG_PUSHPARSER_H_
23 #define LSP_PLUG_IN_FMT_CONFIG_PUSHPARSER_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/fmt/config/PullParser.h>
27 #include <lsp-plug.in/fmt/config/IConfigHandler.h>
28
29 namespace lsp
30 {
31 namespace config
32 {
33 /**
34 * Push parser for configuration, works as an adapter around PullParser
35 */
36 class PushParser
37 {
38 protected:
39 PullParser sParser;
40
41 protected:
42 status_t parse_document(IConfigHandler *handler);
43
44 public:
45 explicit PushParser();
46 PushParser(const PushParser &) = delete;
47 PushParser(PushParser &&) = delete;
48 virtual ~PushParser();
49
50 PushParser & operator = (const PushParser &) = delete;
51 PushParser & operator = (PushParser &&) = delete;
52
53 public:
54 /**
55 * Parse file
56 * @param handler configuration file handler
57 * @param path UTF-8 path to the file
58 * @param charset character set encoding of the file
59 * @return status of operation
60 */
61 status_t parse_file(IConfigHandler *handler, const char *path, const char *charset = NULL);
62
63 /**
64 * Parse file
65 * @param handler configuration file handler
66 * @param path path to the file
67 * @param charset character set encoding of the file
68 * @return status of operation
69 */
70 status_t parse_file(IConfigHandler *handler, const LSPString *path, const char *charset = NULL);
71
72 /**
73 * Parse file
74 * @param handler configuration file handler
75 * @param path path to the file
76 * @param charset character set encoding of the file
77 * @return status of operation
78 */
79 status_t parse_file(IConfigHandler *handler, const io::Path *path, const char *charset = NULL);
80
81 /**
82 * Parse data from input stream
83 * @param handler configuration file handler
84 * @param is input stream
85 * @param flags wrap flags
86 * @param charset character set
87 * @return status of operation
88 */
89 status_t parse_data(IConfigHandler *handler, io::IInStream *is, size_t flags = WRAP_NONE, const char *charset = NULL);
90
91 /**
92 * Parse data from native encoded string
93 * @param handler configuration file handler
94 * @param str data input
95 * @param charset character set
96 * @return status of operation
97 */
98 status_t parse_data(IConfigHandler *handler, const char *str, const char *charset = NULL);
99
100 /**
101 * Parse data from text string
102 * @param handler configuration file handler
103 * @param str data input
104 * @return status of operation
105 */
106 status_t parse_data(IConfigHandler *handler, const LSPString *str);
107
108 /**
109 * Parse data from character sequence
110 * @param handler configuration file handler
111 * @param seq input sequence
112 * @param flags wrap flags
113 * @return status of operation
114 */
115 status_t parse_data(IConfigHandler *handler, io::IInSequence *seq, size_t flags = WRAP_NONE);
116 };
117
118 } /* namespace config */
119 } /* namespace lsp */
120
121 #endif /* LSP_PLUG_IN_FMT_CONFIG_PUSHPARSER_H_ */