Flecs: include/flecs/addons/cpp/mixins/json/entity_builder.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
entity_builder.inl
Go to the documentation of this file.
1
5
11 const Self& set_json(
12 flecs::id_t e,
13 const char *json,
14 flecs::from_json_desc_t *desc = nullptr) const
15{
16 flecs::entity_t type = ecs_get_typeid(world_, e);
17 if (!type) {
18 ecs_err("id is not a type");
19 return to_base();
20 }
21
22 void *ptr = ecs_ensure_id(world_, id_, e);
23 ecs_assert(ptr != NULL, ECS_INTERNAL_ERROR, NULL);
24 ecs_ptr_from_json(world_, type, ptr, json, desc);
25 ecs_modified_id(world_, id_, e);
26
27 return to_base();
28}
29
35 const Self& set_json(
36 flecs::entity_t r,
37 flecs::entity_t t,
38 const char *json,
39 flecs::from_json_desc_t *desc = nullptr) const
40{
41 return set_json(ecs_pair(r, t), json, desc);
42}
43
49template <typename T>
50 const Self& set_json(
51 const char *json,
52 flecs::from_json_desc_t *desc = nullptr) const
53{
54 return set_json(_::type<T>::id(world_), json, desc);
55}
56
62template <typename R, typename T>
63 const Self& set_json(
64 const char *json,
65 flecs::from_json_desc_t *desc = nullptr) const
66{
67 return set_json(
68 _::type<R>::id(world_),
69 _::type<T>::id(world_),
70 json, desc);
71}
72
78template <typename R>
79 const Self& set_json(
80 flecs::entity_t t,
81 const char *json,
82 flecs::from_json_desc_t *desc = nullptr) const
83{
84 return set_json(
85 _::type<R>::id(world_), t,
86 json, desc);
87}
88
94template <typename T>
95 const Self& set_json_second(
96 flecs::entity_t r,
97 const char *json,
98 flecs::from_json_desc_t *desc = nullptr) const
99{
100 return set_json(
101 r, _::type<T>::id(world_),
102 json, desc);
103}
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.
ecs_assert
#define ecs_assert(condition, error_code,...)
Assert.
Definition log.h:368
ecs_ensure_id
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
ecs_modified_id
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Signal that a component has been modified.
ecs_get_typeid
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
flecs::_::type
Definition flecs.hpp:38
flecs::entity_builder::set_json_second
const Self & set_json_second(flecs::entity_t r, const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set pair from JSON.
Definition entity_builder.inl:95
flecs::entity_builder::set_json
const Self & set_json(flecs::entity_t r, flecs::entity_t t, const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set pair from JSON.
Definition entity_builder.inl:35
flecs::entity_builder::set_json
const Self & set_json(flecs::id_t e, const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set component from JSON.
Definition entity_builder.inl:11
flecs::entity_builder::set_json
const Self & set_json(const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set pair from JSON.
Definition entity_builder.inl:63
flecs::entity_builder::set_json
const Self & set_json(const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set component from JSON.
Definition entity_builder.inl:50
flecs::entity_builder::set_json
const Self & set_json(flecs::entity_t t, const char *json, flecs::from_json_desc_t *desc=nullptr) const
Set pair from JSON.
Definition entity_builder.inl:79
flecs::entity_view::type
flecs::type type() const
Get the entity's type.
Definition impl.hpp:104