Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Flecs reflection framework. More...
Classes | |
struct | EcsType |
Component that is automatically added to every type with the right kind. More... | |
struct | EcsPrimitive |
Component added to primitive types. More... | |
struct | EcsMember |
Component added to member entities. More... | |
struct | ecs_member_value_range_t |
Type expressing a range for a member value. More... | |
struct | EcsMemberRanges |
Component added to member entities to express valid value ranges. More... | |
struct | ecs_member_t |
Element type of members vector in EcsStruct. More... | |
struct | EcsStruct |
Component added to struct type entities. More... | |
struct | ecs_enum_constant_t |
Type that describes an enum constant. More... | |
struct | EcsEnum |
Component added to enum type entities. More... | |
struct | ecs_bitmask_constant_t |
Type that describes an bitmask constant. More... | |
struct | EcsBitmask |
Component added to bitmask type entities. More... | |
struct | EcsArray |
Component added to array type entities. More... | |
struct | EcsVector |
Component added to vector type entities. More... | |
struct | ecs_serializer_t |
Serializer interface. More... | |
struct | EcsOpaque |
Opaque type reflection data. More... | |
struct | ecs_unit_translation_t |
Helper type to describe translation between two units. More... | |
struct | EcsUnit |
Component that stores unit data. More... | |
struct | EcsUnitPrefix |
Component that stores unit prefix data. More... | |
struct | ecs_meta_type_op_t |
Meta type serializer instruction data. More... | |
struct | EcsTypeSerializer |
Component that stores the type serializer. More... | |
struct | ecs_meta_scope_t |
Type with information about currently serialized scope. More... | |
struct | ecs_meta_cursor_t |
Type that enables iterating/populating a value using reflection data. More... | |
struct | ecs_primitive_desc_t |
Used with ecs_primitive_init(). More... | |
struct | ecs_enum_desc_t |
Used with ecs_enum_init(). More... | |
struct | ecs_bitmask_desc_t |
Used with ecs_bitmask_init(). More... | |
struct | ecs_array_desc_t |
Used with ecs_array_init(). More... | |
struct | ecs_vector_desc_t |
Used with ecs_vector_init(). More... | |
struct | ecs_struct_desc_t |
Used with ecs_struct_init(). More... | |
struct | ecs_opaque_desc_t |
Used with ecs_opaque_init(). More... | |
struct | ecs_unit_desc_t |
Used with ecs_unit_init(). More... | |
struct | ecs_unit_prefix_desc_t |
Used with ecs_unit_prefix_init(). More... | |
Macros | |
#define | FLECS_META_H |
#define | ECS_MEMBER_DESC_CACHE_SIZE (32) |
Max number of constants/members that can be specified in desc structs. | |
#define | ECS_META_MAX_SCOPE_DEPTH (32) |
Maximum level of type nesting. | |
#define | ecs_primitive(world, ...) ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ ) |
Create a primitive type. | |
#define | ecs_enum(world, ...) ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ ) |
Create an enum type. | |
#define | ecs_bitmask(world, ...) ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ ) |
Create a bitmask type. | |
#define | ecs_array(world, ...) ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ ) |
Create an array type. | |
#define | ecs_vector(world, ...) ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ ) |
Create a vector type. | |
#define | ecs_opaque(world, ...) ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ ) |
Create an opaque type. | |
#define | ecs_struct(world, ...) ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ ) |
Create a struct type. | |
#define | ecs_unit(world, ...) ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ ) |
Create a unit. | |
#define | ecs_unit_prefix(world, ...) ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ ) |
Create a unit prefix. | |
#define | ecs_quantity(world, ...) ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ ) |
Create a unit quantity. | |
Typedefs | |
typedef bool | ecs_bool_t |
Primitive type definitions. | |
typedef char | ecs_char_t |
Builtin char type. | |
typedef unsigned char | ecs_byte_t |
Builtin ecs_byte type. | |
typedef uint8_t | ecs_u8_t |
Builtin u8 type. | |
typedef uint16_t | ecs_u16_t |
Builtin u16 type. | |
typedef uint32_t | ecs_u32_t |
Builtin u32 type. | |
typedef uint64_t | ecs_u64_t |
Builtin u64 type. | |
typedef uintptr_t | ecs_uptr_t |
Builtin uptr type. | |
typedef int8_t | ecs_i8_t |
Builtin i8 type. | |
typedef int16_t | ecs_i16_t |
Builtin i16 type. | |
typedef int32_t | ecs_i32_t |
Builtin i32 type. | |
typedef int64_t | ecs_i64_t |
Builtin i64 type. | |
typedef intptr_t | ecs_iptr_t |
Builtin iptr type. | |
typedef float | ecs_f32_t |
Builtin f32 type. | |
typedef double | ecs_f64_t |
Builtin f64 type. | |
typedef char * | ecs_string_t |
Builtin string type. | |
typedef enum ecs_type_kind_t | ecs_type_kind_t |
Type kinds supported by meta addon. | |
typedef struct EcsType | EcsType |
Component that is automatically added to every type with the right kind. | |
typedef enum ecs_primitive_kind_t | ecs_primitive_kind_t |
Primitive type kinds supported by meta addon. | |
typedef struct EcsPrimitive | EcsPrimitive |
Component added to primitive types. | |
typedef struct EcsMember | EcsMember |
Component added to member entities. | |
typedef struct ecs_member_value_range_t | ecs_member_value_range_t |
Type expressing a range for a member value. | |
typedef struct EcsMemberRanges | EcsMemberRanges |
Component added to member entities to express valid value ranges. | |
typedef struct ecs_member_t | ecs_member_t |
Element type of members vector in EcsStruct. | |
typedef struct EcsStruct | EcsStruct |
Component added to struct type entities. | |
typedef struct ecs_enum_constant_t | ecs_enum_constant_t |
Type that describes an enum constant. | |
typedef struct EcsEnum | EcsEnum |
Component added to enum type entities. | |
typedef struct ecs_bitmask_constant_t | ecs_bitmask_constant_t |
Type that describes an bitmask constant. | |
typedef struct EcsBitmask | EcsBitmask |
Component added to bitmask type entities. | |
typedef struct EcsArray | EcsArray |
Component added to array type entities. | |
typedef struct EcsVector | EcsVector |
Component added to vector type entities. | |
typedef struct ecs_serializer_t | ecs_serializer_t |
Serializer interface. | |
typedef int(* | ecs_meta_serialize_t) (const ecs_serializer_t *ser, const void *src) |
Callback invoked serializing an opaque type. | |
typedef struct EcsOpaque | EcsOpaque |
Opaque type reflection data. | |
typedef struct ecs_unit_translation_t | ecs_unit_translation_t |
Helper type to describe translation between two units. | |
typedef struct EcsUnit | EcsUnit |
Component that stores unit data. | |
typedef struct EcsUnitPrefix | EcsUnitPrefix |
Component that stores unit prefix data. | |
typedef enum ecs_meta_type_op_kind_t | ecs_meta_type_op_kind_t |
Serializer instruction opcodes. | |
typedef struct ecs_meta_type_op_t | ecs_meta_type_op_t |
Meta type serializer instruction data. | |
typedef struct EcsTypeSerializer | EcsTypeSerializer |
Component that stores the type serializer. | |
typedef struct ecs_meta_scope_t | ecs_meta_scope_t |
Type with information about currently serialized scope. | |
typedef struct ecs_meta_cursor_t | ecs_meta_cursor_t |
Type that enables iterating/populating a value using reflection data. | |
typedef struct ecs_primitive_desc_t | ecs_primitive_desc_t |
Used with ecs_primitive_init(). | |
typedef struct ecs_enum_desc_t | ecs_enum_desc_t |
Used with ecs_enum_init(). | |
typedef struct ecs_bitmask_desc_t | ecs_bitmask_desc_t |
Used with ecs_bitmask_init(). | |
typedef struct ecs_array_desc_t | ecs_array_desc_t |
Used with ecs_array_init(). | |
typedef struct ecs_vector_desc_t | ecs_vector_desc_t |
Used with ecs_vector_init(). | |
typedef struct ecs_struct_desc_t | ecs_struct_desc_t |
Used with ecs_struct_init(). | |
typedef struct ecs_opaque_desc_t | ecs_opaque_desc_t |
Used with ecs_opaque_init(). | |
typedef struct ecs_unit_desc_t | ecs_unit_desc_t |
Used with ecs_unit_init(). | |
typedef struct ecs_unit_prefix_desc_t | ecs_unit_prefix_desc_t |
Used with ecs_unit_prefix_init(). | |
Enumerations | |
enum | ecs_type_kind_t { EcsPrimitiveType , EcsBitmaskType , EcsEnumType , EcsStructType , EcsArrayType , EcsVectorType , EcsOpaqueType , EcsTypeKindLast = EcsOpaqueType } |
Type kinds supported by meta addon. More... | |
enum | ecs_primitive_kind_t { EcsBool = 1 , EcsChar , EcsByte , EcsU8 , EcsU16 , EcsU32 , EcsU64 , EcsI8 , EcsI16 , EcsI32 , EcsI64 , EcsF32 , EcsF64 , EcsUPtr , EcsIPtr , EcsString , EcsEntity , EcsId , EcsPrimitiveKindLast = EcsId } |
Primitive type kinds supported by meta addon. More... | |
enum | ecs_meta_type_op_kind_t { EcsOpArray , EcsOpVector , EcsOpOpaque , EcsOpPush , EcsOpPop , EcsOpScope , EcsOpEnum , EcsOpBitmask , EcsOpPrimitive , EcsOpBool , EcsOpChar , EcsOpByte , EcsOpU8 , EcsOpU16 , EcsOpU32 , EcsOpU64 , EcsOpI8 , EcsOpI16 , EcsOpI32 , EcsOpI64 , EcsOpF32 , EcsOpF64 , EcsOpUPtr , EcsOpIPtr , EcsOpString , EcsOpEntity , EcsOpId , EcsMetaTypeOpKindLast = EcsOpId } |
Serializer instruction opcodes. More... | |
Functions | |
FLECS_API const ecs_entity_t | ecs_id (EcsType) |
Id for component added to all types with reflection data. | |
FLECS_API const ecs_entity_t | ecs_id (EcsTypeSerializer) |
Id for component that stores a type specific serializer. | |
FLECS_API const ecs_entity_t | ecs_id (EcsPrimitive) |
Id for component that stores reflection data for a primitive type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsEnum) |
Id for component that stores reflection data for an enum type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsBitmask) |
Id for component that stores reflection data for a bitmask type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsMember) |
Id for component that stores reflection data for struct members. | |
FLECS_API const ecs_entity_t | ecs_id (EcsMemberRanges) |
Id for component that stores min/max ranges for member values. | |
FLECS_API const ecs_entity_t | ecs_id (EcsStruct) |
Id for component that stores reflection data for a struct type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsArray) |
Id for component that stores reflection data for an array type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsVector) |
Id for component that stores reflection data for a vector type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsOpaque) |
Id for component that stores reflection data for an opaque type. | |
FLECS_API const ecs_entity_t | ecs_id (EcsUnit) |
Id for component that stores unit data. | |
FLECS_API const ecs_entity_t | ecs_id (EcsUnitPrefix) |
Id for component that stores unit prefix data. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_bool_t) |
Builtin boolean type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_char_t) |
Builtin char type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_byte_t) |
Builtin byte type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_u8_t) |
Builtin 8 bit unsigned int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_u16_t) |
Builtin 16 bit unsigned int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_u32_t) |
Builtin 32 bit unsigned int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_u64_t) |
Builtin 64 bit unsigned int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_uptr_t) |
Builtin pointer sized unsigned int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_i8_t) |
Builtin 8 bit signed int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_i16_t) |
Builtin 16 bit signed int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_i32_t) |
Builtin 32 bit signed int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_i64_t) |
Builtin 64 bit signed int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_iptr_t) |
Builtin pointer sized signed int type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_f32_t) |
Builtin 32 bit floating point type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_f64_t) |
Builtin 64 bit floating point type. | |
FLECS_API const ecs_entity_t | ecs_id (ecs_string_t) |
Builtin string type. | |
FLECS_API ecs_meta_cursor_t | ecs_meta_cursor (const ecs_world_t *world, ecs_entity_t type, void *ptr) |
Create meta cursor. | |
FLECS_API void * | ecs_meta_get_ptr (ecs_meta_cursor_t *cursor) |
Get pointer to current field. | |
FLECS_API int | ecs_meta_next (ecs_meta_cursor_t *cursor) |
Move cursor to next field. | |
FLECS_API int | ecs_meta_elem (ecs_meta_cursor_t *cursor, int32_t elem) |
Move cursor to a field. | |
FLECS_API int | ecs_meta_member (ecs_meta_cursor_t *cursor, const char *name) |
Move cursor to member. | |
FLECS_API int | ecs_meta_dotmember (ecs_meta_cursor_t *cursor, const char *name) |
Move cursor to member. | |
FLECS_API int | ecs_meta_push (ecs_meta_cursor_t *cursor) |
Push a scope (required/only valid for structs & collections). | |
FLECS_API int | ecs_meta_pop (ecs_meta_cursor_t *cursor) |
Pop a struct or collection scope (must follow a push). | |
FLECS_API bool | ecs_meta_is_collection (const ecs_meta_cursor_t *cursor) |
Is the current scope a collection?. | |
FLECS_API ecs_entity_t | ecs_meta_get_type (const ecs_meta_cursor_t *cursor) |
Get type of current field. | |
FLECS_API ecs_entity_t | ecs_meta_get_unit (const ecs_meta_cursor_t *cursor) |
Get unit of current field. | |
FLECS_API const char * | ecs_meta_get_member (const ecs_meta_cursor_t *cursor) |
Get member name of current field. | |
FLECS_API ecs_entity_t | ecs_meta_get_member_id (const ecs_meta_cursor_t *cursor) |
Get member entity of current field. | |
FLECS_API int | ecs_meta_set_bool (ecs_meta_cursor_t *cursor, bool value) |
Set field with boolean value. | |
FLECS_API int | ecs_meta_set_char (ecs_meta_cursor_t *cursor, char value) |
Set field with char value. | |
FLECS_API int | ecs_meta_set_int (ecs_meta_cursor_t *cursor, int64_t value) |
Set field with int value. | |
FLECS_API int | ecs_meta_set_uint (ecs_meta_cursor_t *cursor, uint64_t value) |
Set field with uint value. | |
FLECS_API int | ecs_meta_set_float (ecs_meta_cursor_t *cursor, double value) |
Set field with float value. | |
FLECS_API int | ecs_meta_set_string (ecs_meta_cursor_t *cursor, const char *value) |
Set field with string value. | |
FLECS_API int | ecs_meta_set_string_literal (ecs_meta_cursor_t *cursor, const char *value) |
Set field with string literal value (has enclosing ""). | |
FLECS_API int | ecs_meta_set_entity (ecs_meta_cursor_t *cursor, ecs_entity_t value) |
Set field with entity value. | |
FLECS_API int | ecs_meta_set_id (ecs_meta_cursor_t *cursor, ecs_id_t value) |
Set field with (component) id value. | |
FLECS_API int | ecs_meta_set_null (ecs_meta_cursor_t *cursor) |
Set field with null value. | |
FLECS_API int | ecs_meta_set_value (ecs_meta_cursor_t *cursor, const ecs_value_t *value) |
Set field with dynamic value. | |
FLECS_API bool | ecs_meta_get_bool (const ecs_meta_cursor_t *cursor) |
Get field value as boolean. | |
FLECS_API char | ecs_meta_get_char (const ecs_meta_cursor_t *cursor) |
Get field value as char. | |
FLECS_API int64_t | ecs_meta_get_int (const ecs_meta_cursor_t *cursor) |
Get field value as signed integer. | |
FLECS_API uint64_t | ecs_meta_get_uint (const ecs_meta_cursor_t *cursor) |
Get field value as unsigned integer. | |
FLECS_API double | ecs_meta_get_float (const ecs_meta_cursor_t *cursor) |
Get field value as float. | |
FLECS_API const char * | ecs_meta_get_string (const ecs_meta_cursor_t *cursor) |
Get field value as string. | |
FLECS_API ecs_entity_t | ecs_meta_get_entity (const ecs_meta_cursor_t *cursor) |
Get field value as entity. | |
ecs_id_t | ecs_meta_get_id (const ecs_meta_cursor_t *cursor) |
Get field value as (component) id. | |
FLECS_API double | ecs_meta_ptr_to_float (ecs_primitive_kind_t type_kind, const void *ptr) |
Convert pointer of primitive kind to float. | |
FLECS_API ecs_entity_t | ecs_primitive_init (ecs_world_t *world, const ecs_primitive_desc_t *desc) |
Create a new primitive type. | |
FLECS_API ecs_entity_t | ecs_enum_init (ecs_world_t *world, const ecs_enum_desc_t *desc) |
Create a new enum type. | |
FLECS_API ecs_entity_t | ecs_bitmask_init (ecs_world_t *world, const ecs_bitmask_desc_t *desc) |
Create a new bitmask type. | |
FLECS_API ecs_entity_t | ecs_array_init (ecs_world_t *world, const ecs_array_desc_t *desc) |
Create a new array type. | |
FLECS_API ecs_entity_t | ecs_vector_init (ecs_world_t *world, const ecs_vector_desc_t *desc) |
Create a new vector type. | |
FLECS_API ecs_entity_t | ecs_struct_init (ecs_world_t *world, const ecs_struct_desc_t *desc) |
Create a new struct type. | |
FLECS_API ecs_entity_t | ecs_opaque_init (ecs_world_t *world, const ecs_opaque_desc_t *desc) |
Create a new opaque type. | |
FLECS_API ecs_entity_t | ecs_unit_init (ecs_world_t *world, const ecs_unit_desc_t *desc) |
Create a new unit. | |
FLECS_API ecs_entity_t | ecs_unit_prefix_init (ecs_world_t *world, const ecs_unit_prefix_desc_t *desc) |
Create a new unit prefix. | |
FLECS_API ecs_entity_t | ecs_quantity_init (ecs_world_t *world, const ecs_entity_desc_t *desc) |
Create a new quantity. | |
FLECS_API void | FlecsMetaImport (ecs_world_t *world) |
Meta module import function. | |
Variables | |
FLECS_API const ecs_entity_t | EcsConstant |
Tag added to enum/bitmask constants. | |
FLECS_API const ecs_entity_t | EcsQuantity |
Tag added to unit quantities. | |
Flecs reflection framework.
#define ecs_array | ( | world, | |
... ) ecs_array_init(world, &(ecs_array_desc_t) __VA_ARGS__ ) |
#define ecs_bitmask | ( | world, | |
... ) ecs_bitmask_init(world, &(ecs_bitmask_desc_t) __VA_ARGS__ ) |
#define ecs_enum | ( | world, | |
... ) ecs_enum_init(world, &(ecs_enum_desc_t) __VA_ARGS__ ) |
#define ECS_MEMBER_DESC_CACHE_SIZE (32) |
#define ECS_META_MAX_SCOPE_DEPTH (32) |
#define ecs_opaque | ( | world, | |
... ) ecs_opaque_init(world, &(ecs_opaque_desc_t) __VA_ARGS__ ) |
#define ecs_primitive | ( | world, | |
... ) ecs_primitive_init(world, &(ecs_primitive_desc_t) __VA_ARGS__ ) |
#define ecs_quantity | ( | world, | |
... ) ecs_quantity_init(world, &(ecs_entity_desc_t) __VA_ARGS__ ) |
#define ecs_struct | ( | world, | |
... ) ecs_struct_init(world, &(ecs_struct_desc_t) __VA_ARGS__ ) |
#define ecs_unit | ( | world, | |
... ) ecs_unit_init(world, &(ecs_unit_desc_t) __VA_ARGS__ ) |
#define ecs_unit_prefix | ( | world, | |
... ) ecs_unit_prefix_init(world, &(ecs_unit_prefix_desc_t) __VA_ARGS__ ) |
#define ecs_vector | ( | world, | |
... ) ecs_vector_init(world, &(ecs_vector_desc_t) __VA_ARGS__ ) |
typedef bool ecs_bool_t |
Primitive type definitions.
These typedefs allow the builtin primitives to be used as regular components:
Or a more useful example (create an enum constant with a manual value):
Builtin bool type
typedef unsigned char ecs_byte_t |
typedef char ecs_char_t |
typedef intptr_t ecs_iptr_t |
typedef int(* ecs_meta_serialize_t) (const ecs_serializer_t *ser, const void *src) |
typedef enum ecs_meta_type_op_kind_t ecs_meta_type_op_kind_t |
Serializer instruction opcodes.
The meta type serializer works by generating a flattened array with instructions that tells a serializer what kind of fields can be found in a type at which offsets.
typedef char* ecs_string_t |
typedef struct ecs_unit_translation_t ecs_unit_translation_t |
Helper type to describe translation between two units.
Note that this is not intended as a generic approach to unit conversions (e.g. from celsius to fahrenheit) but to translate between units that derive from the same base (e.g. meters to kilometers).
Note that power is applied to the factor. When describing a translation of 1000, either use {factor = 1000, power = 1} or {factor = 1, power = 3}.
typedef uintptr_t ecs_uptr_t |
typedef struct EcsOpaque EcsOpaque |
Opaque type reflection data.
An opaque type is a type with an unknown layout that can be mapped to a type known to the reflection framework. See the opaque type reflection examples.
typedef struct EcsTypeSerializer EcsTypeSerializer |
Component that stores the type serializer.
Added to all types with reflection data.
Serializer instruction opcodes.
The meta type serializer works by generating a flattened array with instructions that tells a serializer what kind of fields can be found in a type at which offsets.
Enumerator | |
---|---|
EcsOpScope | Marks last constant that can open/close a scope. |
EcsOpPrimitive | Marks first constant that's a primitive. |
enum ecs_primitive_kind_t |
enum ecs_type_kind_t |
FLECS_API ecs_entity_t ecs_array_init | ( | ecs_world_t * | world, |
const ecs_array_desc_t * | desc ) |
Create a new array type.
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_bitmask_init | ( | ecs_world_t * | world, |
const ecs_bitmask_desc_t * | desc ) |
Create a new bitmask type.
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_enum_init | ( | ecs_world_t * | world, |
const ecs_enum_desc_t * | desc ) |
Create a new enum type.
world | The world. |
desc | The type descriptor. |
|
extern |
Builtin 64 bit unsigned int type.
Builtin (component) id type.
Builtin entity type.
FLECS_API ecs_meta_cursor_t ecs_meta_cursor | ( | const ecs_world_t * | world, |
ecs_entity_t | type, | ||
void * | ptr ) |
Create meta cursor.
A meta cursor allows for walking over, reading and writing a value without having to know its type at compile time.
When a value is assigned through the cursor API, it will get converted to the actual value of the underlying type. This allows the underlying type to change without having to update the serialized data. For example, an integer field can be set by a string, a floating point can be set as integer etc.
world | The world. |
type | The type of the value. |
ptr | Pointer to the value. |
FLECS_API int ecs_meta_dotmember | ( | ecs_meta_cursor_t * | cursor, |
const char * | name ) |
Move cursor to member.
Same as ecs_meta_member(), but with support for "foo.bar" syntax.
cursor | The cursor. |
name | The name of the member. |
FLECS_API int ecs_meta_elem | ( | ecs_meta_cursor_t * | cursor, |
int32_t | elem ) |
Move cursor to a field.
cursor | The cursor. |
FLECS_API bool ecs_meta_get_bool | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as boolean.
cursor | The cursor. |
FLECS_API char ecs_meta_get_char | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as char.
cursor | The cursor. |
FLECS_API ecs_entity_t ecs_meta_get_entity | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as entity.
This operation does not perform conversions.
cursor | The cursor. |
FLECS_API double ecs_meta_get_float | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as float.
cursor | The cursor. |
ecs_id_t ecs_meta_get_id | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as (component) id.
This operation can convert from an entity.
cursor | The cursor. |
FLECS_API int64_t ecs_meta_get_int | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as signed integer.
cursor | The cursor. |
FLECS_API const char * ecs_meta_get_member | ( | const ecs_meta_cursor_t * | cursor | ) |
Get member name of current field.
cursor | The cursor. |
FLECS_API ecs_entity_t ecs_meta_get_member_id | ( | const ecs_meta_cursor_t * | cursor | ) |
Get member entity of current field.
cursor | The cursor. |
FLECS_API void * ecs_meta_get_ptr | ( | ecs_meta_cursor_t * | cursor | ) |
Get pointer to current field.
cursor | The cursor. |
FLECS_API const char * ecs_meta_get_string | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as string.
This operation does not perform conversions. If the field is not a string, this operation will fail.
cursor | The cursor. |
FLECS_API ecs_entity_t ecs_meta_get_type | ( | const ecs_meta_cursor_t * | cursor | ) |
Get type of current field.
cursor | The cursor. |
FLECS_API uint64_t ecs_meta_get_uint | ( | const ecs_meta_cursor_t * | cursor | ) |
Get field value as unsigned integer.
cursor | The cursor. |
FLECS_API ecs_entity_t ecs_meta_get_unit | ( | const ecs_meta_cursor_t * | cursor | ) |
Get unit of current field.
cursor | The cursor. |
FLECS_API bool ecs_meta_is_collection | ( | const ecs_meta_cursor_t * | cursor | ) |
Is the current scope a collection?.
cursor | The cursor. |
FLECS_API int ecs_meta_member | ( | ecs_meta_cursor_t * | cursor, |
const char * | name ) |
Move cursor to member.
cursor | The cursor. |
name | The name of the member. |
FLECS_API int ecs_meta_next | ( | ecs_meta_cursor_t * | cursor | ) |
Move cursor to next field.
cursor | The cursor. |
FLECS_API int ecs_meta_pop | ( | ecs_meta_cursor_t * | cursor | ) |
Pop a struct or collection scope (must follow a push).
cursor | The cursor. |
FLECS_API double ecs_meta_ptr_to_float | ( | ecs_primitive_kind_t | type_kind, |
const void * | ptr ) |
Convert pointer of primitive kind to float.
type_kind | The primitive type kind of the value. |
ptr | Pointer to a value of a primitive type. |
FLECS_API int ecs_meta_push | ( | ecs_meta_cursor_t * | cursor | ) |
Push a scope (required/only valid for structs & collections).
cursor | The cursor. |
FLECS_API int ecs_meta_set_bool | ( | ecs_meta_cursor_t * | cursor, |
bool | value ) |
Set field with boolean value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_char | ( | ecs_meta_cursor_t * | cursor, |
char | value ) |
Set field with char value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_entity | ( | ecs_meta_cursor_t * | cursor, |
ecs_entity_t | value ) |
Set field with entity value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_float | ( | ecs_meta_cursor_t * | cursor, |
double | value ) |
Set field with float value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_id | ( | ecs_meta_cursor_t * | cursor, |
ecs_id_t | value ) |
Set field with (component) id value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_int | ( | ecs_meta_cursor_t * | cursor, |
int64_t | value ) |
Set field with int value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_null | ( | ecs_meta_cursor_t * | cursor | ) |
Set field with null value.
cursor | The cursor. |
FLECS_API int ecs_meta_set_string | ( | ecs_meta_cursor_t * | cursor, |
const char * | value ) |
Set field with string value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_string_literal | ( | ecs_meta_cursor_t * | cursor, |
const char * | value ) |
Set field with string literal value (has enclosing "").
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_uint | ( | ecs_meta_cursor_t * | cursor, |
uint64_t | value ) |
Set field with uint value.
cursor | The cursor. |
value | The value to set. |
FLECS_API int ecs_meta_set_value | ( | ecs_meta_cursor_t * | cursor, |
const ecs_value_t * | value ) |
Set field with dynamic value.
cursor | The cursor. |
value | The value to set. |
FLECS_API ecs_entity_t ecs_opaque_init | ( | ecs_world_t * | world, |
const ecs_opaque_desc_t * | desc ) |
Create a new opaque type.
Opaque types are types of which the layout doesn't match what can be modelled with the primitives of the meta framework, but which have a structure that can be described with meta primitives. Typical examples are STL types such as std::string or std::vector, types with a nontrivial layout, and types that only expose getter/setter methods.
An opaque type is a combination of a serialization function, and a handle to a meta type which describes the structure of the serialized output. For example, an opaque type for std::string would have a serializer function that accesses .c_str(), and with type ecs_string_t.
The serializer callback accepts a serializer object and a pointer to the value of the opaque type to be serialized. The serializer has two methods:
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_primitive_init | ( | ecs_world_t * | world, |
const ecs_primitive_desc_t * | desc ) |
Create a new primitive type.
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_quantity_init | ( | ecs_world_t * | world, |
const ecs_entity_desc_t * | desc ) |
Create a new quantity.
world | The world. |
desc | The quantity descriptor. |
FLECS_API ecs_entity_t ecs_struct_init | ( | ecs_world_t * | world, |
const ecs_struct_desc_t * | desc ) |
Create a new struct type.
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_unit_init | ( | ecs_world_t * | world, |
const ecs_unit_desc_t * | desc ) |
Create a new unit.
world | The world. |
desc | The unit descriptor. |
FLECS_API ecs_entity_t ecs_unit_prefix_init | ( | ecs_world_t * | world, |
const ecs_unit_prefix_desc_t * | desc ) |
Create a new unit prefix.
world | The world. |
desc | The type descriptor. |
FLECS_API ecs_entity_t ecs_vector_init | ( | ecs_world_t * | world, |
const ecs_vector_desc_t * | desc ) |
Create a new vector type.
world | The world. |
desc | The type descriptor. |
FLECS_API void FlecsMetaImport | ( | ecs_world_t * | world | ) |