Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
expr.h
Go to the documentation of this file.
1
37#ifdef FLECS_EXPR
38
39#ifndef FLECS_META
40#define FLECS_META
41#endif
42
43#ifndef FLECS_PARSER
44#define FLECS_PARSER
45#endif
46
47#ifndef FLECS_EXPR_H
48#define FLECS_EXPR_H
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
70FLECS_API
72 char *out,
73 char in,
74 char delimiter);
75
83const char* ecs_chrparse(
84 const char *in,
85 char *out);
86
99FLECS_API
100ecs_size_t ecs_stresc(
101 char *out,
102 ecs_size_t size,
103 char delimiter,
104 const char *in);
105
114FLECS_API
116 char delimiter,
117 const char *in);
118
121typedef struct ecs_expr_var_t {
122 char *name;
123 ecs_value_t value;
124 bool owned; /* Set to false if ecs_vars_t should not take ownership of var */
126
127typedef struct ecs_expr_var_scope_t {
128 ecs_hashmap_t var_index;
129 ecs_vec_t vars;
130 struct ecs_expr_var_scope_t *parent;
132
133typedef struct ecs_vars_t {
134 ecs_world_t *world;
137} ecs_vars_t;
138
140FLECS_API
142 ecs_world_t *world,
143 ecs_vars_t *vars);
144
146FLECS_API
148 ecs_vars_t *vars);
149
151FLECS_API
153 ecs_vars_t *vars);
154
156FLECS_API
158 ecs_vars_t *vars);
159
161FLECS_API
163 ecs_vars_t *vars,
164 const char *name,
165 ecs_entity_t type);
166
171FLECS_API
173 ecs_vars_t *vars,
174 const char *name,
175 ecs_value_t *value);
176
178FLECS_API
180 const ecs_vars_t *vars,
181 const char *name);
182
184typedef struct ecs_parse_expr_desc_t {
185 const char *name;
186 const char *expr;
187 ecs_entity_t (*lookup_action)(
188 const ecs_world_t*,
189 const char *value,
190 void *ctx);
191 void *lookup_ctx;
192 ecs_vars_t *vars;
194
209FLECS_API
210const char* ecs_parse_expr(
211 ecs_world_t *world,
212 const char *ptr,
213 ecs_value_t *value,
214 const ecs_parse_expr_desc_t *desc);
215
225FLECS_API
227 const ecs_world_t *world,
228 ecs_entity_t type,
229 const void *data);
230
240FLECS_API
242 const ecs_world_t *world,
243 ecs_entity_t type,
244 const void *data,
245 ecs_strbuf_t *buf);
246
258FLECS_API
260 const ecs_world_t *world,
261 ecs_entity_t type,
262 const void *data);
263
273FLECS_API
275 const ecs_world_t *world,
276 ecs_entity_t type,
277 const void *data,
278 ecs_strbuf_t *buf);
279
291FLECS_API
293 const ecs_world_t *world,
295 const void *data,
296 ecs_strbuf_t *buf);
297
308FLECS_API
310 const char *name,
311 const char *expr,
312 const char *ptr,
313 char *token);
314
327FLECS_API
329 ecs_world_t *world,
330 const char *str,
331 const ecs_vars_t *vars);
332
365FLECS_API
367 const ecs_iter_t *it,
368 ecs_vars_t *vars,
369 int offset);
370
373#ifdef __cplusplus
374}
375#endif
376
377#endif
378
379#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 ecs_expr_var_t * ecs_vars_lookup(const ecs_vars_t *vars, const char *name)
Lookup variable in scope and parent scopes.
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 expression 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 char * ecs_ptr_to_str(const ecs_world_t *world, ecs_entity_t type, const void *data)
Similar as ecs_ptr_to_expr(), but serializes values to string.
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.
struct ecs_expr_var_t ecs_expr_var_t
Storage for parser variables.
FLECS_API void ecs_iter_to_vars(const ecs_iter_t *it, ecs_vars_t *vars, int offset)
Convert iterator to vars This operation converts an iterator to a variable array.
FLECS_API int ecs_ptr_to_str_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_astresc(char delimiter, const char *in)
Return escaped string.
struct ecs_parse_expr_desc_t ecs_parse_expr_desc_t
Used with ecs_parse_expr().
FLECS_API char * ecs_interpolate_string(ecs_world_t *world, const char *str, const ecs_vars_t *vars)
Evaluate interpolated expressions in string.
const char * ecs_chrparse(const char *in, char *out)
Parse an escaped character.
FLECS_API const char * ecs_parse_expr_token(const char *name, const char *expr, const char *ptr, char *token)
Parse expression token.
ecs_primitive_kind_t
Primitive type kinds supported by meta addon.
Definition meta.h:169
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:305
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:349
Storage for parser variables.
Definition expr.h:121
Used with ecs_parse_expr().
Definition expr.h:184