YAC 3.18.0
Yet Another Coupler
Loading...
Searching...
No Matches
Name-Type pair utilities

Data Structures

struct  yac_name_type_pair
 

Functions

char const * yac_name_type_pair_get_name (struct yac_name_type_pair const *pairs, size_t count, int type)
 
int yac_name_type_pair_get_type (struct yac_name_type_pair const *pairs, size_t count, char const *name)
 

Macros

#define DEF_NAME_TYPE_PAIR(NAME, TYPE)   {.name = #NAME, .type = (int)(TYPE)}
 
#define DEF_NAME_TYPE_PAIRS(NAME, ...)
 

Detailed Description

Utilities for working with yac_name_type_pair tables.

This group provides:

Example usage:

DEF_NAME_TYPE_PAIR(false, 0),
int t =
bool_table, bool_table_size, "yes"); // t == 1
const char *n =
bool_table, bool_table_size, 0); // n == "false"
int yac_name_type_pair_get_type(struct yac_name_type_pair const *pairs, size_t count, char const *name)
Definition utils_core.c:26
#define DEF_NAME_TYPE_PAIR(NAME, TYPE)
char const * yac_name_type_pair_get_name(struct yac_name_type_pair const *pairs, size_t count, int type)
Definition utils_core.c:17
#define DEF_NAME_TYPE_PAIRS(NAME,...)
static const struct yac_name_type_pair bool_table[]
Definition param_bool.c:13

Macro Definition Documentation

◆ DEF_NAME_TYPE_PAIR

#define DEF_NAME_TYPE_PAIR ( NAME,
TYPE )   {.name = #NAME, .type = (int)(TYPE)}

Definition at line 118 of file utils_common.h.

◆ DEF_NAME_TYPE_PAIRS

#define DEF_NAME_TYPE_PAIRS ( NAME,
... )
Value:
static const struct yac_name_type_pair NAME [] = {__VA_ARGS__}; \
enum { NAME ## _size = sizeof(NAME) / sizeof(NAME[0]) };

Definition at line 119 of file utils_common.h.

Function Documentation

◆ yac_name_type_pair_get_name()

char const * yac_name_type_pair_get_name ( struct yac_name_type_pair const * pairs,
size_t count,
int type )

Get the name for a given type from a yac_name_type_pair array.

Parameters
[in]pairsArray of name/type pairs
[in]countNumber of elements in pairs
[in]typeType to look up
Returns
Name string if found, NULL otherwise

Definition at line 17 of file utils_core.c.

Here is the caller graph for this function:

◆ yac_name_type_pair_get_type()

int yac_name_type_pair_get_type ( struct yac_name_type_pair const * pairs,
size_t count,
char const * name )

Get the type for a given name from a yac_name_type_pair array.

Parameters
[in]pairsArray of name/type pairs
[in]countNumber of elements in pairs
[in]nameName string to look up
Returns
Type value if found, INT_MAX otherwise

Definition at line 26 of file utils_core.c.

Here is the caller graph for this function: