Skip to content

Commit 67acaac

Browse files
committed
Update name method to support new type codes
1 parent a9c8f35 commit 67acaac

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/Flux/flxCore.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,35 @@
1212

1313
#include "flxCore.h"
1414

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+
};
1832

1933
//-------------------------------------------------------------------------
2034
// flxTypeName()
2135
//
2236
// Return a human type give the framework type
2337
const char *flxGetTypeName(flxDataType_t type)
2438
{
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+
}
2744

2845
return "Invalid Type";
2946
}

0 commit comments

Comments
 (0)