Flecs v3.2
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
Ids

Functions for working with ecs_id_t. More...

Collaboration diagram for Ids:

Functions

bool ecs_id_is_tag (const ecs_world_t *world, ecs_id_t id)
 Returns whether specified id a tag.
 
bool ecs_id_is_union (const ecs_world_t *world, ecs_id_t id)
 Return whether represents a union.
 
bool ecs_id_in_use (const ecs_world_t *world, ecs_id_t id)
 Returns whether specified id is in use.
 
ecs_entity_t ecs_get_typeid (const ecs_world_t *world, ecs_id_t id)
 Get the type for an id.
 
bool ecs_id_match (ecs_id_t id, ecs_id_t pattern)
 Utility to match an id with a pattern.
 
bool ecs_id_is_pair (ecs_id_t id)
 Utility to check if id is a pair.
 
bool ecs_id_is_wildcard (ecs_id_t id)
 Utility to check if id is a wildcard.
 
bool ecs_id_is_valid (const ecs_world_t *world, ecs_id_t id)
 Utility to check if id is valid.
 
ecs_flags32_t ecs_id_get_flags (const ecs_world_t *world, ecs_id_t id)
 Get flags associated with id.
 
const char * ecs_id_flag_str (ecs_id_t id_flags)
 Convert id flag to string.
 
char * ecs_id_str (const ecs_world_t *world, ecs_id_t id)
 Convert id to string.
 
void ecs_id_str_buf (const ecs_world_t *world, ecs_id_t id, ecs_strbuf_t *buf)
 Write id string to buffer.
 

Detailed Description

Functions for working with ecs_id_t.

Function Documentation

◆ ecs_get_typeid()

ecs_entity_t ecs_get_typeid ( const ecs_world_t * world,
ecs_id_t id )

Get the type for an id.

This operation returns the component id for an id, if the id is associated with a type. For a regular component with a non-zero size (an entity with the EcsComponent component) the operation will return the entity itself.

For an entity that does not have the EcsComponent component, or with an EcsComponent value with size 0, the operation will return 0.

For a pair id the operation will return the type associated with the pair, by applying the following rules in order:

  • The first pair element is returned if it is a component
  • 0 is returned if the relationship entity has the Tag property
  • The second pair element is returned if it is a component
  • 0 is returned.
Parameters
worldThe world.
idThe id.
Returns
The type id of the id.

◆ ecs_id_flag_str()

const char * ecs_id_flag_str ( ecs_id_t id_flags)

Convert id flag to string.

This operation converts a id flag to a string.

Parameters
id_flagsThe id flag.
Returns
The id flag string, or NULL if no valid id is provided.

◆ ecs_id_get_flags()

ecs_flags32_t ecs_id_get_flags ( const ecs_world_t * world,
ecs_id_t id )

Get flags associated with id.

This operation returns the internal flags (see api_flags.h) that are associated with the provided id.

Parameters
worldThe world.
idThe id.
Returns
Flags associated with the id, or 0 if the id is not in use.

◆ ecs_id_in_use()

bool ecs_id_in_use ( const ecs_world_t * world,
ecs_id_t id )

Returns whether specified id is in use.

This operation returns whether an id is in use in the world. An id is in use if it has been added to one or more tables.

Parameters
worldThe world.
idThe id.
Returns
Whether the id is in use.

◆ ecs_id_is_pair()

bool ecs_id_is_pair ( ecs_id_t id)

Utility to check if id is a pair.

Parameters
idThe id.
Returns
True if id is a pair.

◆ ecs_id_is_tag()

bool ecs_id_is_tag ( const ecs_world_t * world,
ecs_id_t id )

Returns whether specified id a tag.

This operation returns whether the specified type is a tag (a component without data/size).

An id is a tag when:

  • it is an entity without the EcsComponent component
  • it has an EcsComponent with size member set to 0
  • it is a pair where both elements are a tag
  • it is a pair where the first element has the EcsTag tag
Parameters
worldThe world.
idThe id.
Returns
Whether the provided id is a tag.

◆ ecs_id_is_union()

bool ecs_id_is_union ( const ecs_world_t * world,
ecs_id_t id )

Return whether represents a union.

This operation returns whether the specified type represents a union. Only pair ids can be unions.

An id represents a union when:

  • The first element of the pair is EcsUnion/flecs::Union
  • The first element of the pair has EcsUnion/flecs::Union
Parameters
worldThe world.
idThe id.
Returns
Whether the provided id represents a union.

◆ ecs_id_is_valid()

bool ecs_id_is_valid ( const ecs_world_t * world,
ecs_id_t id )

Utility to check if id is valid.

A valid id is an id that can be added to an entity. Invalid ids are:

  • ids that contain wildcards
  • ids that contain invalid entities
  • ids that are 0 or contain 0 entities

Note that the same rules apply to removing from an entity, with the exception of wildcards.

Parameters
worldThe world.
idThe id.
Returns
True if the id is valid.

◆ ecs_id_is_wildcard()

bool ecs_id_is_wildcard ( ecs_id_t id)

Utility to check if id is a wildcard.

Parameters
idThe id.
Returns
True if id is a wildcard or a pair containing a wildcard.

◆ ecs_id_match()

bool ecs_id_match ( ecs_id_t id,
ecs_id_t pattern )

Utility to match an id with a pattern.

This operation returns true if the provided pattern matches the provided id. The pattern may contain a wildcard (or wildcards, when a pair).

Parameters
idThe id.
patternThe pattern to compare with.

◆ ecs_id_str()

char * ecs_id_str ( const ecs_world_t * world,
ecs_id_t id )

Convert id to string.

This operation interprets the structure of an id and converts it to a string.

Parameters
worldThe world.
idThe id to convert to a string.
Returns
The id converted to a string.

◆ ecs_id_str_buf()

void ecs_id_str_buf ( const ecs_world_t * world,
ecs_id_t id,
ecs_strbuf_t * buf )

Write id string to buffer.

Same as ecs_id_str() but writes result to ecs_strbuf_t.

Parameters
worldThe world.
idThe id to convert to a string.
bufThe buffer to write to.