librfn
An ad-hoc utility library
Data Structures | Macros | Functions
Enumerations

Convert enumerations to strings and strings to enumerations. More...

Data Structures

struct  rf_enumtable_t
 Lookup table used for the conversions. More...
 

Macros

#define RF_ENUMTABLE_INITIALIZER(...)   { __VA_ARGS__, RF_ENUMTABLE_TERMINATOR }
 
#define RF_ENUM_OUT_OF_RANGE   -19830927
 
#define RF_ENUMTABLE_TERMINATOR   { NULL, 0 }
 

Functions

const char * rf_enum2string (rf_enumtable_t *t, int e)
 
int rf_string2enum (rf_enumtable_t *t, const char *s)
 

Detailed Description

Convert enumerations to strings and strings to enumerations.

Macro Definition Documentation

#define RF_ENUM_OUT_OF_RANGE   -19830927

Definition at line 56 of file enum.h.

#define RF_ENUMTABLE_INITIALIZER (   ...)    { __VA_ARGS__, RF_ENUMTABLE_TERMINATOR }

Initialize a enum lookup table.

Using this macro optional but guarantees that the initializer is correctly terminated.

Definition at line 54 of file enum.h.

#define RF_ENUMTABLE_TERMINATOR   { NULL, 0 }

Definition at line 57 of file enum.h.

Function Documentation

const char* rf_enum2string ( rf_enumtable_t t,
int  e 
)

Definition at line 18 of file enum.c.

int rf_string2enum ( rf_enumtable_t t,
const char *  s 
)

Definition at line 28 of file enum.c.