refactor(cpn): Support JSON radio hardware definitions (#4406)
This commit is contained in:
@@ -92,19 +92,11 @@ std::string DataHelpers::getStringTagMappingTag(const StringTagMappingTable& lut
|
||||
return std::string();
|
||||
}
|
||||
|
||||
int DataHelpers::getStringTagMappingSeq(const StringTagMappingTable& lut, unsigned int index)
|
||||
std::string DataHelpers::getStringNameMappingTag(const StringTagMappingTable& lut, const char * name)
|
||||
{
|
||||
if (index < lut.size())
|
||||
return lut[index].seq;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::string DataHelpers::getStringSeqMappingTag(const StringTagMappingTable& lut, unsigned int seq)
|
||||
{
|
||||
const auto it =
|
||||
auto it =
|
||||
find_if(lut.begin(), lut.end(), [=](const StringTagMapping& elmt) {
|
||||
if (elmt.seq == seq) return true;
|
||||
if (elmt.name == name) return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -114,3 +106,34 @@ std::string DataHelpers::getStringSeqMappingTag(const StringTagMappingTable& lut
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string DataHelpers::getStringTagMappingName(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->name;
|
||||
}
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
QString DataHelpers::getCompositeName(const QString defaultName, const QString customName, const bool prefixCustom)
|
||||
{
|
||||
QString result;
|
||||
|
||||
if (customName.trimmed().isEmpty() || prefixCustom)
|
||||
result = defaultName;
|
||||
|
||||
if (!customName.trimmed().isEmpty()) {
|
||||
if (prefixCustom)
|
||||
result.append(":");
|
||||
result.append(customName.trimmed());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user