11namespace text_sensor {
36 void input(
const std::string &value);
38 void output(
const std::string &value);
104 SubstituteFilter(std::vector<std::string> from_strings, std::vector<std::string> to_strings)
104 SubstituteFilter(std::vector<std::string> from_strings, std::vector<std::string> to_strings) {
…}
A simple filter that adds a string to the end of another string.
AppendFilter(std::string suffix)
optional< std::string > new_value(std::string value) override
Apply a filter to text sensor values such as to_upper.
void output(const std::string &value)
void input(const std::string &value)
virtual void initialize(TextSensor *parent, Filter *next)
Initialize this filter, please note this can be called more than once.
virtual optional< std::string > new_value(std::string value)=0
This will be called every time the filter receives a new value.
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)
optional< std::string > new_value(std::string value) override
const lambda_filter_t & get_lambda_filter() const
A filter that maps values from one set to another.
optional< std::string > new_value(std::string value) override
MapFilter(std::map< std::string, std::string > mappings)
std::map< std::string, std::string > mappings_
A simple filter that adds a string to the start of another string.
PrependFilter(std::string prefix)
optional< std::string > new_value(std::string value) override
A simple filter that replaces a substring with another substring.
optional< std::string > new_value(std::string value) override
std::vector< std::string > to_strings_
std::vector< std::string > from_strings_
SubstituteFilter(std::vector< std::string > from_strings, std::vector< std::string > to_strings)
A simple filter that converts all text to lowercase.
optional< std::string > new_value(std::string value) override
A simple filter that converts all text to uppercase.
optional< std::string > new_value(std::string value) override
std::function< optional< std::string >(std::string)> lambda_filter_t
Providing packet encoding functions for exchanging data with a remote host.