mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
Renamed template parameter and added some comments.
This commit is contained in:
@ -19,23 +19,37 @@ struct adl_serializer
|
|||||||
This function is usually called by the `get()` function of the
|
This function is usually called by the `get()` function of the
|
||||||
@ref basic_json class (either explicit or via conversion operators).
|
@ref basic_json class (either explicit or via conversion operators).
|
||||||
|
|
||||||
|
@note This function is chosen for value types which can be default constructed.
|
||||||
|
|
||||||
@param[in] j JSON value to read from
|
@param[in] j JSON value to read from
|
||||||
@param[in,out] val value to write to
|
@param[in,out] val value to write to
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto from_json(BasicJsonType && j, U& val) noexcept(
|
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
|
||||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
||||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
||||||
{
|
{
|
||||||
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
|
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
/*!
|
||||||
|
@brief convert a JSON value to any value type
|
||||||
|
|
||||||
|
This function is usually called by the `get()` function of the
|
||||||
|
@ref basic_json class (either explicit or via conversion operators).
|
||||||
|
|
||||||
|
@note This function is chosen for value types which can not be default constructed.
|
||||||
|
|
||||||
|
@param[in] j JSON value to read from
|
||||||
|
|
||||||
|
@return copy of the JSON value, converted to @a ValueType
|
||||||
|
*/
|
||||||
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto from_json(BasicJsonType && j) noexcept(
|
static auto from_json(BasicJsonType && j) noexcept(
|
||||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {})))
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {})))
|
||||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {}))
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {}))
|
||||||
{
|
{
|
||||||
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {});
|
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -47,12 +61,12 @@ struct adl_serializer
|
|||||||
@param[in,out] j JSON value to write to
|
@param[in,out] j JSON value to write to
|
||||||
@param[in] val value to read from
|
@param[in] val value to read from
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto to_json(BasicJsonType& j, U && val) noexcept(
|
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
|
||||||
noexcept(::nlohmann::to_json(j, std::forward<U>(val))))
|
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
|
||||||
-> decltype(::nlohmann::to_json(j, std::forward<U>(val)), void())
|
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
|
||||||
{
|
{
|
||||||
::nlohmann::to_json(j, std::forward<U>(val));
|
::nlohmann::to_json(j, std::forward<TargetType>(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
@ -462,6 +462,8 @@ struct from_json_fn
|
|||||||
return from_json(j, val);
|
return from_json(j, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overload to pass calls to built-in from_json functions for non-default constructible STL
|
||||||
|
// types (e.g. std::array<X>, where X is not default constructible).
|
||||||
template<typename BasicJsonType, typename T>
|
template<typename BasicJsonType, typename T>
|
||||||
auto operator()(const BasicJsonType& j, detail::tag<T> t) const
|
auto operator()(const BasicJsonType& j, detail::tag<T> t) const
|
||||||
noexcept(noexcept(from_json(j, t)))
|
noexcept(noexcept(from_json(j, t)))
|
||||||
|
@ -3959,6 +3959,8 @@ struct from_json_fn
|
|||||||
return from_json(j, val);
|
return from_json(j, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overload to pass calls to built-in from_json functions for non-default constructible STL
|
||||||
|
// types (e.g. std::array<X>, where X is not default constructible).
|
||||||
template<typename BasicJsonType, typename T>
|
template<typename BasicJsonType, typename T>
|
||||||
auto operator()(const BasicJsonType& j, detail::tag<T> t) const
|
auto operator()(const BasicJsonType& j, detail::tag<T> t) const
|
||||||
noexcept(noexcept(from_json(j, t)))
|
noexcept(noexcept(from_json(j, t)))
|
||||||
@ -4553,23 +4555,37 @@ struct adl_serializer
|
|||||||
This function is usually called by the `get()` function of the
|
This function is usually called by the `get()` function of the
|
||||||
@ref basic_json class (either explicit or via conversion operators).
|
@ref basic_json class (either explicit or via conversion operators).
|
||||||
|
|
||||||
|
@note This function is chosen for value types which can be default constructed.
|
||||||
|
|
||||||
@param[in] j JSON value to read from
|
@param[in] j JSON value to read from
|
||||||
@param[in,out] val value to write to
|
@param[in,out] val value to write to
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto from_json(BasicJsonType && j, U& val) noexcept(
|
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
|
||||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
|
||||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
|
||||||
{
|
{
|
||||||
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
|
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
/*!
|
||||||
|
@brief convert a JSON value to any value type
|
||||||
|
|
||||||
|
This function is usually called by the `get()` function of the
|
||||||
|
@ref basic_json class (either explicit or via conversion operators).
|
||||||
|
|
||||||
|
@note This function is chosen for value types which can not be default constructed.
|
||||||
|
|
||||||
|
@param[in] j JSON value to read from
|
||||||
|
|
||||||
|
@return copy of the JSON value, converted to @a ValueType
|
||||||
|
*/
|
||||||
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto from_json(BasicJsonType && j) noexcept(
|
static auto from_json(BasicJsonType && j) noexcept(
|
||||||
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {})))
|
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {})))
|
||||||
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {}))
|
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {}))
|
||||||
{
|
{
|
||||||
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<U> {});
|
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::tag<TargetType> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -4581,12 +4597,12 @@ struct adl_serializer
|
|||||||
@param[in,out] j JSON value to write to
|
@param[in,out] j JSON value to write to
|
||||||
@param[in] val value to read from
|
@param[in] val value to read from
|
||||||
*/
|
*/
|
||||||
template<typename BasicJsonType, typename U = ValueType>
|
template<typename BasicJsonType, typename TargetType = ValueType>
|
||||||
static auto to_json(BasicJsonType& j, U && val) noexcept(
|
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
|
||||||
noexcept(::nlohmann::to_json(j, std::forward<U>(val))))
|
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
|
||||||
-> decltype(::nlohmann::to_json(j, std::forward<U>(val)), void())
|
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
|
||||||
{
|
{
|
||||||
::nlohmann::to_json(j, std::forward<U>(val));
|
::nlohmann::to_json(j, std::forward<TargetType>(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
Reference in New Issue
Block a user