1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-24 00:35:14 +03:00

String tag mapping housekeeping

This commit is contained in:
elecpower 2021-12-17 16:46:40 +11:00 committed by Raphael Coeffic
parent 19a9259d96
commit 340b779c8b
5 changed files with 48 additions and 229 deletions

View file

@ -68,3 +68,26 @@ QString DataHelpers::timeToString(const int value, const unsigned int mask)
result.append(QString("%1:%2").arg(minutes, 2, 10, QLatin1Char('0')).arg(seconds, 2, 10, QLatin1Char('0')));
return result;
}
int DataHelpers::getStringTagMappingIndex(const StringTagMappingTable& lut, const char * tag)
{
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 DataHelpers::getStringTagMappingTag(const StringTagMappingTable& lut, unsigned int index)
{
if (index < lut.size())
return lut[index].tag;
return std::string();
}