bool LX16xxConfigWidget::SaveUnsignedSetting(LX1600::Setting key, unsigned idx, LX1600::SettingsMap &settings) { const std::string old_value = device.GetLX16xxSetting(key); unsigned value = ParseUnsigned(old_value.c_str()); if (!SaveValue(idx, value)) return false; NarrowString<32> buffer; buffer.UnsafeFormat("%u", value); settings[key] = std::string(buffer.c_str(), buffer.end()); return true; }
bool LX16xxConfigWidget::SaveFixedEnumSetting(LX1600::Setting key, unsigned idx, LX1600::SettingsMap &settings, unsigned factor) { const std::string old_value = device.GetLX16xxSetting(key); unsigned value = unsigned(ParseDouble(old_value.c_str()) * factor); if (!SaveValue(idx, value)) return false; NarrowString<32> buffer; buffer.UnsafeFormat("%.2f", (double)value / factor); settings[key] = std::string(buffer.c_str(), buffer.end()); return true; }
NarrowString toUpper (const NarrowString & nstr) { NarrowString retval (nstr); std::transform (retval.begin (), retval.end (), retval.begin (), trueUpper); return retval; }
NarrowString toLower (const NarrowString & nstr) { NarrowString retval (nstr.c_str()); std::transform (retval.begin (), retval.end (), retval.begin (), trueLower); return retval; }