From dabe99f83c9f0a0067890239f976fcd63dc32029 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 edf8a78eb..6a587da97 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -242,6 +242,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 { @@ -266,6 +290,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