From fe09e0dd6bd08f0a4b4e8eaeae71bb59977f7ce2 Mon Sep 17 00:00:00 2001 From: Evan Driscoll Date: Tue, 5 Jun 2018 22:25:17 -0500 Subject: [PATCH] Overload 'register_style' template instead of awkward multi-naming Hopefully this is an improvement. :-) --- include/nlohmann/detail/output/fancy_serializer.hpp | 6 +++--- single_include/nlohmann/json.hpp | 6 +++--- test/src/unit-fancy-serialization.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/nlohmann/detail/output/fancy_serializer.hpp b/include/nlohmann/detail/output/fancy_serializer.hpp index 3387fdebc..7e57e1c79 100644 --- a/include/nlohmann/detail/output/fancy_serializer.hpp +++ b/include/nlohmann/detail/output/fancy_serializer.hpp @@ -151,7 +151,7 @@ class basic_print_stylizer // Predicate is conceptually 'bool (json)' here template - auto register_style_object_pred( + auto register_style( Predicate p, print_style style = print_style()) -> typename std::enable_if::value, print_style&>::type @@ -172,7 +172,7 @@ class basic_print_stylizer // 'metawrapper'. So if you pass 'bool (json)', it // will look like it can pass a metawrapper to it template - auto register_style_context_pred( + auto register_style( Predicate p, print_style style = print_style()) -> typename std::enable_if < !details::takes_arguments::value, print_style& >::type @@ -189,7 +189,7 @@ class basic_print_stylizer string_t str, print_style style = print_style()) { - return register_style_context_pred([str](const json_pointer_t& pointer) + return register_style([str](const json_pointer_t& pointer) { return (pointer.cbegin() != pointer.cend()) && (*pointer.crbegin() == str); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a3ec2705b..5c7a28de6 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -10956,7 +10956,7 @@ class basic_print_stylizer // Predicate is conceptually 'bool (json)' here template - auto register_style_object_pred( + auto register_style( Predicate p, print_style style = print_style()) -> typename std::enable_if::value, print_style&>::type @@ -10977,7 +10977,7 @@ class basic_print_stylizer // 'metawrapper'. So if you pass 'bool (json)', it // will look like it can pass a metawrapper to it template - auto register_style_context_pred( + auto register_style( Predicate p, print_style style = print_style()) -> typename std::enable_if < !details::takes_arguments::value, print_style& >::type @@ -10994,7 +10994,7 @@ class basic_print_stylizer string_t str, print_style style = print_style()) { - return register_style_context_pred([str](const json_pointer_t& pointer) + return register_style([str](const json_pointer_t& pointer) { return (pointer.cbegin() != pointer.cend()) && (*pointer.crbegin() == str); diff --git a/test/src/unit-fancy-serialization.cpp b/test/src/unit-fancy-serialization.cpp index 6299bfef2..99aec3bd1 100644 --- a/test/src/unit-fancy-serialization.cpp +++ b/test/src/unit-fancy-serialization.cpp @@ -286,7 +286,7 @@ TEST_CASE("serialization") print_stylizer stylizer; stylizer.get_default_style() = print_style::preset_multiline; - stylizer.register_style_context_pred( + stylizer.register_style( [] (const json_pointer& context) { // Matches if context[-2] is "each elem on one line" @@ -332,7 +332,7 @@ TEST_CASE("serialization") print_stylizer stylizer; stylizer.get_default_style() = print_style::preset_multiline; - stylizer.register_style_object_pred( + stylizer.register_style( [] (const json & j) { return j.type() == json::value_t::array;