From c0c72b5b62c29f9c220c1eb56273ff2a6bcc273f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Delrieu?= Date: Wed, 30 Nov 2016 23:16:54 +0100 Subject: [PATCH] rewrite unit-udt: basic usage --- src/json.hpp | 138 ++++++++++++++++++++-- test/src/unit-class_const_iterator.cpp | 36 +++--- test/src/unit-class_iterator.cpp | 36 +++--- test/src/unit-udt.cpp | 156 ++++++++++++++++++++----- 4 files changed, 290 insertions(+), 76 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 2dfa7c02..fc7781ea 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -257,6 +257,30 @@ struct is_compatible_integer_type_impl +struct is_compatible_enum_type_impl : std::false_type{}; + +template +struct is_compatible_enum_type_impl +{ + using RealLimits = std::numeric_limits; + using CompatibleLimits = std::numeric_limits::type>; + + static constexpr auto value = + CompatibleLimits::is_integer and + RealLimits::is_signed == CompatibleLimits::is_signed; +}; + +template +struct is_compatible_enum_type +{ + static constexpr auto value = is_compatible_enum_type_impl< +// quickfix for all enums + std::is_enum::value, RealIntegerType, + CompatibleEnumType>::value; +}; + template struct is_compatible_integer_type { @@ -281,6 +305,7 @@ struct is_compatible_basic_json_type std::is_constructible::value or std::is_same::value or is_compatible_array_type::value or + is_compatible_enum_type::value or is_compatible_object_type::value or is_compatible_float_type::value or is_compatible_integer_type::value; }; +template +struct is_basic_json_nested_class +{ + static auto constexpr value = std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value or + std::is_same::value; +}; // This trait checks if JSONSerializer::from_json(json const&, udt&) exists template