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; /* Name of expression (used for logging) */
35 const char *expr; /* Full expression (used for logging) */
36
37 ecs_entity_t (*lookup_action)(
38 const ecs_world_t*,
39 const char *value,
40 void *ctx);
41 void *lookup_ctx;
43
55FLECS_API
57 const ecs_world_t *world,
58 ecs_entity_t type,
59 void *ptr,
60 const char *json,
61 const ecs_from_json_desc_t *desc);
62
73FLECS_API
75 ecs_world_t *world,
76 ecs_entity_t entity,
77 const char *json,
78 const ecs_from_json_desc_t *desc);
79
86FLECS_API
88 ecs_world_t *world,
89 const char *json,
90 const ecs_from_json_desc_t *desc);
91
106FLECS_API
108 const ecs_world_t *world,
109 ecs_entity_t type,
110 const void *data,
111 int32_t count);
112
123FLECS_API
125 const ecs_world_t *world,
126 ecs_entity_t type,
127 const void *data,
128 int32_t count,
129 ecs_strbuf_t *buf_out);
130
139FLECS_API
141 const ecs_world_t *world,
142 ecs_entity_t type,
143 const void *data);
144
154FLECS_API
156 const ecs_world_t *world,
157 ecs_entity_t type,
158 const void *data,
159 ecs_strbuf_t *buf_out);
160
171FLECS_API
173 const ecs_world_t *world,
174 ecs_entity_t type);
175
184FLECS_API
186 const ecs_world_t *world,
187 ecs_entity_t type,
188 ecs_strbuf_t *buf_out);
189
205
206#define ECS_ENTITY_TO_JSON_INIT (ecs_entity_to_json_desc_t){true, false,\
207 false, false, false, false, false, true, false, false, false, false }
208
219FLECS_API
221 const ecs_world_t *world,
222 ecs_entity_t entity,
223 const ecs_entity_to_json_desc_t *desc);
224
233FLECS_API
235 const ecs_world_t *world,
236 ecs_entity_t entity,
237 ecs_strbuf_t *buf_out,
238 const ecs_entity_to_json_desc_t *desc);
239
259
260#define ECS_ITER_TO_JSON_INIT (ecs_iter_to_json_desc_t){\
261 .serialize_term_ids = true, \
262 .serialize_ids = true, \
263 .serialize_sources = true, \
264 .serialize_variables = true, \
265 .serialize_is_set = true, \
266 .serialize_values = true, \
267 .serialize_entities = true, \
268 .serialize_entity_labels = false, \
269 .serialize_entity_ids = false, \
270 .serialize_entity_names = false, \
271 .serialize_variable_labels = false, \
272 .serialize_variable_ids = false, \
273 .serialize_colors = false, \
274 .measure_eval_duration = false, \
275 .serialize_type_info = false, \
276 .serialize_table = false \
277}
278
287FLECS_API
289 const ecs_world_t *world,
290 ecs_iter_t *iter,
291 const ecs_iter_to_json_desc_t *desc);
292
301FLECS_API
303 const ecs_world_t *world,
304 ecs_iter_t *iter,
305 ecs_strbuf_t *buf_out,
306 const ecs_iter_to_json_desc_t *desc);
307
310 bool serialize_builtin; /* Exclude flecs modules & contents */
311 bool serialize_modules; /* Exclude modules & contents */
313
329FLECS_API
331 ecs_world_t *world,
332 const ecs_world_to_json_desc_t *desc);
333
341FLECS_API
343 ecs_world_t *world,
344 ecs_strbuf_t *buf_out,
345 const ecs_world_to_json_desc_t *desc);
346
347#ifdef __cplusplus
348}
349#endif
350
351#endif
352
355#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:277
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:286
Used with ecs_iter_to_json.
Definition: json.h:191
bool serialize_values
Serialize component values.
Definition: json.h:202
bool serialize_label
Serialize doc name.
Definition: json.h:194
bool serialize_brief
Serialize brief doc description.
Definition: json.h:195
bool serialize_hidden
Serialize ids hidden by override.
Definition: json.h:201
bool serialize_meta_ids
Serialize 'meta' ids (Name, ChildOf, etc)
Definition: json.h:193
bool serialize_path
Serialize full pathname.
Definition: json.h:192
bool serialize_private
Serialize private components.
Definition: json.h:200
bool serialize_id_labels
Serialize labels of (component) ids.
Definition: json.h:198
bool serialize_link
Serialize doc link (URL)
Definition: json.h:196
bool serialize_type_info
Serialize type info (requires serialize_values)
Definition: json.h:203
bool serialize_color
Serialize doc color.
Definition: json.h:197
bool serialize_base
Serialize base components.
Definition: json.h:199
Used with ecs_ptr_from_json, ecs_entity_from_json.
Definition: json.h:33
Used with ecs_iter_to_json.
Definition: json.h:241
bool serialize_ids
Serialize actual (matched) component ids.
Definition: json.h:243
bool measure_eval_duration
Serialize evaluation duration.
Definition: json.h:255
bool serialize_variable_ids
Serialize numerical ids for variables.
Definition: json.h:253
bool serialize_sources
Serialize sources.
Definition: json.h:244
bool serialize_colors
Serialize doc color for entities.
Definition: json.h:254
bool serialize_entities
Serialize entities (for This terms)
Definition: json.h:248
bool serialize_variables
Serialize variables.
Definition: json.h:245
bool serialize_entity_names
Serialize names (not paths) for entities.
Definition: json.h:251
bool serialize_variable_labels
Serialize doc name for variables.
Definition: json.h:252
bool serialize_table
Serialize entire table vs.
Definition: json.h:257
bool serialize_term_ids
Serialize term (query) component ids.
Definition: json.h:242
bool serialize_entity_labels
Serialize doc name for entities.
Definition: json.h:249
bool serialize_values
Serialize component values.
Definition: json.h:247
bool serialize_type_info
Serialize type information.
Definition: json.h:256
bool serialize_entity_ids
Serialize numerical ids for entities.
Definition: json.h:250
bool serialize_is_set
Serialize is_set (for optional terms)
Definition: json.h:246
Used with ecs_iter_to_json.
Definition: json.h:309