diff --git a/lib/json/reflector.h b/lib/json/reflector.h index e2c89c6..8a2e0fc 100644 --- a/lib/json/reflector.h +++ b/lib/json/reflector.h @@ -148,12 +148,24 @@ inline void push(const Type &reflectable, RAPIDJSON_NAMESPACE::Value &value, RAP /*! * \brief Pushes the specified integer/float/boolean to the specified value. */ -template , std::is_floating_point> * = nullptr> +template , Traits::Not>, Traits::Not>>, + std::is_floating_point> * = nullptr> inline void push(Type reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) { value.Set(reflectable, allocator); } +/*! + * \brief Pushes the specified 8-bit integer to the specified value. + */ +template , std::is_same> * = nullptr> +inline void push(Type reflectable, RAPIDJSON_NAMESPACE::Value &value, RAPIDJSON_NAMESPACE::Document::AllocatorType &allocator) +{ + value.Set(static_cast(reflectable), allocator); +} + /*! * \brief Pushes the specified enumeration item to the specified value. */ @@ -517,7 +529,8 @@ void pull(Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue>, Traits::Any, std::is_floating_point>> * = nullptr> + Traits::EnableIf>, Traits::Not>, + Traits::Not>, Traits::Any, std::is_floating_point>> * = nullptr> inline void pull( Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue> &value, JsonDeserializationErrors *errors) { @@ -530,6 +543,20 @@ inline void pull( reflectable = value.Is() ? value.Get() : static_cast(value.GetDouble()); } +/*! + * \brief Pulls the integer or float from the specified value which is supposed and checked to contain the right type. + */ +template , std::is_same> * = nullptr> +inline void pull( + Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue> &value, JsonDeserializationErrors *errors) +{ + int i = 0; + pull(i, value, errors); + if (value.IsNumber()) { + reflectable = static_cast(i); + } +} + /*! * \brief Pulls the boolean from the specified value which is supposed and checked to contain the right type. */