Util: Add get<T>() functionality with customization points to Value

This commit is contained in:
Riyyi
2022-07-08 14:23:38 +02:00
parent c5bbd7befd
commit 0c972f420c
3 changed files with 137 additions and 2 deletions
+18
View File
@@ -13,6 +13,8 @@
#include <iostream> // istream, ostream
#include <string>
#include "util/json/fromjson.h"
namespace Json {
class Array;
@@ -73,6 +75,22 @@ public:
// --------------------------------------
template<typename T>
T get() const
{
T type;
fromJson(*this, type);
return type;
}
template<typename T>
void getTo(T& type) const
{
fromJson(*this, type);
}
// --------------------------------------
Type type() const { return m_type; }
size_t size() const;