4#ifdef USE_TEXT_SENSOR_FILTER
33 void input(std::string value);
35 void output(std::string &value);
56 bool new_value(std::string &value)
override;
76 if (result.has_value()) {
77 value = std::move(*result);
90 bool new_value(std::string &value)
override;
96 bool new_value(std::string &value)
override;
103 bool new_value(std::string &value)
override;
113 bool new_value(std::string &value)
override;
127 explicit SubstituteFilter(
const std::initializer_list<Substitution> &substitutions);
128 bool new_value(std::string &value)
override;
160 explicit MapFilter(
const std::initializer_list<Substitution> &mappings);
161 bool new_value(std::string &value)
override;
Fixed-capacity vector - allocates once at runtime, never reallocates This avoids std::vector template...
A simple filter that adds a string to the end of another string.
bool new_value(std::string &value) override
AppendFilter(const char *suffix)
Apply a filter to text sensor values such as to_upper.
virtual bool new_value(std::string &value)=0
This will be called every time the filter receives a new value.
void output(std::string &value)
void input(std::string value)
virtual void initialize(TextSensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
This class allows for creation of simple template filters.
lambda_filter_t lambda_filter_
LambdaFilter(lambda_filter_t lambda_filter)
void set_lambda_filter(const lambda_filter_t &lambda_filter)
bool new_value(std::string &value) override
const lambda_filter_t & get_lambda_filter() const
A filter that maps values from one set to another.
bool new_value(std::string &value) override
MapFilter(const std::initializer_list< Substitution > &mappings)
FixedVector< Substitution > mappings_
A simple filter that adds a string to the start of another string.
bool new_value(std::string &value) override
PrependFilter(const char *prefix)
Optimized lambda filter for stateless lambdas (no capture).
optional< std::string >(* lambda_filter_)(std::string)
StatelessLambdaFilter(optional< std::string >(*lambda_filter)(std::string))
bool new_value(std::string &value) override
A simple filter that replaces a substring with another substring.
FixedVector< Substitution > substitutions_
bool new_value(std::string &value) override
SubstituteFilter(const std::initializer_list< Substitution > &substitutions)
A simple filter that converts all text to lowercase.
bool new_value(std::string &value) override
A simple filter that converts all text to uppercase.
bool new_value(std::string &value) override
std::function< optional< std::string >(std::string)> lambda_filter_t