This commit is contained in:
Robin Davies
2023-04-16 01:13:03 -04:00
parent d05c7c7104
commit 845af2ee47
93 changed files with 3987 additions and 1688 deletions
+45 -10
View File
@@ -36,32 +36,46 @@ Units UriToUnits(const std::string &uri);
std::map<Units,std::string> unitsToStringMap =
{
//LV2_UNITS__conversion
//LV2_UNITS__name
CASE(none)
CASE(unknown)
CASE(bar)
CASE(beat)
CASE(bpm)
CASE(cent)
CASE(cm)
CASE(coef)
CASE(db)
CASE(degree)
CASE(frame)
CASE(hz)
CASE(inch)
CASE(khz)
CASE(km)
CASE(m)
CASE(mhz)
CASE(midiNote)
CASE(mile)
CASE(min)
CASE(mm)
CASE(ms)
CASE(pc)
CASE(oct)
CASE(s)
CASE(pc)
CASE(semitone12TET)
};
static const std::string emptyString;
const std::string& pipedal::UnitsToString(Units units)
{
return unitsToStringMap[units];
if (unitsToStringMap.find(units) != unitsToStringMap.end())
{
return unitsToStringMap[units];
} else {
return emptyString;
}
}
#undef CASE
@@ -76,17 +90,24 @@ std::map<std::string,Units> unitMap = {
CASE(bpm)
CASE(cent)
CASE(cm)
CASE(coef)
CASE(db)
CASE(degree)
CASE(frame)
CASE(hz)
CASE(inch)
CASE(khz)
CASE(km)
CASE(m)
CASE(mhz)
CASE(midiNote)
CASE(mile)
CASE(min)
CASE(mm)
CASE(ms)
CASE(pc)
CASE(oct)
CASE(s)
CASE(pc)
CASE(semitone12TET)
};
#undef CASE
@@ -97,38 +118,52 @@ std::map<std::string,Units> unitMap = {
std::map<std::string,Units> uriToUnitsMap = {
{ "", Units::none,},
CASE(bar)
CASE(beat)
CASE(bpm)
CASE(cent)
CASE(cm)
CASE(coef)
CASE(db)
CASE(degree)
CASE(frame)
CASE(hz)
CASE(inch)
CASE(khz)
CASE(km)
CASE(m)
CASE(mhz)
CASE(midiNote)
CASE(mile)
CASE(min)
CASE(mm)
CASE(ms)
CASE(pc)
CASE(oct)
CASE(s)
CASE(pc)
CASE(semitone12TET)
};
#undef CASE
Units pipedal::StringToUnits(const std::string &text)
{
return unitMap[text];
if (unitMap.find(text) != unitMap.end()) {
return unitMap[text];
}
return Units::none;
}
Units pipedal::UriToUnits(const std::string &text)
{
if (text.length() == 0) return Units::none;
auto result = uriToUnitsMap[text];
if (result == Units::none) return Units::unknown;
return result;
if (uriToUnitsMap.contains(text))
{
auto result = uriToUnitsMap[text];
return result;
}
return Units::unknown;
}