Two new macroses NLOHMANN_DEFINE_TYPE_INTRUSIVE_2 and NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_2 added to make work with arbitrary basic_json overloads easier.
This commit is contained in:
parent
97fe455ad5
commit
a0b170b668
@ -57,7 +57,7 @@ class json_ref
|
|||||||
|
|
||||||
value_type const* operator->() const
|
value_type const* operator->() const
|
||||||
{
|
{
|
||||||
return &**this;
|
return &** this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -292,6 +292,24 @@
|
|||||||
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_2
|
||||||
|
@since version 3.9.2
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_2(Type, ...) \
|
||||||
|
template<class JsonType> friend void to_json(JsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<class JsonType> friend void from_json(const JsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_2
|
||||||
|
@since version 3.9.2
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_2(Type, ...) \
|
||||||
|
template<class JsonType> void to_json(JsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<class JsonType> void from_json(const JsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||||
#define JSON_USE_IMPLICIT_CONVERSIONS 1
|
#define JSON_USE_IMPLICIT_CONVERSIONS 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2369,6 +2369,24 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
|||||||
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_INTRUSIVE_2
|
||||||
|
@since version 3.9.2
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_2(Type, ...) \
|
||||||
|
template<class JsonType> friend void to_json(JsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<class JsonType> friend void from_json(const JsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief macro
|
||||||
|
@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_2
|
||||||
|
@since version 3.9.2
|
||||||
|
*/
|
||||||
|
#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_2(Type, ...) \
|
||||||
|
template<class JsonType> void to_json(JsonType& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \
|
||||||
|
template<class JsonType> void from_json(const JsonType& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) }
|
||||||
|
|
||||||
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
#ifndef JSON_USE_IMPLICIT_CONVERSIONS
|
||||||
#define JSON_USE_IMPLICIT_CONVERSIONS 1
|
#define JSON_USE_IMPLICIT_CONVERSIONS 1
|
||||||
#endif
|
#endif
|
||||||
@ -4515,15 +4533,15 @@ class byte_container_with_subtype : public BinaryType
|
|||||||
: container_type(std::move(b))
|
: container_type(std::move(b))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
byte_container_with_subtype(const container_type& b, std::uint8_t subtype) noexcept(noexcept(container_type(b)))
|
byte_container_with_subtype(const container_type& b, std::uint8_t subtype_) noexcept(noexcept(container_type(b)))
|
||||||
: container_type(b)
|
: container_type(b)
|
||||||
, m_subtype(subtype)
|
, m_subtype(subtype_)
|
||||||
, m_has_subtype(true)
|
, m_has_subtype(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
byte_container_with_subtype(container_type&& b, std::uint8_t subtype) noexcept(noexcept(container_type(std::move(b))))
|
byte_container_with_subtype(container_type&& b, std::uint8_t subtype_) noexcept(noexcept(container_type(std::move(b))))
|
||||||
: container_type(std::move(b))
|
: container_type(std::move(b))
|
||||||
, m_subtype(subtype)
|
, m_subtype(subtype_)
|
||||||
, m_has_subtype(true)
|
, m_has_subtype(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -4556,9 +4574,9 @@ class byte_container_with_subtype : public BinaryType
|
|||||||
|
|
||||||
@since version 3.8.0
|
@since version 3.8.0
|
||||||
*/
|
*/
|
||||||
void set_subtype(std::uint8_t subtype) noexcept
|
void set_subtype(std::uint8_t subtype_) noexcept
|
||||||
{
|
{
|
||||||
m_subtype = subtype;
|
m_subtype = subtype_;
|
||||||
m_has_subtype = true;
|
m_has_subtype = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12645,7 +12663,7 @@ class json_ref
|
|||||||
|
|
||||||
value_type const* operator->() const
|
value_type const* operator->() const
|
||||||
{
|
{
|
||||||
return &**this;
|
return &** this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user