mirror of
https://github.com/esphome/esphome.git
synced 2025-10-26 20:53:50 +00:00
dry
This commit is contained in:
@@ -62,12 +62,7 @@ optional<std::string> AppendFilter::new_value(std::string value) { return value
|
|||||||
optional<std::string> PrependFilter::new_value(std::string value) { return this->prefix_ + value; }
|
optional<std::string> PrependFilter::new_value(std::string value) { return this->prefix_ + value; }
|
||||||
|
|
||||||
// Substitute
|
// Substitute
|
||||||
SubstituteFilter::SubstituteFilter(std::initializer_list<Substitution> substitutions) {
|
SubstituteFilter::SubstituteFilter(std::initializer_list<Substitution> substitutions) : substitutions_(substitutions) {}
|
||||||
this->substitutions_.init(substitutions.size());
|
|
||||||
for (auto &sub : substitutions) {
|
|
||||||
this->substitutions_.push_back(std::move(sub));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
optional<std::string> SubstituteFilter::new_value(std::string value) {
|
optional<std::string> SubstituteFilter::new_value(std::string value) {
|
||||||
std::size_t pos;
|
std::size_t pos;
|
||||||
@@ -79,12 +74,7 @@ optional<std::string> SubstituteFilter::new_value(std::string value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map
|
// Map
|
||||||
MapFilter::MapFilter(std::initializer_list<Substitution> mappings) {
|
MapFilter::MapFilter(std::initializer_list<Substitution> mappings) : mappings_(mappings) {}
|
||||||
this->mappings_.init(mappings.size());
|
|
||||||
for (auto &mapping : mappings) {
|
|
||||||
this->mappings_.push_back(std::move(mapping));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
optional<std::string> MapFilter::new_value(std::string value) {
|
optional<std::string> MapFilter::new_value(std::string value) {
|
||||||
for (const auto &mapping : this->mappings_) {
|
for (const auto &mapping : this->mappings_) {
|
||||||
|
|||||||
Reference in New Issue
Block a user