You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
668 B
27 lines
668 B
3 weeks ago
|
#ifndef SETTINGS_H
|
||
|
#define SETTINGS_H
|
||
|
|
||
|
#include <string>
|
||
|
#include <nvs_flash.h>
|
||
|
|
||
|
class Settings {
|
||
|
public:
|
||
|
Settings(const std::string& ns, bool read_write = false);
|
||
|
~Settings();
|
||
|
|
||
|
std::string GetString(const std::string& key, const std::string& default_value = "");
|
||
|
void SetString(const std::string& key, const std::string& value);
|
||
|
int32_t GetInt(const std::string& key, int32_t default_value = 0);
|
||
|
void SetInt(const std::string& key, int32_t value);
|
||
|
void EraseKey(const std::string& key);
|
||
|
void EraseAll();
|
||
|
|
||
|
private:
|
||
|
std::string ns_;
|
||
|
nvs_handle_t nvs_handle_ = 0;
|
||
|
bool read_write_ = false;
|
||
|
bool dirty_ = false;
|
||
|
};
|
||
|
|
||
|
#endif
|