Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs_cpp.h File Reference

C++ utility functions. More...

Go to the source code of this file.

Classes

struct  ecs_cpp_component_desc_t
 
struct  ecs_cpp_get_mut_t
 Result type for C++ set/assign operations. More...
 

Typedefs

typedef void(* ecs_cpp_type_action_t) (ecs_world_t *world, ecs_entity_t component)
 
typedef struct ecs_cpp_component_desc_t ecs_cpp_component_desc_t
 
typedef struct ecs_cpp_get_mut_t ecs_cpp_get_mut_t
 Result type for C++ set/assign operations.
 

Functions

FLECS_API char * ecs_cpp_get_type_name (char *type_name, const char *func_name, size_t len, size_t front_len)
 Get type name from compiler-generated function name.
 
FLECS_API char * ecs_cpp_get_symbol_name (char *symbol_name, const char *type_name, size_t len)
 Get symbol name from type name.
 
FLECS_API char * ecs_cpp_get_constant_name (char *constant_name, const char *func_name, size_t len, size_t back_len)
 Get constant name from compiler-generated function name.
 
FLECS_API const char * ecs_cpp_trim_module (ecs_world_t *world, const char *type_name)
 Trim module prefix from type name.
 
FLECS_API ecs_entity_t ecs_cpp_component_register (ecs_world_t *world, const ecs_cpp_component_desc_t *desc)
 Register a C++ component.
 
FLECS_API void ecs_cpp_enum_init (ecs_world_t *world, ecs_entity_t id, ecs_entity_t underlying_type)
 Initialize a C++ enum type.
 
FLECS_API ecs_entity_t ecs_cpp_enum_constant_register (ecs_world_t *world, ecs_entity_t parent, ecs_entity_t id, const char *name, void *value, ecs_entity_t value_type, size_t value_size)
 Register a C++ enum constant.
 
FLECS_API FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_set (ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, const void *new_ptr, size_t size)
 Set a component value for a C++ entity.
 
FLECS_API FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_assign (ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, const void *new_ptr, size_t size)
 Assign a component value for a C++ entity.
 
FLECS_API FLECS_ALWAYS_INLINE ecs_entity_t ecs_cpp_new (ecs_world_t *world, ecs_entity_t parent, const char *name, const char *sep, const char *root_sep)
 Create a new entity from C++.
 
FLECS_API ecs_member_tecs_cpp_last_member (const ecs_world_t *world, ecs_entity_t type)
 Get the last registered member for a type.
 

Detailed Description

C++ utility functions.

This header contains utility functions that are accessible from both C and C++ code. These functions are not part of the public API and are not meant to be used directly by applications.

Definition in file flecs_cpp.h.

Typedef Documentation

◆ ecs_cpp_type_action_t

typedef void(* ecs_cpp_type_action_t) (ecs_world_t *world, ecs_entity_t component)

Definition at line 100 of file flecs_cpp.h.

Function Documentation

◆ ecs_cpp_assign()

FLECS_API FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_assign ( ecs_world_t * world,
ecs_entity_t entity,
ecs_id_t component,
const void * new_ptr,
size_t size )

Assign a component value for a C++ entity.

Parameters
worldThe world.
entityThe entity.
componentThe component ID.
new_ptrPointer to the new component value.
sizeThe size of the component.
Returns
Result containing the component pointer and metadata.

◆ ecs_cpp_component_register()

FLECS_API ecs_entity_t ecs_cpp_component_register ( ecs_world_t * world,
const ecs_cpp_component_desc_t * desc )

Register a C++ component.

Parameters
worldThe world.
descComponent registration parameters.

◆ ecs_cpp_enum_constant_register()

FLECS_API ecs_entity_t ecs_cpp_enum_constant_register ( ecs_world_t * world,
ecs_entity_t parent,
ecs_entity_t id,
const char * name,
void * value,
ecs_entity_t value_type,
size_t value_size )

Register a C++ enum constant.

Parameters
worldThe world.
parentThe parent enum type entity.
idThe entity ID for the constant.
nameThe constant name.
valuePointer to the constant value.
value_typeThe type of the constant value.
value_sizeThe size of the constant value.
Returns
The constant entity.

◆ ecs_cpp_enum_init()

FLECS_API void ecs_cpp_enum_init ( ecs_world_t * world,
ecs_entity_t id,
ecs_entity_t underlying_type )

Initialize a C++ enum type.

Parameters
worldThe world.
idThe entity ID for the enum type.
underlying_typeThe underlying integer type of the enum.

◆ ecs_cpp_get_constant_name()

FLECS_API char * ecs_cpp_get_constant_name ( char * constant_name,
const char * func_name,
size_t len,
size_t back_len )

Get constant name from compiler-generated function name.

Parameters
constant_nameBuffer to write the constant name to.
func_nameThe compiler-generated function name.
lenThe length of the constant name.
back_lenThe number of characters to skip at the back.
Returns
The constant name.

◆ ecs_cpp_get_symbol_name()

FLECS_API char * ecs_cpp_get_symbol_name ( char * symbol_name,
const char * type_name,
size_t len )

Get symbol name from type name.

Parameters
symbol_nameBuffer to write the symbol name to.
type_nameThe type name.
lenThe length of the type name.
Returns
The symbol name.

◆ ecs_cpp_get_type_name()

FLECS_API char * ecs_cpp_get_type_name ( char * type_name,
const char * func_name,
size_t len,
size_t front_len )

Get type name from compiler-generated function name.

Parameters
type_nameBuffer to write the type name to.
func_nameThe compiler-generated function name.
lenThe length of the type name.
front_lenThe number of characters to skip at the front.
Returns
The type name.

◆ ecs_cpp_last_member()

FLECS_API ecs_member_t * ecs_cpp_last_member ( const ecs_world_t * world,
ecs_entity_t type )

Get the last registered member for a type.

Parameters
worldThe world.
typeThe type entity.
Returns
Pointer to the last member, or NULL if none.

◆ ecs_cpp_new()

FLECS_API FLECS_ALWAYS_INLINE ecs_entity_t ecs_cpp_new ( ecs_world_t * world,
ecs_entity_t parent,
const char * name,
const char * sep,
const char * root_sep )

Create a new entity from C++.

Parameters
worldThe world.
parentThe parent entity.
nameThe entity name.
sepThe path separator.
root_sepThe root path separator.
Returns
The new entity.

◆ ecs_cpp_set()

FLECS_API FLECS_ALWAYS_INLINE ecs_cpp_get_mut_t ecs_cpp_set ( ecs_world_t * world,
ecs_entity_t entity,
ecs_id_t component,
const void * new_ptr,
size_t size )

Set a component value for a C++ entity.

Parameters
worldThe world.
entityThe entity.
componentThe component ID.
new_ptrPointer to the new component value.
sizeThe size of the component.
Returns
Result containing the component pointer and metadata.

◆ ecs_cpp_trim_module()

FLECS_API const char * ecs_cpp_trim_module ( ecs_world_t * world,
const char * type_name )

Trim module prefix from type name.

Parameters
worldThe world.
type_nameThe type name to trim.
Returns
The trimmed type name.