40template <
typename T,
typename ElemType =
void>
42 opaque(flecs::world_t *w =
nullptr) :
world(w) {
57 reinterpret_cast<decltype(
58 this-
>desc.type.serialize)>(func);
65 reinterpret_cast<decltype(
66 this-
>desc.type.serialize_member)>(func);
73 reinterpret_cast<decltype(
74 this-
>desc.type.serialize_element)>(func);
81 reinterpret_cast<decltype(
82 this-
>desc.type.assign_bool)>(func);
89 reinterpret_cast<decltype(
90 this-
>desc.type.assign_char)>(func);
95 opaque&
assign_int(
void (*func)(T *dst, int64_t value)) {
97 reinterpret_cast<decltype(
98 this-
>desc.type.assign_int)>(func);
105 reinterpret_cast<decltype(
106 this-
>desc.type.assign_uint)>(func);
113 reinterpret_cast<decltype(
114 this-
>desc.type.assign_float)>(func);
121 reinterpret_cast<decltype(
122 this-
>desc.type.assign_string)>(func);
131 reinterpret_cast<decltype(
132 this-
>desc.type.assign_entity)>(func);
141 reinterpret_cast<decltype(
142 this-
>desc.type.assign_id)>(func);
149 reinterpret_cast<decltype(
150 this-
>desc.type.assign_null)>(func);
155 opaque&
clear(
void (*func)(T *dst)) {
156 this->desc.type.
clear =
157 reinterpret_cast<decltype(
158 this-
>desc.type.clear)>(func);
165 reinterpret_cast<decltype(
166 this-
>desc.type.ensure_element)>(func);
173 reinterpret_cast<decltype(
174 this-
>desc.type.ensure_member)>(func);
179 opaque&
count(
size_t (*func)(
const T *dst)) {
180 this->desc.type.
count =
181 reinterpret_cast<decltype(
182 this-
>desc.type.count)>(func);
189 reinterpret_cast<decltype(
190 this-
>desc.type.resize)>(func);
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Used with ecs_opaque_init().
Type safe interface for opaque types.
opaque & assign_char(void(*func)(T *dst, char value))
Assign char value.
opaque & assign_uint(void(*func)(T *dst, uint64_t value))
Assign unsigned int value.
opaque & assign_string(void(*func)(T *dst, const char *value))
Assign string value.
opaque & assign_bool(void(*func)(T *dst, bool value))
Assign bool value.
opaque & as_type(flecs::id_t func)
Type that describes the type kind/structure of the opaque type.
opaque & assign_float(void(*func)(T *dst, double value))
Assign float value.
opaque & assign_entity(void(*func)(T *dst, ecs_world_t *world, ecs_entity_t entity))
Assign entity value.
flecs::world_t * world
Opaque type descriptor.
opaque & resize(void(*func)(T *dst, size_t count))
Resize to number of elements.
opaque & assign_null(void(*func)(T *dst))
Assign null value.
opaque & assign_id(void(*func)(T *dst, ecs_world_t *world, ecs_id_t id))
Assign (component) id value.
opaque & serialize_element(flecs::serialize_element< T > func)
Serialize element function.
opaque & ensure_member(void *(*func)(T *dst, const char *member))
Ensure & get element.
opaque & clear(void(*func)(T *dst))
Clear collection elements.
opaque & serialize_member(flecs::serialize_member< T > func)
Serialize member function.
opaque & ensure_element(ElemType *(*func)(T *dst, size_t elem))
Ensure & get collection element.
opaque & serialize(flecs::serialize< T > func)
Serialize function.
opaque & count(size_t(*func)(const T *dst))
Return number of elements.
opaque & assign_int(void(*func)(T *dst, int64_t value))
Assign int value.