aboutsummaryrefslogtreecommitdiff
path: root/lib/events/single_key_value.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-05 07:49:16 +0200
committerGitHub <noreply@github.com>2022-09-05 07:49:16 +0200
commit1e263a32fcbc44985e474a626393494a81f15e37 (patch)
tree8811e0a995dcd593cb9f233e02ece9402e76eb1b /lib/events/single_key_value.h
parent8cb629f406f5b8b1ff7ce787dd3967d5684e07c3 (diff)
parentbd2736bc9f8b6023ecbc21d0d831856703b853db (diff)
downloadlibquotient-1e263a32fcbc44985e474a626393494a81f15e37.tar.gz
libquotient-1e263a32fcbc44985e474a626393494a81f15e37.zip
Merge pull request #565 from quotient-im/kitsune/streamline-event-types-2
Streamline event types, part 2
Diffstat (limited to 'lib/events/single_key_value.h')
-rw-r--r--lib/events/single_key_value.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/events/single_key_value.h b/lib/events/single_key_value.h
index 75ca8cd2..ca2bd331 100644
--- a/lib/events/single_key_value.h
+++ b/lib/events/single_key_value.h
@@ -5,13 +5,22 @@
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)
+ QUO_IMPLICIT SingleKeyValue(const T& v = {})
+ : value { v }
+ {}
+ QUO_IMPLICIT SingleKeyValue(T&& v)
+ : value { std::move(v) }
+ {}
+ // NOLINTEND(google-explicit-constructor)
T value;
};
} // 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)
@@ -22,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