|
ESPHome 2026.8.2
|
Specialization for std::string: supports VALUE, STATIC_STRING, FLASH_STRING, stateless lambdas, and stateful lambdas (std::function). More...
#include <automation.h>
Public Member Functions | |
| TemplatableValue () | |
| TemplatableValue (const char *str) | |
| TemplatableValue (const __FlashStringHelper *str) | |
| template<typename F > requires (!std::invocable<F, X...>) | |
| TemplatableValue (F value) | |
| template<typename F > requires std::invocable<F, X...> && std::convertible_to<F, std::string (*)(X...)> | |
| TemplatableValue (F f) | |
| template<typename F > requires std::invocable<F, X...> &&(!std::convertible_to<F, std::string (*)(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 |
| std::string | value (X... x) const |
| optional< std::string > | optional_value (X... x) const |
| std::string | value_or (X... x, std::string default_value) const |
| bool | is_static_string () const |
| Check if this holds a static string (const char* stored without allocation) The pointer is always directly readable (RAM or flash-mapped). | |
| const char * | get_static_string () const |
| Get the static string pointer (only valid if is_static_string() returns true) The pointer is always directly readable — FLASH_STRING uses a separate type. | |
| bool | is_empty () const |
| Check if the string value is empty without allocating. | |
| 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 , FLASH_STRING } |
Protected Attributes | |
| enum esphome::TemplatableValue< std::string, X... >:: { ... } | type_ |
| union esphome::TemplatableValue< std::string, X... >:: { ... } | |
Specialization for std::string: supports VALUE, STATIC_STRING, FLASH_STRING, stateless lambdas, and stateful lambdas (std::function).
Definition at line 217 of file automation.h.
|
protected |
| Enumerator | |
|---|---|
| NONE | |
| VALUE | |
| LAMBDA | |
| STATELESS_LAMBDA | |
| STATIC_STRING | |
| FLASH_STRING | |
Definition at line 418 of file automation.h.
|
inline |
Definition at line 219 of file automation.h.
|
inline |
Definition at line 223 of file automation.h.
|
inline |
Definition at line 229 of file automation.h.
|
inline |
Definition at line 234 of file automation.h.
|
inline |
Definition at line 240 of file automation.h.
|
inline |
Definition at line 247 of file automation.h.
|
inline |
Definition at line 253 of file automation.h.
|
inlinenoexcept |
Definition at line 266 of file automation.h.
|
inline |
Definition at line 298 of file automation.h.
|
inline |
Get the static string pointer (only valid if is_static_string() returns true) The pointer is always directly readable — FLASH_STRING uses a separate type.
Definition at line 353 of file automation.h.
|
inline |
Definition at line 307 of file automation.h.
|
inline |
Check if the string value is empty without allocating.
For NONE, returns true. For STATIC_STRING/VALUE, checks without allocation. For LAMBDA/STATELESS_LAMBDA, must call value() which may allocate.
Definition at line 358 of file automation.h.
|
inline |
Check if this holds a static string (const char* stored without allocation) The pointer is always directly readable (RAM or flash-mapped).
Returns false for FLASH_STRING (PROGMEM on ESP8266, requires _P functions).
Definition at line 349 of file automation.h.
|
inline |
Definition at line 282 of file automation.h.
|
inlinenoexcept |
Definition at line 290 of file automation.h.
|
inline |
Definition at line 334 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 FLASH_STRING (ESP8266 PROGMEM), copies to provided buffer via _P functions. For LAMBDA/STATELESS_LAMBDA, calls value(), copies to provided buffer, returns ref to buffer.
| lambda_buf | Buffer used only for copy cases (must remain valid while StringRef is used). |
| lambda_buf_size | Size of the buffer. |
Definition at line 384 of file automation.h.
|
inline |
Definition at line 309 of file automation.h.
|
inline |
Definition at line 340 of file automation.h.
| union esphome::TemplatableValue< std::string, X... > { ... } esphome::TemplatableValue< std::string, X... > |
| std::function<std::string(X...)>* esphome::TemplatableValue< std::string, X... >::f_ |
Definition at line 428 of file automation.h.
| std::string(* esphome::TemplatableValue< std::string, X... >::stateless_f_) (X...) |
Definition at line 429 of file automation.h.
| const char* esphome::TemplatableValue< std::string, X... >::static_str_ |
Definition at line 430 of file automation.h.
| enum esphome::TemplatableValue< std::string, X... > { ... } esphome::TemplatableValue< std::string, X... >::type_ |
| std::string* esphome::TemplatableValue< std::string, X... >::value_ |
Definition at line 427 of file automation.h.