mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
[wpilib] Preferences: Deprecate Put* in favor of Set* (#3337)
This naming is more consistent with other APIs. Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
@@ -49,67 +49,91 @@ int64_t Preferences::GetLong(wpi::StringRef key, int64_t defaultValue) {
|
||||
return static_cast<int64_t>(m_table->GetNumber(key, defaultValue));
|
||||
}
|
||||
|
||||
void Preferences::PutString(wpi::StringRef key, wpi::StringRef value) {
|
||||
void Preferences::SetString(wpi::StringRef key, wpi::StringRef value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetString(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutString(wpi::StringRef key, wpi::StringRef value) {
|
||||
SetString(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitString(wpi::StringRef key, wpi::StringRef value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultString(value);
|
||||
}
|
||||
|
||||
void Preferences::PutInt(wpi::StringRef key, int value) {
|
||||
void Preferences::SetInt(wpi::StringRef key, int value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDouble(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutInt(wpi::StringRef key, int value) {
|
||||
SetInt(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitInt(wpi::StringRef key, int value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
}
|
||||
|
||||
void Preferences::PutDouble(wpi::StringRef key, double value) {
|
||||
void Preferences::SetDouble(wpi::StringRef key, double value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDouble(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutDouble(wpi::StringRef key, double value) {
|
||||
SetDouble(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitDouble(wpi::StringRef key, double value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
}
|
||||
|
||||
void Preferences::PutFloat(wpi::StringRef key, float value) {
|
||||
void Preferences::SetFloat(wpi::StringRef key, float value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDouble(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutFloat(wpi::StringRef key, float value) {
|
||||
SetFloat(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitFloat(wpi::StringRef key, float value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
}
|
||||
|
||||
void Preferences::PutBoolean(wpi::StringRef key, bool value) {
|
||||
void Preferences::SetBoolean(wpi::StringRef key, bool value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetBoolean(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutBoolean(wpi::StringRef key, bool value) {
|
||||
SetBoolean(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitBoolean(wpi::StringRef key, bool value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultBoolean(value);
|
||||
}
|
||||
|
||||
void Preferences::PutLong(wpi::StringRef key, int64_t value) {
|
||||
void Preferences::SetLong(wpi::StringRef key, int64_t value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDouble(value);
|
||||
entry.SetPersistent();
|
||||
}
|
||||
|
||||
void Preferences::PutLong(wpi::StringRef key, int64_t value) {
|
||||
SetLong(key, value);
|
||||
}
|
||||
|
||||
void Preferences::InitLong(wpi::StringRef key, int64_t value) {
|
||||
auto entry = m_table->GetEntry(key);
|
||||
entry.SetDefaultDouble(value);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
#include <wpi/deprecated.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -114,6 +115,18 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetString(wpi::StringRef key, wpi::StringRef value);
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table.
|
||||
*
|
||||
* The value may not have quotation marks, nor may the key have any whitespace
|
||||
* nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetString instead.")
|
||||
void PutString(wpi::StringRef key, wpi::StringRef value);
|
||||
|
||||
/**
|
||||
@@ -130,6 +143,17 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetInt(wpi::StringRef key, int value);
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table.
|
||||
*
|
||||
* The key may not have any whitespace nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetInt instead.")
|
||||
void PutInt(wpi::StringRef key, int value);
|
||||
|
||||
/**
|
||||
@@ -146,6 +170,17 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetDouble(wpi::StringRef key, double value);
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table.
|
||||
*
|
||||
* The key may not have any whitespace nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetDouble instead.")
|
||||
void PutDouble(wpi::StringRef key, double value);
|
||||
|
||||
/**
|
||||
@@ -162,6 +197,17 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetFloat(wpi::StringRef key, float value);
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table.
|
||||
*
|
||||
* The key may not have any whitespace nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetFloat instead.")
|
||||
void PutFloat(wpi::StringRef key, float value);
|
||||
|
||||
/**
|
||||
@@ -178,6 +224,17 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetBoolean(wpi::StringRef key, bool value);
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table.
|
||||
*
|
||||
* The key may not have any whitespace nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetBoolean instead.")
|
||||
void PutBoolean(wpi::StringRef key, bool value);
|
||||
|
||||
/**
|
||||
@@ -194,6 +251,17 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetLong(wpi::StringRef key, int64_t value);
|
||||
|
||||
/**
|
||||
* Puts the given long (int64_t) into the preferences table.
|
||||
*
|
||||
* The key may not have any whitespace nor an equals sign.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetLong instead.")
|
||||
void PutLong(wpi::StringRef key, int64_t value);
|
||||
|
||||
/**
|
||||
|
||||
@@ -75,14 +75,27 @@ public final class Preferences {
|
||||
* @param value the value
|
||||
* @throws NullPointerException if value is null
|
||||
*/
|
||||
public void putString(String key, String value) {
|
||||
requireNonNullParam(value, "value", "putString");
|
||||
public void setString(String key, String value) {
|
||||
requireNonNullParam(value, "value", "setString");
|
||||
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setString(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @throws NullPointerException if value is null
|
||||
* @deprecated Use {@link #setString(String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putString(String key, String value) {
|
||||
setString(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table if it doesn't already exist.
|
||||
*
|
||||
@@ -100,12 +113,24 @@ public final class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void putInt(String key, int value) {
|
||||
public void setInt(String key, int value) {
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setDouble(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @deprecated Use {@link #setInt(String, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putInt(String key, int value) {
|
||||
setInt(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table if it doesn't already exist.
|
||||
*
|
||||
@@ -123,12 +148,23 @@ public final class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void putDouble(String key, double value) {
|
||||
public void setDouble(String key, double value) {
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setDouble(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @deprecated Use {@link #setDouble(String, double)}
|
||||
*/
|
||||
public void putDouble(String key, double value) {
|
||||
setDouble(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table if it doesn't already exist.
|
||||
*
|
||||
@@ -146,12 +182,24 @@ public final class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void putFloat(String key, float value) {
|
||||
public void setFloat(String key, float value) {
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setDouble(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @deprecated Use {@link #setFloat(String, float)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putFloat(String key, float value) {
|
||||
setFloat(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table if it doesn't already exist.
|
||||
*
|
||||
@@ -169,12 +217,24 @@ public final class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void putBoolean(String key, boolean value) {
|
||||
public void setBoolean(String key, boolean value) {
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setBoolean(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @deprecated Use {@link #setBoolean(String, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putBoolean(String key, boolean value) {
|
||||
setBoolean(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table if it doesn't already exist.
|
||||
*
|
||||
@@ -192,12 +252,24 @@ public final class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void putLong(String key, long value) {
|
||||
public void setLong(String key, long value) {
|
||||
NetworkTableEntry entry = m_table.getEntry(key);
|
||||
entry.setDouble(value);
|
||||
entry.setPersistent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given long into the preferences table.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @deprecated Use {@link #setLong(String, long)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void putLong(String key, long value) {
|
||||
setLong(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the given long into the preferences table if it doesn't already exist.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user