10namespace fs = std::filesystem;
12static const char *
const TAG =
"host.preferences";
24 FILE *fp = fopen(this->
filename_.c_str(),
"rb");
29 if (fread(&key,
sizeof(key), 1, fp) != 1)
31 if (fread(&
len,
sizeof(
len), 1, fp) != 1)
34 if (fread(
data,
sizeof(uint8_t),
len, fp) !=
len)
37 this->data[key] = vec;
46 FILE *fp = fopen(this->
filename_.c_str(),
"wb");
47 std::map<uint32_t, std::vector<uint8_t>>::iterator it;
49 for (it = this->
data.begin(); it != this->data.end(); ++it) {
50 fwrite(&it->first,
sizeof(uint32_t), 1, fp);
51 uint8_t
len = it->second.size();
52 fwrite(&
len,
sizeof(
len), 1, fp);
53 fwrite(it->second.data(),
sizeof(uint8_t), it->second.size(), fp);
const std::string & get_name() const
Get the name of this Application set by pre_setup().
bool save(const uint8_t *data, size_t len) override
bool load(uint8_t *data, size_t len) override
bool load(uint32_t key, uint8_t *data, size_t len)
bool save(uint32_t key, const uint8_t *data, size_t len)
std::map< uint32_t, std::vector< uint8_t > > data
ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash) override
HostPreferences * host_preferences
Providing packet encoding functions for exchanging data with a remote host.
ESPPreferences * global_preferences
Application App
Global storage of Application pointer - only one Application can exist.