Flecs: include/flecs/addons/cpp/mixins/json/world.inl Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
world.inl
Go to the documentation of this file.
1
5
11 flecs::string to_json(flecs::entity_t tid, const void* value) {
12 char *json = ecs_ptr_to_json(world_, tid, value);
13 return flecs::string(json);
14}
15
21template <typename T>
22 flecs::string to_json(const T* value) {
23 flecs::entity_t tid = _::type<T>::id(world_);
24 return to_json(tid, value);
25}
26
32 flecs::string to_json() {
33 return flecs::string( ecs_world_to_json(world_, nullptr) );
34}
35
41 const char* from_json(flecs::entity_t tid, void* value, const char *json, flecs::from_json_desc_t *desc = nullptr) {
42 return ecs_ptr_from_json(world_, tid, value, json, desc);
43}
44
50template <typename T>
51 const char* from_json(T* value, const char *json, flecs::from_json_desc_t *desc = nullptr) {
52 return ecs_ptr_from_json(world_, _::type<T>::id(world_),
53 value, json, desc);
54}
55
61 const char* from_json(const char *json, flecs::from_json_desc_t *desc = nullptr) {
62 return ecs_world_from_json(world_, json, desc);
63}
64
70 const char* from_json_file(const char *json, flecs::from_json_desc_t *desc = nullptr) {
71 return ecs_world_from_json_file(world_, json, desc);
72}
ecs_world_from_json
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.
ecs_world_from_json_file
FLECS_API const char * ecs_world_from_json_file(ecs_world_t *world, const char *filename, const ecs_from_json_desc_t *desc)
Same as ecs_world_from_json(), but loads JSON from file.
ecs_ptr_to_json
FLECS_API char * ecs_ptr_to_json(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into JSON string.
ecs_world_to_json
FLECS_API char * ecs_world_to_json(ecs_world_t *world, const ecs_world_to_json_desc_t *desc)
Serialize world into JSON string.
ecs_ptr_from_json
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::world::to_json
flecs::string to_json(flecs::entity_t tid, const void *value)
Serialize untyped value to JSON.
Definition world.hpp:12
flecs::_::type
Definition flecs.hpp:39
flecs::string
Definition string.hpp:13
flecs::world::from_json_file
const char * from_json_file(const char *json, flecs::from_json_desc_t *desc=nullptr)
Deserialize JSON file into world.
Definition world.inl:70
flecs::world::from_json
const char * from_json(const char *json, flecs::from_json_desc_t *desc=nullptr)
Deserialize JSON into world.
Definition world.inl:61
flecs::world::to_json
flecs::string to_json(const T *value)
Serialize value to JSON.
Definition world.inl:22
flecs::world::to_json
flecs::string to_json()
Serialize world to JSON.
Definition world.inl:32
flecs::world::to_json
flecs::string to_json(flecs::entity_t tid, const void *value)
Serialize untyped value to JSON.
Definition world.inl:11
flecs::world::from_json
const char * from_json(flecs::entity_t tid, void *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
Deserialize value from JSON.
Definition world.inl:41
flecs::world::from_json
const char * from_json(T *value, const char *json, flecs::from_json_desc_t *desc=nullptr)
Deserialize value from JSON.
Definition world.inl:51