![]() |
Flecs v3.2
A fast entity component system (ECS) for C & C++
|
Query DSL parser and parsing utilities. More...
Functions | |
FLECS_API const char * | ecs_parse_ws (const char *ptr) |
Skip whitespace characters. More... | |
FLECS_API const char * | ecs_parse_ws_eol (const char *ptr) |
Skip whitespace and newline characters. More... | |
const char * | ecs_parse_identifier (const char *name, const char *expr, const char *ptr, char *token_out) |
Utility function to parse an identifier. | |
FLECS_API const char * | ecs_parse_digit (const char *ptr, char *token) |
Parse digit. More... | |
FLECS_API const char * | ecs_parse_token (const char *name, const char *expr, const char *ptr, char *token_out, char delim) |
Parse a single token. More... | |
FLECS_API char * | ecs_parse_term (const ecs_world_t *world, const char *name, const char *expr, const char *ptr, ecs_term_t *term_out) |
Parse term in expression. More... | |
Query DSL parser and parsing utilities.
FLECS_API const char * ecs_parse_digit | ( | const char * | ptr, |
char * | token | ||
) |
Parse digit.
This function will parse until the first non-digit character is found. The provided expression must contain at least one digit character.
ptr | The expression to parse. |
token | The output buffer. |
FLECS_API char * ecs_parse_term | ( | const ecs_world_t * | world, |
const char * | name, | ||
const char * | expr, | ||
const char * | ptr, | ||
ecs_term_t * | term_out | ||
) |
Parse term in expression.
This operation parses a single term in an expression and returns a pointer to the next term expression.
If the returned pointer points to the 0-terminator, the expression is fully parsed. The function would typically be called in a while loop:
const char *ptr = expr; while (ptr[0] && (ptr = ecs_parse_term(world, name, expr, ptr, &term))) { }
The operation does not attempt to find entity ids from the names in the expression. Use the ecs_term_resolve_ids function to resolve the identifiers in the parsed term.
The returned term will in most cases contain allocated resources, which should freed (or used) by the application. To free the resources for a term, use the ecs_term_free function.
The parser accepts expressions in the legacy string format.
world | The world. |
name | The name of the expression (optional, improves error logs) |
expr | The expression to parse (optional, improves error logs) |
ptr | The pointer to the current term (must be in expr). |
term_out | Out parameter for the term. |
FLECS_API const char * ecs_parse_token | ( | const char * | name, |
const char * | expr, | ||
const char * | ptr, | ||
char * | token_out, | ||
char | delim | ||
) |
Parse a single token.
This function can be used as simple tokenizer by other parsers.
name | of program (used for logging). |
expr | pointer to token to parse. |
ptr | pointer to first character to parse. |
token_out | Parsed token (buffer should be ECS_MAX_TOKEN_SIZE large) |
FLECS_API const char * ecs_parse_ws | ( | const char * | ptr | ) |
Skip whitespace characters.
This function skips whitespace characters. Does not skip newlines.
ptr | Pointer to (potential) whitespaces to skip. |
FLECS_API const char * ecs_parse_ws_eol | ( | const char * | ptr | ) |
Skip whitespace and newline characters.
This function skips whitespace characters.
ptr | Pointer to (potential) whitespaces to skip. |