Skip to content

Commit d191b5d

Browse files
committed
migrated helper to include/nlohmann/detail/conversions/from_json.hpp
Signed-off-by: Ash-Jose <[email protected]>
1 parent 677f5d9 commit d191b5d

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

include/nlohmann/detail/conversions/from_json.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
#include <nlohmann/detail/string_concat.hpp>
3030
#include <nlohmann/detail/value_t.hpp>
3131

32+
/* helper for strict enum error reporting */
33+
template<typename BasicJsonType>
34+
inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
35+
{
36+
JSON_THROW(::nlohmann::detail::type_error::create(
37+
302,
38+
std::string("invalid value for ") + enum_type + ": " + j.dump(),
39+
&j));
40+
}
41+
3242
// include after macro_scope.hpp
3343
#ifdef JSON_HAS_CPP_17
3444
#include <optional> // optional

include/nlohmann/detail/macro_scope.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,6 @@
260260
@since version 3.12.0
261261
*/
262262

263-
/* helper for strict enum error reporting */
264-
template<typename BasicJsonType>
265-
inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
266-
{
267-
JSON_THROW(::nlohmann::detail::type_error::create(
268-
302,
269-
std::string("invalid value for ") + enum_type + ": " + j.dump(),
270-
&j));
271-
}
272-
273263
#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(ENUM_TYPE, ...) \
274264
template<typename BasicJsonType> \
275265
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \

single_include/nlohmann/json.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,16 +2624,6 @@ JSON_HEDLEY_DIAGNOSTIC_POP
26242624
@since version 3.12.0
26252625
*/
26262626

2627-
/* helper for strict enum error reporting */
2628-
template<typename BasicJsonType>
2629-
inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
2630-
{
2631-
JSON_THROW(::nlohmann::detail::type_error::create(
2632-
302,
2633-
std::string("invalid value for ") + enum_type + ": " + j.dump(),
2634-
&j));
2635-
}
2636-
26372627
#define NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(ENUM_TYPE, ...) \
26382628
template<typename BasicJsonType> \
26392629
inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \
@@ -4914,6 +4904,16 @@ NLOHMANN_JSON_NAMESPACE_END
49144904
// #include <nlohmann/detail/value_t.hpp>
49154905

49164906

4907+
/* helper for strict enum error reporting */
4908+
template<typename BasicJsonType>
4909+
inline void throw_enum_error(const BasicJsonType& j, const char* enum_type)
4910+
{
4911+
JSON_THROW(::nlohmann::detail::type_error::create(
4912+
302,
4913+
std::string("invalid value for ") + enum_type + ": " + j.dump(),
4914+
&j));
4915+
}
4916+
49174917
// include after macro_scope.hpp
49184918
#ifdef JSON_HAS_CPP_17
49194919
#include <optional> // optional

0 commit comments

Comments
 (0)