Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/expr/Resolver.h

raw
1 /*
2 * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2024 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 16 сент. 2019 г.
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_EXPR_RESOLVER_H_
23 #define LSP_PLUG_IN_EXPR_RESOLVER_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/expr/types.h>
27 #include <lsp-plug.in/expr/functions.h>
28
29 namespace lsp
30 {
31 namespace expr
32 {
33 /**
34 * This is a class that resolves the actual value by the variable name.
35 * By default, it resolves all values as NULLs
36 *
37 */
38 class Resolver
39 {
40 public:
41 explicit Resolver();
42 Resolver(const Resolver &) = delete;
43 Resolver(Resolver &&) = delete;
44 virtual ~Resolver();
45
46 Resolver & operator = (const Resolver &) = delete;
47 Resolver & operator = (Resolver &&) = delete;
48
49 protected:
50 stdfunc_t find_std_func(const char *name);
51
52 public:
53 /**
54 * Resolve array variable by name and indexes
55 * @param value pointer to value to store the data
56 * @param name array variable name
57 * @param num_indexes number of indexes in array
58 * @param indexes pointer to array containing all index values
59 * @return status of operation
60 */
61 virtual status_t resolve(value_t *value, const char *name, size_t num_indexes = 0, const ssize_t *indexes = NULL);
62
63 /**
64 * Resolve array variable by name and indexes
65 * @param value pointer to value to store the data
66 * @param name array variable name
67 * @param num_indexes number of indexes in array
68 * @param indexes pointer to array containing all index values
69 * @return status of operation
70 */
71 virtual status_t resolve(value_t *value, const LSPString *name, size_t num_indexes = 0, const ssize_t *indexes = NULL);
72
73 /**
74 * Perform function call
75 * @param value destination pointer to store the value
76 * @param name name of the function
77 * @param num_args number of arguments
78 * @param args list of arguments (may be NULL)
79 * @return status of operation
80 */
81 virtual status_t call(value_t *value, const char *name, size_t num_args, const value_t *args = NULL);
82
83 /**
84 * Perform function call
85 * @param value destination pointer to store the value
86 * @param name name of the function
87 * @param num_args number of arguments
88 * @param args list of arguments (may be NULL)
89 * @return status of operation
90 */
91 virtual status_t call(value_t *value, const LSPString *name, size_t num_args, const value_t *args = NULL);
92 };
93
94 } /* namespace expr */
95 } /* namespace lsp */
96
97 #endif /* LSP_PLUG_IN_EXPR_RESOLVER_H_ */