|
ESPHome 2026.2.1
|
#include <automation.h>
Public Member Functions | |
| TemplatableValue () | |
| TemplatableValue (const char *str) | |
| template<typename F > requires (!std::invocable<F, X...>) | |
| TemplatableValue (F value) | |
| template<typename F > requires std::invocable<F, X...> && std::convertible_to<F, T (*)(X...)> | |
| TemplatableValue (F f) | |
| template<typename F > requires std::invocable<F, X...> &&(!std::convertible_to<F, T (*)(X...)>) | |
| TemplatableValue (F f) | |
| TemplatableValue (const TemplatableValue &other) | |
| TemplatableValue (TemplatableValue &&other) noexcept | |
| TemplatableValue & | operator= (const TemplatableValue &other) |
| TemplatableValue & | operator= (TemplatableValue &&other) noexcept |
| ~TemplatableValue () | |
| bool | has_value () const |
| T | value (X... x) const |
| optional< T > | optional_value (X... x) |
| T | value_or (X... x, T default_value) |
| bool | is_static_string () const |
| Check if this holds a static string (const char* stored without allocation) | |
| const char * | get_static_string () const |
| Get the static string pointer (only valid if is_static_string() returns true) | |
| bool | is_empty () const |
| Check if the string value is empty without allocating (for std::string specialization). | |
| StringRef | ref_or_copy_to (char *lambda_buf, size_t lambda_buf_size) const |
| Get a StringRef to the string value without heap allocation when possible. | |
Protected Types | |
| enum | : uint8_t { NONE , VALUE , LAMBDA , STATELESS_LAMBDA , STATIC_STRING } |
| using | ValueStorage = std::conditional_t<USE_HEAP_STORAGE, T *, T> |
Protected Attributes | ||
| enum esphome::TemplatableValue:: { ... } | type_ | |
| union { | ||
| ValueStorage value_ | ||
| std::function< T(X...)> * f_ | ||
| T(* stateless_f_ )(X...) | ||
| const char * static_str_ | ||
| }; | ||
Definition at line 45 of file automation.h.
|
protected |
Definition at line 245 of file automation.h.
|
protected |
| Enumerator | |
|---|---|
| NONE | |
| VALUE | |
| LAMBDA | |
| STATELESS_LAMBDA | |
| STATIC_STRING | |
Definition at line 236 of file automation.h.
|
inline |
Definition at line 51 of file automation.h.
|
inline |
Definition at line 55 of file automation.h.
|
inline |
Definition at line 59 of file automation.h.
|
inline |
Definition at line 69 of file automation.h.
|
inline |
Definition at line 76 of file automation.h.
|
inline |
Definition at line 81 of file automation.h.
|
inlinenoexcept |
Definition at line 98 of file automation.h.
|
inline |
Definition at line 134 of file automation.h.
|
inline |
Get the static string pointer (only valid if is_static_string() returns true)
Definition at line 192 of file automation.h.
|
inline |
Definition at line 147 of file automation.h.
|
inline |
Check if the string value is empty without allocating (for std::string specialization).
For NONE, returns true. For STATIC_STRING/VALUE, checks without allocation. For LAMBDA/STATELESS_LAMBDA, must call value() which may allocate.
Definition at line 197 of file automation.h.
|
inline |
Check if this holds a static string (const char* stored without allocation)
Definition at line 189 of file automation.h.
|
inline |
Definition at line 118 of file automation.h.
|
inlinenoexcept |
Definition at line 126 of file automation.h.
|
inline |
Definition at line 174 of file automation.h.
|
inline |
Get a StringRef to the string value without heap allocation when possible.
For STATIC_STRING/VALUE, returns reference to existing data (no allocation). For LAMBDA/STATELESS_LAMBDA, calls value(), copies to provided buffer, returns ref to buffer.
| lambda_buf | Buffer used only for lambda case (must remain valid while StringRef is used). |
| lambda_buf_size | Size of the buffer. |
Definition at line 216 of file automation.h.
|
inline |
Definition at line 149 of file automation.h.
|
inline |
Definition at line 181 of file automation.h.
| union { ... } esphome::TemplatableValue< T, X > |
| std::function<T(X...)>* esphome::TemplatableValue< T, X >::f_ |
Definition at line 248 of file automation.h.
| T(* esphome::TemplatableValue< T, X >::stateless_f_) (X...) |
Definition at line 249 of file automation.h.
| const char* esphome::TemplatableValue< T, X >::static_str_ |
Definition at line 250 of file automation.h.
| enum { ... } esphome::TemplatableValue< T, X >::type_ |
| ValueStorage esphome::TemplatableValue< T, X >::value_ |
Definition at line 247 of file automation.h.