Use new settings API in recon and scanner (#1394)

* Use new settings in recon
* Trim on string value read, remove dupe entry
* Check update_range flag when setting values
* Add a few saved settings to scanner
* Add copywrite note
This commit is contained in:
Kyle Reed 2023-08-20 13:28:02 -07:00 committed by GitHub
parent c6424f1623
commit 564f76b47d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 128 deletions

View file

@ -2,6 +2,7 @@
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2016 Furrtek
* Copyright (C) 2022 Arjan Onwezen
* Copyright (C) 2023 Kyle Reed
*
* This file is part of PortaPack.
*
@ -58,7 +59,7 @@ void BoundSetting::parse(std::string_view value) {
parse_int(value, as<uint8_t>());
break;
case SettingType::String:
as<std::string>() = std::string{value};
as<std::string>() = trim(value);
break;
case SettingType::Bool: {
int parsed = 0;
@ -106,10 +107,18 @@ void BoundSetting::write(File& file) const {
SettingsStore::SettingsStore(std::string_view store_name, SettingBindings bindings)
: store_name_{store_name}, bindings_{bindings} {
load_settings(store_name_, bindings_);
reload();
}
SettingsStore::~SettingsStore() {
save();
}
void SettingsStore::reload() {
load_settings(store_name_, bindings_);
}
void SettingsStore::save() const {
save_settings(store_name_, bindings_);
}