mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
Use std::string_view and fmtlib across all libraries (#3402)
- Twine, StringRef, Format, and NativeFormatting have been removed - Logging now uses fmtlib style formatting - Nearly all uses of wpi::outs/errs have been replaced with fmt::print() or std::puts()/std::fputs() (for unformatted strings). - A wpi/fmt/raw_ostream.h header has been added to enable fmt::print() with wpi::raw_ostream
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <networktables/NetworkTable.h>
|
||||
@@ -53,7 +54,8 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
std::string GetString(wpi::StringRef key, wpi::StringRef defaultValue = "");
|
||||
std::string GetString(std::string_view key,
|
||||
std::string_view defaultValue = "");
|
||||
|
||||
/**
|
||||
* Returns the int at the given key. If this table does not have a value for
|
||||
@@ -63,7 +65,7 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
int GetInt(wpi::StringRef key, int defaultValue = 0);
|
||||
int GetInt(std::string_view key, int defaultValue = 0);
|
||||
|
||||
/**
|
||||
* Returns the double at the given key. If this table does not have a value
|
||||
@@ -73,7 +75,7 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
double GetDouble(wpi::StringRef key, double defaultValue = 0.0);
|
||||
double GetDouble(std::string_view key, double defaultValue = 0.0);
|
||||
|
||||
/**
|
||||
* Returns the float at the given key. If this table does not have a value
|
||||
@@ -83,7 +85,7 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
float GetFloat(wpi::StringRef key, float defaultValue = 0.0);
|
||||
float GetFloat(std::string_view key, float defaultValue = 0.0);
|
||||
|
||||
/**
|
||||
* Returns the boolean at the given key. If this table does not have a value
|
||||
@@ -93,7 +95,7 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
bool GetBoolean(wpi::StringRef key, bool defaultValue = false);
|
||||
bool GetBoolean(std::string_view key, bool defaultValue = false);
|
||||
|
||||
/**
|
||||
* Returns the long (int64_t) at the given key. If this table does not have a
|
||||
@@ -104,7 +106,7 @@ class Preferences {
|
||||
* @param defaultValue the value to return if none exists in the table
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
int64_t GetLong(wpi::StringRef key, int64_t defaultValue = 0);
|
||||
int64_t GetLong(std::string_view key, int64_t defaultValue = 0);
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table.
|
||||
@@ -115,7 +117,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetString(wpi::StringRef key, wpi::StringRef value);
|
||||
void SetString(std::string_view key, std::string_view value);
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table.
|
||||
@@ -127,13 +129,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetString instead.")
|
||||
void PutString(wpi::StringRef key, wpi::StringRef value);
|
||||
void PutString(std::string_view key, std::string_view value);
|
||||
|
||||
/**
|
||||
* Puts the given string into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitString(wpi::StringRef key, wpi::StringRef value);
|
||||
void InitString(std::string_view key, std::string_view value);
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table.
|
||||
@@ -143,7 +145,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetInt(wpi::StringRef key, int value);
|
||||
void SetInt(std::string_view key, int value);
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table.
|
||||
@@ -154,13 +156,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetInt instead.")
|
||||
void PutInt(wpi::StringRef key, int value);
|
||||
void PutInt(std::string_view key, int value);
|
||||
|
||||
/**
|
||||
* Puts the given int into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitInt(wpi::StringRef key, int value);
|
||||
void InitInt(std::string_view key, int value);
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table.
|
||||
@@ -170,7 +172,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetDouble(wpi::StringRef key, double value);
|
||||
void SetDouble(std::string_view key, double value);
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table.
|
||||
@@ -181,13 +183,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetDouble instead.")
|
||||
void PutDouble(wpi::StringRef key, double value);
|
||||
void PutDouble(std::string_view key, double value);
|
||||
|
||||
/**
|
||||
* Puts the given double into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitDouble(wpi::StringRef key, double value);
|
||||
void InitDouble(std::string_view key, double value);
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table.
|
||||
@@ -197,7 +199,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetFloat(wpi::StringRef key, float value);
|
||||
void SetFloat(std::string_view key, float value);
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table.
|
||||
@@ -208,13 +210,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetFloat instead.")
|
||||
void PutFloat(wpi::StringRef key, float value);
|
||||
void PutFloat(std::string_view key, float value);
|
||||
|
||||
/**
|
||||
* Puts the given float into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitFloat(wpi::StringRef key, float value);
|
||||
void InitFloat(std::string_view key, float value);
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table.
|
||||
@@ -224,7 +226,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetBoolean(wpi::StringRef key, bool value);
|
||||
void SetBoolean(std::string_view key, bool value);
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table.
|
||||
@@ -235,13 +237,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetBoolean instead.")
|
||||
void PutBoolean(wpi::StringRef key, bool value);
|
||||
void PutBoolean(std::string_view key, bool value);
|
||||
|
||||
/**
|
||||
* Puts the given boolean into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitBoolean(wpi::StringRef key, bool value);
|
||||
void InitBoolean(std::string_view key, bool value);
|
||||
|
||||
/**
|
||||
* Puts the given long (int64_t) into the preferences table.
|
||||
@@ -251,7 +253,7 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
void SetLong(wpi::StringRef key, int64_t value);
|
||||
void SetLong(std::string_view key, int64_t value);
|
||||
|
||||
/**
|
||||
* Puts the given long (int64_t) into the preferences table.
|
||||
@@ -262,13 +264,13 @@ class Preferences {
|
||||
* @param value the value
|
||||
*/
|
||||
WPI_DEPRECATED("Use SetLong instead.")
|
||||
void PutLong(wpi::StringRef key, int64_t value);
|
||||
void PutLong(std::string_view key, int64_t value);
|
||||
|
||||
/**
|
||||
* Puts the given long into the preferences table if it doesn't
|
||||
* already exist.
|
||||
*/
|
||||
void InitLong(wpi::StringRef key, int64_t value);
|
||||
void InitLong(std::string_view key, int64_t value);
|
||||
|
||||
/**
|
||||
* Returns whether or not there is a key with the given name.
|
||||
@@ -276,14 +278,14 @@ class Preferences {
|
||||
* @param key the key
|
||||
* @return if there is a value at the given key
|
||||
*/
|
||||
bool ContainsKey(wpi::StringRef key);
|
||||
bool ContainsKey(std::string_view key);
|
||||
|
||||
/**
|
||||
* Remove a preference.
|
||||
*
|
||||
* @param key the key
|
||||
*/
|
||||
void Remove(wpi::StringRef key);
|
||||
void Remove(std::string_view key);
|
||||
|
||||
/**
|
||||
* Remove all preferences.
|
||||
|
||||
Reference in New Issue
Block a user