Move switch types lookup to rawswitch and firmware

This commit is contained in:
elecpower
2021-12-31 10:53:10 +01:00
committed by Raphael Coeffic
parent 245d64f521
commit 924942ca0d
5 changed files with 79 additions and 15 deletions
@@ -256,3 +256,29 @@ std::string Firmware::getTrimSwitchesTag(unsigned int index)
return std::string();
}
int Firmware::getRawSwitchTypesIndex(const char * tag)
{
const StringTagMappingTable& lut = rawSwitchTypesLookupTable;
auto it =
find_if(lut.begin(), lut.end(), [=](const StringTagMapping& elmt) {
if (elmt.tag == tag) return true;
return false;
});
if (it != lut.end()) {
return it - lut.begin();
}
return -1;
}
std::string Firmware::getRawSwitchTypesTag(unsigned int index)
{
const StringTagMappingTable& lut = rawSwitchTypesLookupTable;
if (index < lut.size())
return lut[index].tag;
return std::string();
}