78 for (
size_t i = 0; i < count; i++) {
79 const size_t from_len = strlen(substitutions[i].from);
80 const size_t to_len = strlen(substitutions[i].to);
82 while ((
pos = value.find(substitutions[i].
from,
pos, from_len)) != std::string::npos) {
83 value.replace(
pos, from_len, substitutions[i].to, to_len);
bool new_value(std::string &value) override
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.
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
bool new_value(std::string &value) override
void internal_send_state_to_frontend(const std::string &state)
bool new_value(std::string &value) override
bool new_value(std::string &value) override
std::function< optional< std::string >(std::string)> lambda_filter_t
bool map_filter_apply(const Substitution *mappings, size_t count, std::string &value)
Non-template helper (implementation in filter.cpp)
bool substitute_filter_apply(const Substitution *substitutions, size_t count, std::string &value)
Non-template helper (implementation in filter.cpp)