Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1
11#ifdef FLECS_JSON
12
13#ifndef FLECS_EXPR
14#define FLECS_EXPR
15#endif
16
17#ifndef FLECS_JSON_H
18#define FLECS_JSON_H
19
28#ifdef __cplusplus
29extern "C" {
30#endif
31
33typedef struct ecs_from_json_desc_t {
34 const char *name;
35 const char *expr;
40 const ecs_world_t*,
41 const char *value,
42 void *ctx);
43 void *lookup_ctx;
45
57FLECS_API
59 const ecs_world_t *world,
60 ecs_entity_t type,
61 void *ptr,
62 const char *json,
63 const ecs_from_json_desc_t *desc);
64
75FLECS_API
77 ecs_world_t *world,
78 ecs_entity_t entity,
79 const char *json,
80 const ecs_from_json_desc_t *desc);
81
88FLECS_API
90 ecs_world_t *world,
91 const char *json,
92 const ecs_from_json_desc_t *desc);
93
108FLECS_API
110 const ecs_world_t *world,
111 ecs_entity_t type,
112 const void *data,
113 int32_t count);
114
125FLECS_API
127 const ecs_world_t *world,
128 ecs_entity_t type,
129 const void *data,
130 int32_t count,
131 ecs_strbuf_t *buf_out);
132
141FLECS_API
143 const ecs_world_t *world,
144 ecs_entity_t type,
145 const void *data);
146
156FLECS_API
158 const ecs_world_t *world,
159 ecs_entity_t type,
160 const void *data,
161 ecs_strbuf_t *buf_out);
162
173FLECS_API
175 const ecs_world_t *world,
176 ecs_entity_t type);
177
186FLECS_API
188 const ecs_world_t *world,
189 ecs_entity_t type,
190 ecs_strbuf_t *buf_out);
191
209
210#define ECS_ENTITY_TO_JSON_INIT (ecs_entity_to_json_desc_t){true, false,\
211 false, false, false, false, false, true, false, false, false, false, false, false }
212
223FLECS_API
225 const ecs_world_t *world,
226 ecs_entity_t entity,
227 const ecs_entity_to_json_desc_t *desc);
228
237FLECS_API
239 const ecs_world_t *world,
240 ecs_entity_t entity,
241 ecs_strbuf_t *buf_out,
242 const ecs_entity_to_json_desc_t *desc);
243
263
264#define ECS_ITER_TO_JSON_INIT (ecs_iter_to_json_desc_t){\
265 .serialize_term_ids = true, \
266 .serialize_ids = true, \
267 .serialize_sources = true, \
268 .serialize_variables = true, \
269 .serialize_is_set = true, \
270 .serialize_values = true, \
271 .serialize_entities = true, \
272 .serialize_entity_labels = false, \
273 .serialize_entity_ids = false, \
274 .serialize_entity_names = false, \
275 .serialize_variable_labels = false, \
276 .serialize_variable_ids = false, \
277 .serialize_colors = false, \
278 .measure_eval_duration = false, \
279 .serialize_type_info = false, \
280 .serialize_table = false \
281}
282
291FLECS_API
293 const ecs_world_t *world,
294 ecs_iter_t *iter,
295 const ecs_iter_to_json_desc_t *desc);
296
305FLECS_API
307 const ecs_world_t *world,
308 ecs_iter_t *iter,
309 ecs_strbuf_t *buf_out,
310 const ecs_iter_to_json_desc_t *desc);
311
317
333FLECS_API
335 ecs_world_t *world,
336 const ecs_world_to_json_desc_t *desc);
337
345FLECS_API
347 ecs_world_t *world,
348 ecs_strbuf_t *buf_out,
349 const ecs_world_to_json_desc_t *desc);
350
351#ifdef __cplusplus
352}
353#endif
354
355#endif
356
359#endif
FLECS_API const char * ecs_entity_from_json(ecs_world_t *world, ecs_entity_t entity, const char *json, const ecs_from_json_desc_t *desc)
Parse JSON object with multiple component values into entity.
FLECS_API const char * ecs_world_from_json(ecs_world_t *world, const char *json, const ecs_from_json_desc_t *desc)
Parse JSON object with multiple entities into the world.
FLECS_API int ecs_type_info_to_json_buf(const ecs_world_t *world, ecs_entity_t type, ecs_strbuf_t *buf_out)
Serialize type info into JSON string buffer.
FLECS_API int ecs_ptr_to_json_buf(const ecs_world_t *world, ecs_entity_t type, const void *data, ecs_strbuf_t *buf_out)
Serialize value into JSON string buffer.
FLECS_API char * ecs_entity_to_json(const ecs_world_t *world, ecs_entity_t entity, const ecs_entity_to_json_desc_t *desc)
Serialize entity into JSON string.
FLECS_API char * ecs_ptr_to_json(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into JSON string.
FLECS_API char * ecs_type_info_to_json(const ecs_world_t *world, ecs_entity_t type)
Serialize type info to JSON.
FLECS_API int ecs_world_to_json_buf(ecs_world_t *world, ecs_strbuf_t *buf_out, const ecs_world_to_json_desc_t *desc)
Serialize world into JSON string buffer.
FLECS_API char * ecs_iter_to_json(const ecs_world_t *world, ecs_iter_t *iter, const ecs_iter_to_json_desc_t *desc)
Serialize iterator into JSON string.
FLECS_API char * ecs_world_to_json(ecs_world_t *world, const ecs_world_to_json_desc_t *desc)
Serialize world into JSON string.
FLECS_API int ecs_iter_to_json_buf(const ecs_world_t *world, ecs_iter_t *iter, ecs_strbuf_t *buf_out, const ecs_iter_to_json_desc_t *desc)
Serialize iterator into JSON string buffer.
FLECS_API const char * ecs_ptr_from_json(const ecs_world_t *world, ecs_entity_t type, void *ptr, const char *json, const ecs_from_json_desc_t *desc)
Parse JSON string into value.
FLECS_API int ecs_array_to_json_buf(const ecs_world_t *world, ecs_entity_t type, const void *data, int32_t count, ecs_strbuf_t *buf_out)
Serialize array into JSON string buffer.
FLECS_API char * ecs_array_to_json(const ecs_world_t *world, ecs_entity_t type, const void *data, int32_t count)
Serialize array into JSON string.
FLECS_API int ecs_entity_to_json_buf(const ecs_world_t *world, ecs_entity_t entity, ecs_strbuf_t *buf_out, const ecs_entity_to_json_desc_t *desc)
Serialize entity into JSON string buffer.
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:282
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:291
Used with ecs_iter_to_json.
Definition json.h:193
bool serialize_values
Serialize component values.
Definition json.h:204
bool serialize_label
Serialize doc name.
Definition json.h:196
bool serialize_alerts
Serialize active alerts for entity.
Definition json.h:206
bool serialize_brief
Serialize brief doc description.
Definition json.h:197
bool serialize_hidden
Serialize ids hidden by override.
Definition json.h:203
bool serialize_meta_ids
Serialize 'meta' ids (Name, ChildOf, etc)
Definition json.h:195
bool serialize_path
Serialize full pathname.
Definition json.h:194
bool serialize_private
Serialize private components.
Definition json.h:202
ecs_entity_t serialize_refs
Serialize references (incoming edges) for relationship.
Definition json.h:207
bool serialize_id_labels
Serialize labels of (component) ids.
Definition json.h:200
bool serialize_link
Serialize doc link (URL)
Definition json.h:198
bool serialize_type_info
Serialize type info (requires serialize_values)
Definition json.h:205
bool serialize_color
Serialize doc color.
Definition json.h:199
bool serialize_base
Serialize base components.
Definition json.h:201
Used with ecs_ptr_from_json, ecs_entity_from_json.
Definition json.h:33
const char * name
Name of expression (used for logging)
Definition json.h:34
ecs_entity_t(* lookup_action)(const ecs_world_t *, const char *value, void *ctx)
Callback that allows for specifying a custom lookup function.
Definition json.h:39
const char * expr
Full expression (used for logging)
Definition json.h:35
Used with ecs_iter_to_json.
Definition json.h:245
bool serialize_ids
Serialize actual (matched) component ids.
Definition json.h:247
bool measure_eval_duration
Serialize evaluation duration.
Definition json.h:259
bool serialize_variable_ids
Serialize numerical ids for variables.
Definition json.h:257
bool serialize_sources
Serialize sources.
Definition json.h:248
bool serialize_colors
Serialize doc color for entities.
Definition json.h:258
bool serialize_entities
Serialize entities (for This terms)
Definition json.h:252
bool serialize_variables
Serialize variables.
Definition json.h:249
bool serialize_entity_names
Serialize names (not paths) for entities.
Definition json.h:255
bool serialize_variable_labels
Serialize doc name for variables.
Definition json.h:256
bool serialize_table
Serialize entire table vs.
Definition json.h:261
bool serialize_term_ids
Serialize term (query) component ids.
Definition json.h:246
bool serialize_entity_labels
Serialize doc name for entities.
Definition json.h:253
bool serialize_values
Serialize component values.
Definition json.h:251
bool serialize_type_info
Serialize type information.
Definition json.h:260
bool serialize_entity_ids
Serialize numerical ids for entities.
Definition json.h:254
bool serialize_is_set
Serialize is_set (for optional terms)
Definition json.h:250
Used with ecs_iter_to_json.
Definition json.h:313
bool serialize_builtin
Exclude flecs modules & contents.
Definition json.h:314
bool serialize_modules
Exclude modules & contents.
Definition json.h:315