aboutsummaryrefslogtreecommitdiff
path: root/lib/roomstateview.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/roomstateview.h')
-rw-r--r--lib/roomstateview.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/roomstateview.h b/lib/roomstateview.h
index 13b375f2..119c24cf 100644
--- a/lib/roomstateview.h
+++ b/lib/roomstateview.h
@@ -90,6 +90,26 @@ public:
return contains(EvT::TypeId);
}
+ template <Keyed_State_Event EvT>
+ auto content(const QString& stateKey,
+ typename EvT::content_type defaultValue = {}) const
+ {
+ // StateEvent<>::content is special in that it returns a const-ref,
+ // and lift() inside queryOr() can't wrap that in a temporary Omittable.
+ if (const auto evt = get<EvT>(stateKey))
+ return evt->content();
+ return std::move(defaultValue);
+ }
+
+ template <Keyless_State_Event EvT>
+ auto content(typename EvT::content_type defaultValue = {}) const
+ {
+ // Same as above
+ if (const auto evt = get<EvT>())
+ return evt->content();
+ return defaultValue;
+ }
+
//! \brief Get the content of the current state event with the given
//! event type and state key
//! \return An empty object if there's no event in the current state with