|
12 | 12 |
|
13 | 13 | #include "flxCore.h"
|
14 | 14 |
|
15 |
| -static const char *typeNames[] = {"none", "bool", "int8", "int16", |
16 |
| - "integer", "unsigned int8", "unsigned int16", "unsigned integer", |
17 |
| - "float", "double", "string"}; |
| 15 | +static const struct |
| 16 | +{ |
| 17 | + flxDataType_t type; |
| 18 | + const char *name; |
| 19 | +} typeNames[] = { |
| 20 | + {flxTypeNone, "none"}, |
| 21 | + {flxTypeBool, "bool"}, |
| 22 | + {flxTypeInt8, "int8"}, |
| 23 | + {flxTypeInt16, "int16"}, |
| 24 | + {flxTypeInt32, "int32"}, |
| 25 | + {flxTypeUInt8, "unsigned int8"}, |
| 26 | + {flxTypeUInt16, "unsigned int16"}, |
| 27 | + {flxTypeUInt32, "unsigned int32"}, |
| 28 | + {flxTypeFloat, "float"}, |
| 29 | + {flxTypeDouble, "double"}, |
| 30 | + {flxTypeString, "string"}, |
| 31 | +}; |
18 | 32 |
|
19 | 33 | //-------------------------------------------------------------------------
|
20 | 34 | // flxTypeName()
|
21 | 35 | //
|
22 | 36 | // Return a human type give the framework type
|
23 | 37 | const char *flxGetTypeName(flxDataType_t type)
|
24 | 38 | {
|
25 |
| - if (type < sizeof(typeNames)) |
26 |
| - return typeNames[type]; |
| 39 | + for (size_t i = 0; i < sizeof(typeNames) / sizeof(typeNames[0]); i++) |
| 40 | + { |
| 41 | + if (typeNames[i].type == type) |
| 42 | + return typeNames[i].name; |
| 43 | + } |
27 | 44 |
|
28 | 45 | return "Invalid Type";
|
29 | 46 | }
|
0 commit comments