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;
119
120typedef struct ecs_expr_var_scope_t {
121 ecs_hashmap_t var_index;
122 ecs_vec_t vars;
123 struct ecs_expr_var_scope_t *parent;
125
126typedef struct ecs_vars_t {
127 ecs_world_t *world;
130} ecs_vars_t;
131
133FLECS_API
135 ecs_world_t *world,
136 ecs_vars_t *vars);
137
139FLECS_API
141 ecs_vars_t *vars);
142
144FLECS_API
146 ecs_vars_t *vars);
147
149FLECS_API
151 ecs_vars_t *vars);
152
154FLECS_API
156 ecs_vars_t *vars,
157 const char *name,
158 ecs_entity_t type);
159
164FLECS_API
166 ecs_vars_t *vars,
167 const char *name,
168 ecs_value_t *value);
169
171FLECS_API
173 ecs_vars_t *vars,
174 const char *name);
175
177typedef struct ecs_parse_expr_desc_t {
178 const char *name;
179 const char *expr;
180 ecs_entity_t (*lookup_action)(
181 const ecs_world_t*,
182 const char *value,
183 void *ctx);
184 void *lookup_ctx;
185 ecs_vars_t *vars;
187
202FLECS_API
203const char* ecs_parse_expr(
204 ecs_world_t *world,
205 const char *ptr,
206 ecs_value_t *value,
207 const ecs_parse_expr_desc_t *desc);
208
218FLECS_API
220 const ecs_world_t *world,
221 ecs_entity_t type,
222 const void *data);
223
233FLECS_API
235 const ecs_world_t *world,
236 ecs_entity_t type,
237 const void *data,
238 ecs_strbuf_t *buf);
239
251FLECS_API
253 const ecs_world_t *world,
254 ecs_primitive_kind_t kind,
255 const void *data,
256 ecs_strbuf_t *buf);
257
268FLECS_API
270 const char *name,
271 const char *expr,
272 const char *ptr,
273 char *token);
274
277#ifdef __cplusplus
278}
279#endif
280
281#endif
282
283#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:220
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:229
Storage for parser variables.
Definition: expr.h:115
Used with ecs_parse_expr.
Definition: expr.h:177