simplify xdr type mapping

This commit is contained in:
andreas 2023-10-24 16:19:00 +02:00
parent 0e10fcfee2
commit 4b3c6f13b4
1 changed files with 7 additions and 8 deletions

View File

@ -55,20 +55,19 @@ GwXDRType *types[] = {
new GwXDRType(GwXDRType::GENERIC, "G", ""), new GwXDRType(GwXDRType::GENERIC, "G", ""),
new GwXDRType(GwXDRType::DISPLACEMENT, "A", "P"), new GwXDRType(GwXDRType::DISPLACEMENT, "A", "P"),
new GwXDRType(GwXDRType::DISPLACEMENTD, "A", "D",DegToRad,RadToDeg,"rd"), new GwXDRType(GwXDRType::DISPLACEMENTD, "A", "D",DegToRad,RadToDeg,"rd"),
new GwXDRType(GwXDRType::RPM,"T","R"), new GwXDRType(GwXDRType::RPM,"T","R")
//important to have 2x NULL! };
NULL, template<typename T, int size>
NULL}; int GetArrLength(T(&)[size]){return size;}
static GwXDRType *findType(GwXDRType::TypeCode type, int *start = NULL) static GwXDRType *findType(GwXDRType::TypeCode type, int *start = NULL)
{ {
int len=GetArrLength(types);
int from = 0; int from = 0;
if (start != NULL) if (start != NULL)
from = *start; from = *start;
if (types[from] == NULL) if (from < 0 || from >= len) return NULL;
return NULL;
int i = from; int i = from;
for (; types[i] != NULL; i++) for (; i< len; i++)
{ {
if (types[i]->code == type) if (types[i]->code == type)
{ {