[wpilib] Preferences: Set Persistent in Init methods (#4025)

Fixes #4018
This commit is contained in:
sciencewhiz
2022-02-12 22:30:02 -08:00
committed by GitHub
parent ac7549edca
commit 165d2837cf
2 changed files with 12 additions and 0 deletions

View File

@@ -87,6 +87,7 @@ void Preferences::PutString(std::string_view key, std::string_view value) {
void Preferences::InitString(std::string_view key, std::string_view value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultString(value);
entry.SetPersistent();
}
void Preferences::SetInt(std::string_view key, int value) {
@@ -102,6 +103,7 @@ void Preferences::PutInt(std::string_view key, int value) {
void Preferences::InitInt(std::string_view key, int value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultDouble(value);
entry.SetPersistent();
}
void Preferences::SetDouble(std::string_view key, double value) {
@@ -117,6 +119,7 @@ void Preferences::PutDouble(std::string_view key, double value) {
void Preferences::InitDouble(std::string_view key, double value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultDouble(value);
entry.SetPersistent();
}
void Preferences::SetFloat(std::string_view key, float value) {
@@ -132,6 +135,7 @@ void Preferences::PutFloat(std::string_view key, float value) {
void Preferences::InitFloat(std::string_view key, float value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultDouble(value);
entry.SetPersistent();
}
void Preferences::SetBoolean(std::string_view key, bool value) {
@@ -147,6 +151,7 @@ void Preferences::PutBoolean(std::string_view key, bool value) {
void Preferences::InitBoolean(std::string_view key, bool value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultBoolean(value);
entry.SetPersistent();
}
void Preferences::SetLong(std::string_view key, int64_t value) {
@@ -162,6 +167,7 @@ void Preferences::PutLong(std::string_view key, int64_t value) {
void Preferences::InitLong(std::string_view key, int64_t value) {
auto entry = ::GetInstance().table->GetEntry(key);
entry.SetDefaultDouble(value);
entry.SetPersistent();
}
bool Preferences::ContainsKey(std::string_view key) {