diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-01 17:42:57 +0300 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-11-01 17:42:57 +0300 |
commit | c4e1e0906558608326210eb333b0beb73636de60 (patch) | |
tree | cd5abf797bdaa93a18a9b52423392900722c2cf9 /converters.h | |
parent | 2931b4d13e1883150b92f80f08aa51d86ac2445f (diff) | |
download | libquotient-c4e1e0906558608326210eb333b0beb73636de60.tar.gz libquotient-c4e1e0906558608326210eb333b0beb73636de60.zip |
Add fromJson<QList<QString>> and fromJson<QStringList>
Diffstat (limited to 'converters.h')
-rw-r--r-- | converters.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/converters.h b/converters.h index f6e850c6..733c2c0e 100644 --- a/converters.h +++ b/converters.h @@ -118,4 +118,19 @@ namespace QMatrixClient return vect; } }; + + template <typename T> struct FromJson<QList<T>> + { + QList<T> operator()(QJsonValue jv) const + { + const auto jsonArray = jv.toArray(); + QList<T> sl; sl.reserve(jsonArray.size()); + std::transform(jsonArray.begin(), jsonArray.end(), + std::back_inserter(sl), FromJson<T>()); + return sl; + } + }; + + template <> struct FromJson<QStringList> : FromJson<QList<QString>> { }; + } // namespace QMatrixClient |