diff options
Diffstat (limited to 'lib/events')
-rw-r--r-- | lib/events/event.h | 26 | ||||
-rw-r--r-- | lib/events/simplestateevents.h | 24 | ||||
-rw-r--r-- | lib/events/single_key_value.h | 6 |
3 files changed, 28 insertions, 28 deletions
diff --git a/lib/events/event.h b/lib/events/event.h index c8ef5acb..0abef1f0 100644 --- a/lib/events/event.h +++ b/lib/events/event.h @@ -511,19 +511,19 @@ public: /// To retrieve the value the getter uses a JSON key name that corresponds to /// its own (getter's) name but written in snake_case. \p GetterName_ must be /// in camelCase, no quotes (an identifier, not a literal). -#define DEFINE_SIMPLE_EVENT(Name_, Base_, TypeId_, ValueType_, GetterName_, \ - JsonKey_) \ - constexpr auto Name_##ContentKey = JsonKey_##_ls; \ - class QUOTIENT_API Name_ \ - : public EventTemplate< \ - Name_, Base_, \ - EventContent::SingleKeyValue<ValueType_, &Name_##ContentKey>> { \ - public: \ - QUO_EVENT(Name_, TypeId_) \ - using value_type = ValueType_; \ - using EventTemplate::EventTemplate; \ - QUO_CONTENT_GETTER_X(ValueType_, GetterName_, Name_##ContentKey) \ - }; \ +#define DEFINE_SIMPLE_EVENT(Name_, Base_, TypeId_, ValueType_, GetterName_, \ + JsonKey_) \ + constexpr auto Name_##ContentKey = JsonKey_##_ls; \ + class QUOTIENT_API Name_ \ + : public EventTemplate< \ + Name_, Base_, \ + EventContent::SingleKeyValue<ValueType_, Name_##ContentKey>> { \ + public: \ + QUO_EVENT(Name_, TypeId_) \ + using value_type = ValueType_; \ + using EventTemplate::EventTemplate; \ + QUO_CONTENT_GETTER_X(ValueType_, GetterName_, Name_##ContentKey) \ + }; \ // End of macro // === is<>(), eventCast<>() and switchOnType<>() === diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h index d84dc1b1..2a0d3817 100644 --- a/lib/events/simplestateevents.h +++ b/lib/events/simplestateevents.h @@ -7,17 +7,17 @@ #include "single_key_value.h" namespace Quotient { -#define DEFINE_SIMPLE_STATE_EVENT(Name_, TypeId_, ValueType_, ContentKey_) \ - constexpr auto Name_##Key = #ContentKey_##_ls; \ - class QUOTIENT_API Name_ \ - : public KeylessStateEventBase< \ - Name_, EventContent::SingleKeyValue<ValueType_, &Name_##Key>> { \ - public: \ - using value_type = ValueType_; \ - QUO_EVENT(Name_, TypeId_) \ - using KeylessStateEventBase::KeylessStateEventBase; \ - auto ContentKey_() const { return content().value; } \ - }; \ +#define DEFINE_SIMPLE_STATE_EVENT(Name_, TypeId_, ValueType_, ContentKey_) \ + constexpr auto Name_##Key = #ContentKey_##_ls; \ + class QUOTIENT_API Name_ \ + : public KeylessStateEventBase< \ + Name_, EventContent::SingleKeyValue<ValueType_, Name_##Key>> { \ + public: \ + using value_type = ValueType_; \ + QUO_EVENT(Name_, TypeId_) \ + using KeylessStateEventBase::KeylessStateEventBase; \ + auto ContentKey_() const { return content().value; } \ + }; \ // End of macro DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name) @@ -29,7 +29,7 @@ constexpr auto RoomAliasesEventKey = "aliases"_ls; class QUOTIENT_API RoomAliasesEvent : public KeyedStateEventBase< RoomAliasesEvent, - EventContent::SingleKeyValue<QStringList, &RoomAliasesEventKey>> + EventContent::SingleKeyValue<QStringList, RoomAliasesEventKey>> { public: QUO_EVENT(RoomAliasesEvent, "m.room.aliases") diff --git a/lib/events/single_key_value.h b/lib/events/single_key_value.h index 5edff3b1..ca2bd331 100644 --- a/lib/events/single_key_value.h +++ b/lib/events/single_key_value.h @@ -5,7 +5,7 @@ namespace Quotient { namespace EventContent { - template <typename T, const QLatin1String* KeyStr> + template <typename T, const QLatin1String& KeyStr> struct SingleKeyValue { // NOLINTBEGIN(google-explicit-constructor): that check should learn // about explicit(false) @@ -20,7 +20,7 @@ namespace EventContent { }; } // namespace EventContent -template <typename ValueT, const QLatin1String* KeyStr> +template <typename ValueT, const QLatin1String& KeyStr> struct JsonConverter<EventContent::SingleKeyValue<ValueT, KeyStr>> { using content_type = EventContent::SingleKeyValue<ValueT, KeyStr>; static content_type load(const QJsonValue& jv) @@ -31,6 +31,6 @@ struct JsonConverter<EventContent::SingleKeyValue<ValueT, KeyStr>> { { return { { JsonKey, toJson(c.value) } }; } - static inline const auto JsonKey = toSnakeCase(*KeyStr); + static inline const auto JsonKey = toSnakeCase(KeyStr); }; } // namespace Quotient |