38template <
typename T,
typename ElemType =
void>
40 opaque(flecs::world_t *w =
nullptr) :
world(w) {
55 reinterpret_cast<decltype(
56 this-
>desc.type.serialize)>(func);
63 reinterpret_cast<decltype(
64 this-
>desc.type.serialize_member)>(func);
71 reinterpret_cast<decltype(
72 this-
>desc.type.serialize_element)>(func);
79 reinterpret_cast<decltype(
80 this-
>desc.type.assign_bool)>(func);
87 reinterpret_cast<decltype(
88 this-
>desc.type.assign_char)>(func);
93 opaque&
assign_int(
void (*func)(T *dst, int64_t value)) {
95 reinterpret_cast<decltype(
96 this-
>desc.type.assign_int)>(func);
103 reinterpret_cast<decltype(
104 this-
>desc.type.assign_uint)>(func);
111 reinterpret_cast<decltype(
112 this-
>desc.type.assign_float)>(func);
119 reinterpret_cast<decltype(
120 this-
>desc.type.assign_string)>(func);
129 reinterpret_cast<decltype(
130 this-
>desc.type.assign_entity)>(func);
139 reinterpret_cast<decltype(
140 this-
>desc.type.assign_id)>(func);
147 reinterpret_cast<decltype(
148 this-
>desc.type.assign_null)>(func);
153 opaque&
clear(
void (*func)(T *dst)) {
154 this->desc.type.
clear =
155 reinterpret_cast<decltype(
156 this-
>desc.type.clear)>(func);
163 reinterpret_cast<decltype(
164 this-
>desc.type.ensure_element)>(func);
171 reinterpret_cast<decltype(
172 this-
>desc.type.ensure_member)>(func);
177 opaque&
count(
size_t (*func)(
const T *dst)) {
178 this->desc.type.
count =
179 reinterpret_cast<decltype(
180 this-
>desc.type.count)>(func);
187 reinterpret_cast<decltype(
188 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.