OOKwiz
on/off-keying for ESP32 and a variety of supported radio modules
Public Member Functions | Static Public Member Functions | List of all members
Settings Class Reference

#include <Settings.h>

Public Member Functions

 Settings ()
 

Static Public Member Functions

static bool set (const String &name, const String &value="")
 Set a value. More...
 
template<typename T >
static bool set (const String &name, const T &value="")
 
static bool unset (const String &name)
 Removes key with given name from memory. More...
 
static bool get (const String &name, String &value)
 Get a value from memory as String. More...
 
static bool get (const String &name, float &value)
 Get a value from memory as float. More...
 
static bool get (const String &name, int &value)
 Get a value from memory as int. More...
 
static bool get (const String &name, long &value)
 Get a value from memory as long. More...
 
static String getString (const String &name, const String dflt="")
 Get a value from memory as String with default. More...
 
static int getInt (const String &name, const long dflt=-1)
 Get a value from memory as int with default. More...
 
static long getLong (const String &name, const long dflt=-1)
 Get a value from memory as long with default. More...
 
static float getFloat (const String &name, const float dflt=-1)
 Get a value from memory as float with default. More...
 
static bool validName (const String &name)
 true if name is a valid name for a setting. More...
 
static String list ()
 List of values in memory. More...
 
static bool fromList (String in)
 Stores all settings from a String into memory. More...
 
static bool save (const String filename)
 Save settings to file in SPIFFS. More...
 
static bool load (const String filename)
 Load settings from file in SPIFFS. More...
 
static bool ls ()
 Shows all files in the location SPIFFS_PREFIX in SPIFFS. More...
 
static bool rm (const String filename)
 Deletes file from SPIFFS. More...
 
static bool fileExists (String filename)
 See if given file exists in SPIFFS. More...
 
static void zap ()
 Deletes all settings from memory. More...
 
static bool isSet (const String &name)
 Find out if a key with given name exists in memory. More...
 

Detailed Description

Definition at line 31 of file Settings.h.

Constructor & Destructor Documentation

◆ Settings()

Settings::Settings ( )

Definition at line 11 of file Settings.cpp.

Member Function Documentation

◆ set() [1/2]

bool Settings::set ( const String &  name,
const String &  value = "" 
)
static

Set a value.

Parameters
namename of the key to be set
valuevalue to be set as an Arduino String
Returns

Definition at line 188 of file Settings.cpp.

◆ set() [2/2]

template<typename T >
static bool Settings::set ( const String &  name,
const T &  value = "" 
)
inlinestatic

Definition at line 38 of file Settings.h.

◆ unset()

bool Settings::unset ( const String &  name)
static

Removes key with given name from memory.

Parameters
namename of key
Returns
true if removed, false if name not valid or key not set.

Definition at line 199 of file Settings.cpp.

◆ get() [1/4]

bool Settings::get ( const String &  name,
String &  value 
)
static

Get a value from memory as String.

Parameters
namename of the key
valueString variable that will hold the value on return
Returns
true if value found, false if not

Definition at line 211 of file Settings.cpp.

◆ get() [2/4]

bool Settings::get ( const String &  name,
float &  value 
)
static

Get a value from memory as float.

Parameters
namename of the key
valuefloat variable that will hold the value on return
Returns
true if value found, false if not

Definition at line 223 of file Settings.cpp.

◆ get() [3/4]

bool Settings::get ( const String &  name,
int &  value 
)
static

Get a value from memory as int.

Parameters
namename of the key
valueint variable that will hold the value on return
Returns
true if value found, false if not

Definition at line 237 of file Settings.cpp.

◆ get() [4/4]

bool Settings::get ( const String &  name,
long &  value 
)
static

Get a value from memory as long.

Parameters
namename of the key
valuelong variable that will hold the value on return
Returns
true if value found, false if not

Definition at line 251 of file Settings.cpp.

◆ getString()

String Settings::getString ( const String &  name,
const String  dflt = "" 
)
static

Get a value from memory as String with default.

Parameters
namename of the key
dflt[optional] Default returned if key not found in memory or "" if no default specified.
Returns
String with value found, or default

Definition at line 265 of file Settings.cpp.

◆ getInt()

int Settings::getInt ( const String &  name,
const long  dflt = -1 
)
static

Get a value from memory as int with default.

Parameters
namename of the key
dflt[optional] Default returned if key not found in memory or -1 if no default specified.
Returns
int with value found, or default

Definition at line 276 of file Settings.cpp.

◆ getLong()

long Settings::getLong ( const String &  name,
const long  dflt = -1 
)
static

Get a value from memory as long with default.

Parameters
namename of the key
dflt[optional] Default returned if key not found in memory or -1 if no default specified.
Returns
long with value found, or default

Definition at line 287 of file Settings.cpp.

◆ getFloat()

float Settings::getFloat ( const String &  name,
const float  dflt = -1 
)
static

Get a value from memory as float with default.

Parameters
namename of the key
dflt[optional] Default returned if key not found in memory or -1 if no default specified.
Returns
float with value found, or default

Definition at line 298 of file Settings.cpp.

◆ validName()

bool Settings::validName ( const String &  name)
static

true if name is a valid name for a setting.

Definition at line 143 of file Settings.cpp.

◆ list()

String Settings::list ( )
static

List of values in memory.

Returns
String with name=value<lf>name=value<lf>...

Definition at line 159 of file Settings.cpp.

◆ fromList()

bool Settings::fromList ( String  in)
static

Stores all settings from a String into memory.

Parameters
inString that contains name=value<lf>name=value<lf>...
Returns
true if it worked, displays error and returns false if not.

Definition at line 122 of file Settings.cpp.

◆ save()

bool Settings::save ( const String  filename)
static

Save settings to file in SPIFFS.

Parameters
filenameThe actual filename in SPIFFS will have SPIFFS_PREFIX from config.h preprended
Returns
true if it worked, displays error and returns false if not.

Definition at line 18 of file Settings.cpp.

◆ load()

bool Settings::load ( const String  filename)
static

Load settings from file in SPIFFS.

Parameters
filenameThe actual filename in SPIFFS will have SPIFFS_PREFIX from config.h preprended
Returns
true if it worked, displays error and returns false if not.

Definition at line 44 of file Settings.cpp.

◆ ls()

bool Settings::ls ( )
static

Shows all files in the location SPIFFS_PREFIX in SPIFFS.

Returns
true if it worked, displays error and returns false if not.

Definition at line 68 of file Settings.cpp.

◆ rm()

bool Settings::rm ( const String  filename)
static

Deletes file from SPIFFS.

Parameters
filenameThe actual filename in SPIFFS will have SPIFFS_PREFIX from config.h preprended
Returns
true if it worked, displays error and returns false if not.

Definition at line 85 of file Settings.cpp.

◆ fileExists()

bool Settings::fileExists ( String  filename)
static

See if given file exists in SPIFFS.

Parameters
filenameThe actual filename in SPIFFS will have SPIFFS_PREFIX from config.h preprended
Returns
true if file exists, false if not.

Definition at line 102 of file Settings.cpp.

◆ zap()

void Settings::zap ( )
static

Deletes all settings from memory.

Definition at line 115 of file Settings.cpp.

◆ isSet()

bool Settings::isSet ( const String &  name)
static

Find out if a key with given name exists in memory.

Parameters
nameSetting name
Returns
true if that name is set

Definition at line 180 of file Settings.cpp.


The documentation for this class was generated from the following files: