diff --git a/lib/json/reflector-boosthana.h b/lib/json/reflector-boosthana.h index 38b85ab..f3a611d 100644 --- a/lib/json/reflector-boosthana.h +++ b/lib/json/reflector-boosthana.h @@ -35,18 +35,6 @@ void push(const Type &reflectable, RAPIDJSON_NAMESPACE::Value::Object &value, RA // define functions to "pull" values from a RapidJSON array or object -template , std::is_floating_point, std::is_pointer, std::is_enum, - Traits::IsSpecializationOf, - Traits::All, Traits::Not>>>...> -void pull( - Type &reflectable, RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - boost::hana::for_each(boost::hana::keys(reflectable), [&reflectable, &value, &errors](auto key) { - pull(boost::hana::at_key(reflectable, key), boost::hana::to(key), value, errors); - }); -} - template , std::is_floating_point, std::is_pointer, std::is_enum, Traits::IsSpecializationOf, diff --git a/lib/json/reflector-chronoutilities.h b/lib/json/reflector-chronoutilities.h index d52d72c..ad5b581 100644 --- a/lib/json/reflector-chronoutilities.h +++ b/lib/json/reflector-chronoutilities.h @@ -55,21 +55,6 @@ inline void push(const ChronoUtilities::TimeSpan &ref // define functions to "pull" values from a RapidJSON array or object -template <> -inline void pull(ChronoUtilities::DateTime &reflectable, - RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - std::string asString; - pull(asString, value, errors); - try { - reflectable = ChronoUtilities::DateTime::fromIsoStringGmt(asString.data()); - } catch (const ConversionUtilities::ConversionException &) { - if (errors) { - errors->reportConversionError(JsonType::String); - } - } -} - template <> inline void pull(ChronoUtilities::DateTime &reflectable, const RAPIDJSON_NAMESPACE::GenericValue> &value, JsonDeserializationErrors *errors) @@ -85,21 +70,6 @@ inline void pull(ChronoUtilities::DateTime &reflectab } } -template <> -inline void pull(ChronoUtilities::TimeSpan &reflectable, - RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - std::string asString; - pull(asString, value, errors); - try { - reflectable = ChronoUtilities::TimeSpan::fromString(asString.data()); - } catch (const ConversionUtilities::ConversionException &) { - if (errors) { - errors->reportConversionError(JsonType::String); - } - } -} - template <> inline void pull(ChronoUtilities::TimeSpan &reflectable, const RAPIDJSON_NAMESPACE::GenericValue> &value, JsonDeserializationErrors *errors) diff --git a/lib/json/reflector.h b/lib/json/reflector.h index 223c1b7..b00cf5e 100644 --- a/lib/json/reflector.h +++ b/lib/json/reflector.h @@ -298,16 +298,6 @@ void push(const Type &reflectable, RAPIDJSON_NAMESPACE::Value::Array &value, RAP // define functions to "pull" values from a RapidJSON array or object -/*! - * \brief Pulls the \a reflectable which has a custom type from the specified value. - */ -template , std::is_floating_point, std::is_pointer, std::is_enum, - Traits::IsSpecializationOf, - Traits::All, Traits::Not>>>...> -void pull( - Type &reflectable, RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors); - /*! * \brief Pulls the \a reflectable which has a custom type from the specified object. * \remarks The definition of this function must be provided by the code generator or Boost.Hana. @@ -336,23 +326,6 @@ void pull(Type &reflectable, const RAPIDJSON_NAMESPACE::GenericValue(reflectable, value.GetObject(), errors); } -/*! - * \brief Pulls the integer/float/boolean from the specified value iterator which is supposed and checked to contain the right type. - */ -template , std::is_floating_point, std::is_pointer>...> -inline void pull( - Type &reflectable, RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - if (!value->Is()) { - if (errors) { - errors->reportTypeMismatch(value->GetType()); - } - return; - } - reflectable = value->Get(); - ++value; -} - /*! * \brief Pulls the integer/float/boolean from the specified value which is supposed and checked to contain the right type. */ @@ -369,23 +342,6 @@ inline void pull( reflectable = value.Get(); } -/*! - * \brief Pulls the std::string from the specified value iterator which is supposed and checked to contain a string. - */ -template <> -inline void pull(std::string &reflectable, RAPIDJSON_NAMESPACE::GenericValue>::ValueIterator &value, - JsonDeserializationErrors *errors) -{ - if (!value->IsString()) { - if (errors) { - errors->reportTypeMismatch(value->GetType()); - } - return; - } - reflectable = value->GetString(); - ++value; -} - /*! * \brief Pulls the std::string from the specified value which is supposed and checked to contain a string. */ @@ -408,43 +364,6 @@ inline void pull( template , Traits::Not>>...> void pull(Type &reflectable, rapidjson::GenericValue>::ConstArray array, JsonDeserializationErrors *errors); -/*! - * \brief Pulls the speciified \a reflectable which is an iteratable without reserve() method from the specified value iterator which is checked to contain an array. - */ -template , Traits::Not>, - Traits::Not>>...> -void pull(Type &reflectable, rapidjson::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - if (!value->IsArray()) { - if (errors) { - errors->reportTypeMismatch(value->GetType()); - } - return; - } - pull(reflectable, value->GetArray(), errors); - ++value; -} - -/*! - * \brief Pulls the speciified \a reflectable which is an iteratable with reserve() method from the specified value iterator which is checked to contain an array. - */ -template , Traits::IsReservable, Traits::Not>>...> -void pull(Type &reflectable, rapidjson::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - if (!value->IsArray()) { - if (errors) { - errors->reportTypeMismatch(value->GetType()); - } - return; - } - auto array = value->GetArray(); - reflectable.reserve(array.Size()); - pull(reflectable, array, errors); - ++value; -} - /*! * \brief Pulls the speciified \a reflectable which is an iteratable without reserve() method from the specified value which is checked to contain an array. */ @@ -530,31 +449,7 @@ template struct TuplePullHelper { } // namespace Detail /*! - * \brief Pulls the speciified \a reflectable which is tuple from the specified value iterator which is checked to contain an array. - */ -template >...> -void pull(Type &reflectable, rapidjson::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) -{ - if (!value->IsArray()) { - if (errors) { - errors->reportTypeMismatch(value->GetType()); - } - return; - } - auto array = value->GetArray(); - if (array.Size() != std::tuple_size::value) { - if (errors) { - // FIXME: report expected and actual size - errors->reportArraySizeMismatch(); - } - return; - } - Detail::TuplePullHelper::value>::pull(reflectable, array, errors); - ++value; -} - -/*! - * \brief Pulls the speciified \a reflectable which is tuple from the specified value iterator which is checked to contain an array. + * \brief Pulls the speciified \a reflectable which is tuple from the specified value which is checked to contain an array. */ template >...> void pull(Type &reflectable, rapidjson::GenericValue> &value, JsonDeserializationErrors *errors) @@ -576,6 +471,16 @@ void pull(Type &reflectable, rapidjson::GenericValue::value>::pull(reflectable, array, errors); } +/*! + * \brief Pulls the speciified \a reflectable from the specified value iterator which is checked to contain the right type. + */ +template +inline void pull(Type &reflectable, rapidjson::GenericValue>::ValueIterator &value, JsonDeserializationErrors *errors) +{ + pull(reflectable, *value, errors); + ++value; +} + /*! * \brief Pulls the speciified member of \a reflectable which has a custom type from the specified object. * \remarks It is checked whether the object actually contains the member. If not, the missing member is ignored. So currently all members