15 virtual bool save(
const std::string &value) {
return true; }
17 virtual void setup(uint32_t
id, std::string &value) {}
26 bool save(
const std::string &value)
override {
27 int diff = value.compare(this->
prev_);
31 int size = value.size();
34 unsigned char temp[SZ + 1];
35 memcpy(temp + 1, value.c_str(), size);
37 temp[0] = ((
unsigned char) size);
39 this->
prev_.assign(value);
26 bool save(
const std::string &value)
override {
…}
48 void setup(uint32_t
id, std::string &value)
override {
55 value.assign(temp + 1, (
size_t) temp[0]);
58 this->
prev_.assign(value);
48 void setup(uint32_t
id, std::string &value)
override {
…}
66 void setup()
override;
77 void control(
const std::string &value)
override;
virtual ESPPreferenceObject make_preference(size_t length, uint32_t type, bool in_flash)=0
This class simplifies creating components that periodically check a state.
void set_optimistic(bool optimistic)
void set_template(std::function< optional< std::string >()> &&f)
std::string initial_value_
void set_value_saver(TemplateTextSaverBase *restore_value_saver)
Trigger< std::string > * get_set_trigger() const
void dump_config() override
void set_initial_value(const std::string &initial_value)
TemplateTextSaverBase * pref_
optional< std::function< optional< std::string >()> > f_
Trigger< std::string > * set_trigger_
void control(const std::string &value) override
float get_setup_priority() const override
virtual bool save(const std::string &value)
virtual void setup(uint32_t id, std::string &value)
ESPPreferenceObject pref_
void setup(uint32_t id, std::string &value) override
bool save(const std::string &value) override
Base-class for all text inputs.
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Providing packet encoding functions for exchanging data with a remote host.
ESPPreferences * global_preferences
T id(T value)
Helper function to make id(var) known from lambdas work in custom components.