 |
NetSim Source Code Help
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
2#undef DECL_ENUM_ELEMENT
5#undef DECL_ENUM_ELEMENT_WITH_VAL
7#ifndef GENERATE_ENUM_STRINGS
8 #define DECL_ENUM_ELEMENT( element ) element
9 #define DECL_ENUM_ELEMENT_WITH_VAL( element, val ) element = val
10 #define BEGIN_ENUM( ENUM_NAME ) typedef enum tag##ENUM_NAME
11 #define END_ENUM( ENUM_NAME ) ENUM_NAME; \
12 char* GetString##ENUM_NAME(enum tag##ENUM_NAME index);
14 typedef struct {
char * desc;
int type;} EnumDesc_t;
15 #define DECL_ENUM_ELEMENT( element ) { #element, (int)(element) }
16 #define DECL_ENUM_ELEMENT_WITH_VAL( element, val ) { #element, val }
17 #define BEGIN_ENUM( ENUM_NAME ) EnumDesc_t gs_##ENUM_NAME [] =
18 #define END_ENUM( ENUM_NAME ) ; \
19 char* GetString##ENUM_NAME(enum tag##ENUM_NAME index) \
21 for (i = 0; i < sizeof(gs_##ENUM_NAME)/sizeof(EnumDesc_t); i++) { \
22 if ((int)index == gs_##ENUM_NAME [i].type) return gs_##ENUM_NAME [i].desc; } \
23 return "Unknown Enum type!!"; }