Redesigned the writer (#36) and added YAML support based on the new writer (#23)

This commit is contained in:
Patrick Urbanke
2024-01-03 07:22:36 +01:00
parent 0a524a9893
commit 5c81e40f09
133 changed files with 3082 additions and 838 deletions
+4 -17
View File
@@ -4,6 +4,7 @@
#include <yyjson.h>
#include <array>
#include <concepts>
#include <exception>
#include <map>
#include <memory>
@@ -42,24 +43,10 @@ struct Reader {
using InputObjectType = YYJSONInputObject;
using InputVarType = YYJSONInputVar;
template <class T, class = void>
struct has_from_json_obj : std::false_type {};
template <class T>
struct has_from_json_obj<
T,
std::enable_if_t<std::is_invocable_r<
T, decltype(T::from_json_obj), typename Reader::InputVarType>::value>>
: std::true_type {};
template <class T>
struct has_from_json_obj<T, std::enable_if_t<std::is_invocable_r<
rfl::Result<T>, decltype(T::from_json_obj),
typename Reader::InputVarType>::value>>
: std::true_type {};
template <class T>
static constexpr bool has_custom_constructor = has_from_json_obj<T>::value;
static constexpr bool has_custom_constructor = (requires(InputVarType var) {
T::from_json_obj(var);
});
rfl::Result<InputVarType> get_field(
const std::string& _name, const InputObjectType _obj) const noexcept {