make unknown string a member
This commit is contained in:
parent
1d24fd3732
commit
6201644e60
|
@ -374,7 +374,7 @@ GwXDRFoundMapping GwXDRMappings::getMapping(GwXDRCategory category,int selector,
|
||||||
}
|
}
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
#define MAX_UNKNOWN 200
|
|
||||||
bool GwXDRMappings::addUnknown(GwXDRCategory category,int selector,int field,int instance){
|
bool GwXDRMappings::addUnknown(GwXDRCategory category,int selector,int field,int instance){
|
||||||
if (unknown.size() >= 200) return false;
|
if (unknown.size() >= 200) return false;
|
||||||
unsigned long uk=((int)category) &0x7f;
|
unsigned long uk=((int)category) &0x7f;
|
||||||
|
@ -388,16 +388,14 @@ bool GwXDRMappings::addUnknown(GwXDRCategory category,int selector,int field,int
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * GwXDRMappings::getUnMapped(){
|
const char * GwXDRMappings::getUnMapped(){
|
||||||
const int ESIZE=13;
|
if (unknowAsString == NULL) unknowAsString=new char[(MAX_MAPPINGS+1)*ESIZE];
|
||||||
int sz=(unknown.size()+1)*ESIZE;
|
*unknowAsString=0;
|
||||||
char *rt=new char[sz];
|
char *ptr=unknowAsString;
|
||||||
*rt=0;
|
|
||||||
char *ptr=rt;
|
|
||||||
for (auto it=unknown.begin();it!=unknown.end();it++){
|
for (auto it=unknown.begin();it!=unknown.end();it++){
|
||||||
snprintf(ptr,ESIZE-1,"%lu,",*it);
|
snprintf(ptr,ESIZE-1,"%lu,",*it);
|
||||||
*(ptr+ESIZE-1)=0;
|
*(ptr+ESIZE-1)=0;
|
||||||
while (*ptr != 0) ptr++;
|
while (*ptr != 0) ptr++;
|
||||||
}
|
}
|
||||||
return rt;
|
return unknowAsString;
|
||||||
}
|
}
|
|
@ -164,13 +164,18 @@ class GwXDRFoundMapping{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//the class GwXDRMappings is not intended to be deleted
|
||||||
|
//the deletion will leave memory leaks!
|
||||||
class GwXDRMappings{
|
class GwXDRMappings{
|
||||||
|
static const int MAX_UNKNOWN=200;
|
||||||
|
static const int ESIZE=13;
|
||||||
private:
|
private:
|
||||||
GwLog *logger;
|
GwLog *logger;
|
||||||
GwConfigHandler *config;
|
GwConfigHandler *config;
|
||||||
GwXDRMapping::N138Map n183Map;
|
GwXDRMapping::N138Map n183Map;
|
||||||
GwXDRMapping::N2KMap n2kMap;
|
GwXDRMapping::N2KMap n2kMap;
|
||||||
std::unordered_set<unsigned long> unknown;
|
std::unordered_set<unsigned long> unknown;
|
||||||
|
char *unknowAsString=NULL;
|
||||||
GwXDRFoundMapping selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key);
|
GwXDRFoundMapping selectMapping(GwXDRMapping::MappingList *list,int instance,const char * key);
|
||||||
bool addUnknown(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
bool addUnknown(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
||||||
public:
|
public:
|
||||||
|
@ -180,8 +185,7 @@ class GwXDRMappings{
|
||||||
//the returned mapping will exactly contain one mapping def
|
//the returned mapping will exactly contain one mapping def
|
||||||
GwXDRFoundMapping getMapping(String xName,String xType,String xUnit);
|
GwXDRFoundMapping getMapping(String xName,String xType,String xUnit);
|
||||||
GwXDRFoundMapping getMapping(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
GwXDRFoundMapping getMapping(GwXDRCategory category,int selector,int field=0,int instance=-1);
|
||||||
//returns a newly created buffer - user must destroy!
|
const char * getUnMapped();
|
||||||
char * getUnMapped();
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue