Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/i18n/JsonDictionary.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: 26 февр. 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_I18N_JSONDICTIONARY_H_
23 #define LSP_PLUG_IN_I18N_JSONDICTIONARY_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/fmt/json/Parser.h>
27 #include <lsp-plug.in/i18n/IDictionary.h>
28 #include <lsp-plug.in/lltl/parray.h>
29 #include <lsp-plug.in/io/IInSequence.h>
30 #include <lsp-plug.in/io/IInStream.h>
31
32 namespace lsp
33 {
34 namespace i18n
35 {
36 class JsonDictionary: public IDictionary
37 {
38 private:
39 JsonDictionary & operator = (const JsonDictionary &);
40
41 protected:
42 typedef struct node_t
43 {
44 LSPString sKey;
45 LSPString sValue;
46 JsonDictionary *pChild;
47 } node_t;
48
49 protected:
50 lltl::parray<node_t> vNodes;
51
52 protected:
53 status_t add_node(const node_t *node);
54 status_t parse_json(json::Parser *p);
55 node_t *find_node(const LSPString *key);
56
57 public:
58 explicit JsonDictionary();
59 virtual ~JsonDictionary();
60
61 public:
62 using IDictionary::init;
63 using IDictionary::get_value;
64 using IDictionary::get_child;
65 using IDictionary::lookup;
66
67 virtual status_t init(const char *path);
68
69 virtual status_t init(const LSPString *path);
70
71 virtual status_t init(io::IInSequence *is);
72
73 virtual status_t init(io::IInStream *is);
74
75 virtual status_t lookup(const LSPString *key, LSPString *value);
76
77 virtual status_t lookup(const LSPString *key, IDictionary **value);
78
79 virtual status_t get_value(size_t index, LSPString *key, LSPString *value);
80
81 virtual status_t get_child(size_t index, LSPString *key, IDictionary **dict);
82
83 virtual size_t size();
84 };
85 }
86
87 } /* namespace lsp */
88
89 #endif /* LSP_PLUG_IN_I18N_JSONDICTIONARY_H_ */