libt3config
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
expression.h
1 /* Copyright (C) 2011 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_CONFIG_EXPRESSION_H
15 #define T3_CONFIG_EXPRESSION_H
16 
17 typedef struct expr_node_t expr_node_t;
18 
19 #include "config_api.h"
20 #include "config_internal.h"
21 
22 typedef enum {
23  EXPR_TOP,
24  EXPR_AND,
25  EXPR_OR,
26  EXPR_XOR,
27  EXPR_NOT,
28 
29  EXPR_IDENT,
30 
31  EXPR_EQ,
32  EXPR_NE,
33 
34  EXPR_LT,
35  EXPR_LE,
36  EXPR_GT,
37  EXPR_GE,
38 
39  EXPR_STRING_CONST,
40  EXPR_INT_CONST,
41  EXPR_NUMBER_CONST,
42  EXPR_BOOL_CONST,
43 
44  EXPR_PATH,
45  EXPR_PATH_ROOT,
46  EXPR_DEREF,
47  EXPR_THIS,
48 
49  EXPR_LENGTH,
50  EXPR_LIST,
51  /* Used only to store the result of resolve, such that each lookup_node
52  only has to be called onde. */
53  EXPR_CONFIG
54 } expr_type_t;
55 
56 
57 struct expr_node_t {
58  expr_type_t type;
59  union {
60  struct expr_node_t *operand[2];
61  char *string;
62  t3_config_int_t integer;
63  double number;
64  t3_bool boolean;
65  const t3_config_t *config;
66  } value;
67 };
68 
69 
70 T3_CONFIG_LOCAL t3_bool _t3_config_evaluate_expr(const expr_node_t *expression, const t3_config_t *config, const t3_config_t *root);
71 T3_CONFIG_LOCAL t3_bool _t3_config_validate_expr(const expr_node_t *expression, const t3_config_t *config, const t3_config_t *root);
72 T3_CONFIG_LOCAL void _t3_config_delete_expr(expr_node_t *expr);
73 #endif