strinferf

This commit is contained in:
J. Nick Koston
2026-01-09 16:43:28 -10:00
parent fef7b6093d
commit 2eb98c19f7
5 changed files with 15 additions and 17 deletions

View File

@@ -8,13 +8,13 @@ event:
on_event:
- logger.log: Event fired
- lambda: |-
// Test get_last_event_type() returns std::string_view
// Test get_last_event_type() returns StringRef
if (id(some_event).has_event()) {
auto event_type = id(some_event).get_last_event_type();
// Compare with string literal using ==
if (event_type == "template_event_type1") {
ESP_LOGD("test", "Event type is template_event_type1");
}
// Log using %.*s format for string_view
ESP_LOGD("test", "Event type: %.*s", (int) event_type.size(), event_type.data());
// Log using %.*s format for StringRef
ESP_LOGD("test", "Event type: %.*s", (int) event_type.size(), event_type.c_str());
}