Flecs v3.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
expr.h
Go to the documentation of this file.
1
31#ifdef FLECS_EXPR
32
33#ifndef FLECS_META
34#define FLECS_META
35#endif
36
37#ifndef FLECS_PARSER
38#define FLECS_PARSER
39#endif
40
41#ifndef FLECS_EXPR_H
42#define FLECS_EXPR_H
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
64FLECS_API
66 char *out,
67 char in,
68 char delimiter);
69
77const char* ecs_chrparse(
78 const char *in,
79 char *out);
80
93FLECS_API
94ecs_size_t ecs_stresc(
95 char *out,
96 ecs_size_t size,
97 char delimiter,
98 const char *in);
99
108FLECS_API
110 char delimiter,
111 const char *in);
112
115typedef struct ecs_expr_var_t {
116 char *name;
117 ecs_value_t value;
118 bool owned; /* Set to false if ecs_vars_t should not take ownership of var */
120
121typedef struct ecs_expr_var_scope_t {
122 ecs_hashmap_t var_index;
123 ecs_vec_t vars;
124 struct ecs_expr_var_scope_t *parent;
126
127typedef struct ecs_vars_t {
128 ecs_world_t *world;
131} ecs_vars_t;
132
134FLECS_API
136 ecs_world_t *world,
137 ecs_vars_t *vars);
138
140FLECS_API
142 ecs_vars_t *vars);
143
145FLECS_API
147 ecs_vars_t *vars);
148
150FLECS_API
152 ecs_vars_t *vars);
153
155FLECS_API
157 ecs_vars_t *vars,
158 const char *name,
159 ecs_entity_t type);
160
165FLECS_API
167 ecs_vars_t *vars,
168 const char *name,
169 ecs_value_t *value);
170
172FLECS_API
174 ecs_vars_t *vars,
175 const char *name);
176
178typedef struct ecs_parse_expr_desc_t {
179 const char *name;
180 const char *expr;
181 ecs_entity_t (*lookup_action)(
182 const ecs_world_t*,
183 const char *value,
184 void *ctx);
185 void *lookup_ctx;
186 ecs_vars_t *vars;
188
203FLECS_API
204const char* ecs_parse_expr(
205 ecs_world_t *world,
206 const char *ptr,
207 ecs_value_t *value,
208 const ecs_parse_expr_desc_t *desc);
209
219FLECS_API
221 const ecs_world_t *world,
222 ecs_entity_t type,
223 const void *data);
224
234FLECS_API
236 const ecs_world_t *world,
237 ecs_entity_t type,
238 const void *data,
239 ecs_strbuf_t *buf);
240
252FLECS_API
254 const ecs_world_t *world,
255 ecs_primitive_kind_t kind,
256 const void *data,
257 ecs_strbuf_t *buf);
258
269FLECS_API
271 const char *name,
272 const char *expr,
273 const char *ptr,
274 char *token);
275
278#ifdef __cplusplus
279}
280#endif
281
282#endif
283
284#endif
FLECS_API ecs_expr_var_t * ecs_vars_declare(ecs_vars_t *vars, const char *name, ecs_entity_t type)
Declare variable in current scope.
FLECS_API ecs_expr_var_t * ecs_vars_declare_w_value(ecs_vars_t *vars, const char *name, ecs_value_t *value)
Declare variable in current scope from value.
FLECS_API int ecs_ptr_to_expr_buf(const ecs_world_t *world, ecs_entity_t type, const void *data, ecs_strbuf_t *buf)
Serialize value into string buffer.
FLECS_API char * ecs_chresc(char *out, char in, char delimiter)
Write an escaped character.
FLECS_API int ecs_primitive_to_expr_buf(const ecs_world_t *world, ecs_primitive_kind_t kind, const void *data, ecs_strbuf_t *buf)
Serialize primitive value into string buffer.
FLECS_API char * ecs_ptr_to_expr(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into expression string.
FLECS_API void ecs_vars_fini(ecs_vars_t *vars)
Cleanup variable storage.
FLECS_API ecs_size_t ecs_stresc(char *out, ecs_size_t size, char delimiter, const char *in)
Write an escaped string.
FLECS_API void ecs_vars_push(ecs_vars_t *vars)
Push variable scope.
FLECS_API void ecs_vars_init(ecs_world_t *world, ecs_vars_t *vars)
Init variable storage.
FLECS_API const char * ecs_parse_expr(ecs_world_t *world, const char *ptr, ecs_value_t *value, const ecs_parse_expr_desc_t *desc)
Parse expression into value.
FLECS_API int ecs_vars_pop(ecs_vars_t *vars)
Pop variable scope.
FLECS_API char * ecs_astresc(char delimiter, const char *in)
Return escaped string.
const char * ecs_chrparse(const char *in, char *out)
Parse an escaped character.
FLECS_API ecs_expr_var_t * ecs_vars_lookup(ecs_vars_t *vars, const char *name)
Lookup variable in scope and parent scopes.
FLECS_API const char * ecs_parse_expr_token(const char *name, const char *expr, const char *ptr, char *token)
Parse expression token.
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:219
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:228
Storage for parser variables.
Definition: expr.h:115
Used with ecs_parse_expr.
Definition: expr.h:178