aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/accountdataevents.h2
-rw-r--r--lib/events/event.h6
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/events/accountdataevents.h b/lib/events/accountdataevents.h
index a99d85ac..ffee5ba6 100644
--- a/lib/events/accountdataevents.h
+++ b/lib/events/accountdataevents.h
@@ -85,7 +85,7 @@ namespace QMatrixClient
toJson(std::move(content)) } }) \
{ } \
auto _ContentKey() const \
- { return fromJson<content_type>(contentJson()[#_ContentKey##_ls]); } \
+ { return content<content_type>(#_ContentKey##_ls); } \
}; \
REGISTER_EVENT_TYPE(_Name) \
// End of macro
diff --git a/lib/events/event.h b/lib/events/event.h
index d7ac4292..b7bbd83e 100644
--- a/lib/events/event.h
+++ b/lib/events/event.h
@@ -32,19 +32,23 @@ namespace QMatrixClient
template <typename EventT>
using event_ptr_tt = std::unique_ptr<EventT>;
+ /// Unwrap a plain pointer from a smart pointer
template <typename EventT>
- inline EventT* rawPtr(const event_ptr_tt<EventT>& ptr) // unwrap
+ inline EventT* rawPtr(const event_ptr_tt<EventT>& ptr)
{
return ptr.get();
}
+ /// Unwrap a plain pointer and downcast it to the specified type
template <typename TargetEventT, typename EventT>
inline TargetEventT* weakPtrCast(const event_ptr_tt<EventT>& ptr)
{
return static_cast<TargetEventT*>(rawPtr(ptr));
}
+ /// Re-wrap a smart pointer to base into a smart pointer to derived
template <typename TargetT, typename SourceT>
+ [[deprecated("Consider using eventCast() or visit() instead")]]
inline event_ptr_tt<TargetT> ptrCast(event_ptr_tt<SourceT>&& ptr)
{
return unique_ptr_cast<TargetT>(ptr);