Skip to content

Commit a18ff7c

Browse files
committed
style: apply concat() suggestion and rerun make amalgamate
Signed-off-by: Ash-Jose <[email protected]>
1 parent bbb77da commit a18ff7c

File tree

3 files changed

+73
-71
lines changed

3 files changed

+73
-71
lines changed

include/nlohmann/detail/macro_scope.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@
288288
if (it == std::end(m)) \
289289
{ \
290290
throw ::nlohmann::detail::type_error::create( \
291-
302, \
292-
concat("invalid value for ", #ENUM_TYPE, ": ", j.dump()), \
293-
j); \
291+
302, \
292+
concat("invalid value for ", #ENUM_TYPE, ": ", j.dump()), \
293+
j); \
294294
} \
295295
e = it->first; \
296296
}

single_include/nlohmann/json.hpp

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -2652,9 +2652,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP
26522652
if (it == std::end(m)) \
26532653
{ \
26542654
throw ::nlohmann::detail::type_error::create( \
2655-
302, \
2656-
concat("invalid value for ", #ENUM_TYPE, ": ", j.dump()), \
2657-
j); \
2655+
302, \
2656+
concat("invalid value for ", #ENUM_TYPE, ": ", j.dump()), \
2657+
j); \
26582658
} \
26592659
e = it->first; \
26602660
}
@@ -3541,71 +3541,71 @@ NLOHMANN_JSON_NAMESPACE_END
35413541
// SPDX-License-Identifier: MIT
35423542

35433543
#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_
3544-
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
3544+
#define INCLUDE_NLOHMANN_JSON_FWD_HPP_
35453545

3546-
#include <cstdint> // int64_t, uint64_t
3547-
#include <map> // map
3548-
#include <memory> // allocator
3549-
#include <string> // string
3550-
#include <vector> // vector
3551-
3552-
// #include <nlohmann/detail/abi_macros.hpp>
3546+
#include <cstdint> // int64_t, uint64_t
3547+
#include <map> // map
3548+
#include <memory> // allocator
3549+
#include <string> // string
3550+
#include <vector> // vector
35533551

3552+
// #include <nlohmann/detail/abi_macros.hpp>
35543553

3555-
/*!
3556-
@brief namespace for Niels Lohmann
3557-
@see https://github.com/nlohmann
3558-
@since version 1.0.0
3559-
*/
3560-
NLOHMANN_JSON_NAMESPACE_BEGIN
35613554

3562-
/*!
3563-
@brief default JSONSerializer template argument
3555+
/*!
3556+
@brief namespace for Niels Lohmann
3557+
@see https://github.com/nlohmann
3558+
@since version 1.0.0
3559+
*/
3560+
NLOHMANN_JSON_NAMESPACE_BEGIN
35643561

3565-
This serializer ignores the template arguments and uses ADL
3566-
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3567-
for serialization.
3568-
*/
3569-
template<typename T = void, typename SFINAE = void>
3570-
struct adl_serializer;
3571-
3572-
/// a class to store JSON values
3573-
/// @sa https://json.nlohmann.me/api/basic_json/
3574-
template<template<typename U, typename V, typename... Args> class ObjectType =
3575-
std::map,
3576-
template<typename U, typename... Args> class ArrayType = std::vector,
3577-
class StringType = std::string, class BooleanType = bool,
3578-
class NumberIntegerType = std::int64_t,
3579-
class NumberUnsignedType = std::uint64_t,
3580-
class NumberFloatType = double,
3581-
template<typename U> class AllocatorType = std::allocator,
3582-
template<typename T, typename SFINAE = void> class JSONSerializer =
3583-
adl_serializer,
3584-
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3585-
class CustomBaseClass = void>
3586-
class basic_json;
3562+
/*!
3563+
@brief default JSONSerializer template argument
35873564

3588-
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3589-
/// @sa https://json.nlohmann.me/api/json_pointer/
3590-
template<typename RefStringType>
3591-
class json_pointer;
3565+
This serializer ignores the template arguments and uses ADL
3566+
([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl))
3567+
for serialization.
3568+
*/
3569+
template<typename T = void, typename SFINAE = void>
3570+
struct adl_serializer;
3571+
3572+
/// a class to store JSON values
3573+
/// @sa https://json.nlohmann.me/api/basic_json/
3574+
template<template<typename U, typename V, typename... Args> class ObjectType =
3575+
std::map,
3576+
template<typename U, typename... Args> class ArrayType = std::vector,
3577+
class StringType = std::string, class BooleanType = bool,
3578+
class NumberIntegerType = std::int64_t,
3579+
class NumberUnsignedType = std::uint64_t,
3580+
class NumberFloatType = double,
3581+
template<typename U> class AllocatorType = std::allocator,
3582+
template<typename T, typename SFINAE = void> class JSONSerializer =
3583+
adl_serializer,
3584+
class BinaryType = std::vector<std::uint8_t>, // cppcheck-suppress syntaxError
3585+
class CustomBaseClass = void>
3586+
class basic_json;
3587+
3588+
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
3589+
/// @sa https://json.nlohmann.me/api/json_pointer/
3590+
template<typename RefStringType>
3591+
class json_pointer;
35923592

3593-
/*!
3594-
@brief default specialization
3595-
@sa https://json.nlohmann.me/api/json/
3596-
*/
3597-
using json = basic_json<>;
3593+
/*!
3594+
@brief default specialization
3595+
@sa https://json.nlohmann.me/api/json/
3596+
*/
3597+
using json = basic_json<>;
35983598

3599-
/// @brief a minimal map-like container that preserves insertion order
3600-
/// @sa https://json.nlohmann.me/api/ordered_map/
3601-
template<class Key, class T, class IgnoredLess, class Allocator>
3602-
struct ordered_map;
3599+
/// @brief a minimal map-like container that preserves insertion order
3600+
/// @sa https://json.nlohmann.me/api/ordered_map/
3601+
template<class Key, class T, class IgnoredLess, class Allocator>
3602+
struct ordered_map;
36033603

3604-
/// @brief specialization that maintains the insertion order of object keys
3605-
/// @sa https://json.nlohmann.me/api/ordered_json/
3606-
using ordered_json = basic_json<nlohmann::ordered_map>;
3604+
/// @brief specialization that maintains the insertion order of object keys
3605+
/// @sa https://json.nlohmann.me/api/ordered_json/
3606+
using ordered_json = basic_json<nlohmann::ordered_map>;
36073607

3608-
NLOHMANN_JSON_NAMESPACE_END
3608+
NLOHMANN_JSON_NAMESPACE_END
36093609

36103610
#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_
36113611

@@ -5469,7 +5469,7 @@ NLOHMANN_JSON_NAMESPACE_END
54695469

54705470

54715471
// #include <nlohmann/detail/macro_scope.hpp>
5472-
// JSON_HAS_CPP_17
5472+
// JSON_HAS_CPP_17
54735473
#ifdef JSON_HAS_CPP_17
54745474
#include <optional> // optional
54755475
#endif
@@ -20297,10 +20297,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2029720297
const bool allow_exceptions = true,
2029820298
const bool ignore_comments = false,
2029920299
const bool ignore_trailing_commas = false
20300-
)
20300+
)
2030120301
{
2030220302
return ::nlohmann::detail::parser<basic_json, InputAdapterType>(std::move(adapter),
20303-
std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
20303+
std::move(cb), allow_exceptions, ignore_comments, ignore_trailing_commas);
2030420304
}
2030520305

2030620306
private:
@@ -20998,8 +20998,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2099820998
detail::enable_if_t <
2099920999
!detail::is_basic_json<U>::value && detail::is_compatible_type<basic_json_t, U>::value, int > = 0 >
2100021000
basic_json(CompatibleType && val) noexcept(noexcept( // NOLINT(bugprone-forwarding-reference-overload,bugprone-exception-escape)
21001-
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
21002-
std::forward<CompatibleType>(val))))
21001+
JSONSerializer<U>::to_json(std::declval<basic_json_t&>(),
21002+
std::forward<CompatibleType>(val))))
2100321003
{
2100421004
JSONSerializer<U>::to_json(*this, std::forward<CompatibleType>(val));
2100521005
set_parents();
@@ -21793,7 +21793,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2179321793
detail::has_from_json<basic_json_t, ValueType>::value,
2179421794
int > = 0 >
2179521795
ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept(
21796-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
21796+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), std::declval<ValueType&>())))
2179721797
{
2179821798
auto ret = ValueType();
2179921799
JSONSerializer<ValueType>::from_json(*this, ret);
@@ -21835,7 +21835,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2183521835
detail::has_non_default_from_json<basic_json_t, ValueType>::value,
2183621836
int > = 0 >
2183721837
ValueType get_impl(detail::priority_tag<1> /*unused*/) const noexcept(noexcept(
21838-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
21838+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>())))
2183921839
{
2184021840
return JSONSerializer<ValueType>::from_json(*this);
2184121841
}
@@ -21985,7 +21985,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
2198521985
detail::has_from_json<basic_json_t, ValueType>::value,
2198621986
int > = 0 >
2198721987
ValueType & get_to(ValueType& v) const noexcept(noexcept(
21988-
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
21988+
JSONSerializer<ValueType>::from_json(std::declval<const basic_json_t&>(), v)))
2198921989
{
2199021990
JSONSerializer<ValueType>::from_json(*this, v);
2199121991
return v;

tests/src/unit-serialize_enum_strict.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
#include "../doctest/doctest.h"
33
using json = nlohmann::json;
44

5-
namespace ns {
5+
namespace ns
6+
{
67
enum class Color { red, green, blue, unknown };
78

8-
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(Color, {
9+
NLOHMANN_JSON_SERIALIZE_ENUM_STRICT(Color,
10+
{
911
{ Color::unknown, "unknown" },
1012
{ Color::red, "red" },
1113
{ Color::green, "green" },

0 commit comments

Comments
 (0)