From e2974c38e4153d3a23790519305aeaead65b6675 Mon Sep 17 00:00:00 2001 From: Evan Driscoll Date: Tue, 5 Jun 2018 22:51:11 -0500 Subject: [PATCH] Rename fancy->styled --- .../detail/output/fancy_serializer.hpp | 22 +++---- include/nlohmann/json.hpp | 2 +- single_include/nlohmann/json.hpp | 24 ++++---- test/src/unit-fancy-serialization.cpp | 60 +++++++++---------- 4 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/nlohmann/detail/output/fancy_serializer.hpp b/include/nlohmann/detail/output/fancy_serializer.hpp index 7e57e1c79..6033035dc 100644 --- a/include/nlohmann/detail/output/fancy_serializer.hpp +++ b/include/nlohmann/detail/output/fancy_serializer.hpp @@ -214,7 +214,7 @@ namespace detail /////////////////// template -class fancy_serializer +class styled_serializer { using stylizer_t = basic_print_stylizer; using primitive_serializer_t = primitive_serializer; @@ -231,15 +231,15 @@ class fancy_serializer @param[in] s output stream to serialize to @param[in] ichar indentation character to use */ - fancy_serializer(output_adapter_t s, - const stylizer_t& st) + styled_serializer(output_adapter_t s, + const stylizer_t& st) : o(std::move(s)), stylizer(st), indent_string(512, st.get_default_style().indent_char) {} // delete because of pointer members - fancy_serializer(const fancy_serializer&) = delete; - fancy_serializer& operator=(const fancy_serializer&) = delete; + styled_serializer(const styled_serializer&) = delete; + styled_serializer& operator=(const styled_serializer&) = delete; void dump(const BasicJsonType& val, const bool ensure_ascii) { @@ -517,7 +517,7 @@ class fancy_serializer } private: - /// the output of the fancy_serializer + /// the output of the styled_serializer output_adapter_t o = nullptr; /// Used for serializing "base" objects. Strings are sort of @@ -533,20 +533,20 @@ class fancy_serializer } template -std::ostream& fancy_dump(std::ostream& o, const BasicJsonType& j, - basic_print_stylizer const& stylizer) +std::ostream& styled_dump(std::ostream& o, const BasicJsonType& j, + basic_print_stylizer const& stylizer) { // do the actual serialization - detail::fancy_serializer s(detail::output_adapter(o), stylizer); + detail::styled_serializer s(detail::output_adapter(o), stylizer); s.dump(j, false); return o; } template -std::ostream& fancy_dump(std::ostream& o, const BasicJsonType& j, print_style style) +std::ostream& styled_dump(std::ostream& o, const BasicJsonType& j, print_style style) { basic_print_stylizer stylizer(style); - return fancy_dump(o, j, stylizer); + return styled_dump(o, j, stylizer); } } diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index bfe032045..4512ad746 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -167,7 +167,7 @@ class basic_json friend ::nlohmann::json_pointer; friend ::nlohmann::detail::parser; friend ::nlohmann::detail::serializer; - friend ::nlohmann::detail::fancy_serializer; + friend ::nlohmann::detail::styled_serializer; template friend class ::nlohmann::detail::iter_impl; template diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5c7a28de6..405cc80ee 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -11019,7 +11019,7 @@ namespace detail /////////////////// template -class fancy_serializer +class styled_serializer { using stylizer_t = basic_print_stylizer; using primitive_serializer_t = primitive_serializer; @@ -11036,15 +11036,15 @@ class fancy_serializer @param[in] s output stream to serialize to @param[in] ichar indentation character to use */ - fancy_serializer(output_adapter_t s, - const stylizer_t& st) + styled_serializer(output_adapter_t s, + const stylizer_t& st) : o(std::move(s)), stylizer(st), indent_string(512, st.get_default_style().indent_char) {} // delete because of pointer members - fancy_serializer(const fancy_serializer&) = delete; - fancy_serializer& operator=(const fancy_serializer&) = delete; + styled_serializer(const styled_serializer&) = delete; + styled_serializer& operator=(const styled_serializer&) = delete; void dump(const BasicJsonType& val, const bool ensure_ascii) { @@ -11322,7 +11322,7 @@ class fancy_serializer } private: - /// the output of the fancy_serializer + /// the output of the styled_serializer output_adapter_t o = nullptr; /// Used for serializing "base" objects. Strings are sort of @@ -11338,20 +11338,20 @@ class fancy_serializer } template -std::ostream& fancy_dump(std::ostream& o, const BasicJsonType& j, - basic_print_stylizer const& stylizer) +std::ostream& styled_dump(std::ostream& o, const BasicJsonType& j, + basic_print_stylizer const& stylizer) { // do the actual serialization - detail::fancy_serializer s(detail::output_adapter(o), stylizer); + detail::styled_serializer s(detail::output_adapter(o), stylizer); s.dump(j, false); return o; } template -std::ostream& fancy_dump(std::ostream& o, const BasicJsonType& j, print_style style) +std::ostream& styled_dump(std::ostream& o, const BasicJsonType& j, print_style style) { basic_print_stylizer stylizer(style); - return fancy_dump(o, j, stylizer); + return styled_dump(o, j, stylizer); } } @@ -11570,7 +11570,7 @@ class basic_json friend ::nlohmann::json_pointer; friend ::nlohmann::detail::parser; friend ::nlohmann::detail::serializer; - friend ::nlohmann::detail::fancy_serializer; + friend ::nlohmann::detail::styled_serializer; template friend class ::nlohmann::detail::iter_impl; template diff --git a/test/src/unit-fancy-serialization.cpp b/test/src/unit-fancy-serialization.cpp index 99aec3bd1..197a75257 100644 --- a/test/src/unit-fancy-serialization.cpp +++ b/test/src/unit-fancy-serialization.cpp @@ -34,7 +34,7 @@ SOFTWARE. using nlohmann::json; using nlohmann::json_pointer; -using nlohmann::fancy_dump; +using nlohmann::styled_dump; using nlohmann::print_style; using nlohmann::print_stylizer; @@ -73,17 +73,17 @@ std::string dedent(const char* str) return ans; } -std::string fancy_to_string(json j, print_style style = print_style()) +std::string styled_to_string(json j, print_style style = print_style()) { std::stringstream ss; - fancy_dump(ss, j, style); + styled_dump(ss, j, style); return ss.str(); } -std::string fancy_to_string(json j, print_stylizer stylizer) +std::string styled_to_string(json j, print_stylizer stylizer) { std::stringstream ss; - fancy_dump(ss, j, stylizer); + styled_dump(ss, j, stylizer); return ss.str(); } @@ -93,31 +93,31 @@ TEST_CASE("serialization") { SECTION("null") { - auto str = fancy_to_string({}); + auto str = styled_to_string({}); CHECK(str == "null"); } SECTION("true") { - auto str = fancy_to_string(true); + auto str = styled_to_string(true); CHECK(str == "true"); } SECTION("false") { - auto str = fancy_to_string(false); + auto str = styled_to_string(false); CHECK(str == "false"); } SECTION("integer") { - auto str = fancy_to_string(10); + auto str = styled_to_string(10); CHECK(str == "10"); } SECTION("floating point") { - auto str = fancy_to_string(7.5); + auto str = styled_to_string(7.5); CHECK(str == "7.5"); } } @@ -126,7 +126,7 @@ TEST_CASE("serialization") { SECTION("long strings usually print") { - auto str = fancy_to_string( + auto str = styled_to_string( "The quick brown fox jumps over the lazy brown dog"); CHECK(str == "\"The quick brown fox jumps over the lazy brown dog\""); @@ -137,7 +137,7 @@ TEST_CASE("serialization") print_style style; style.strings_maximum_length = 10; - auto str = fancy_to_string( + auto str = styled_to_string( "The quick brown fox jumps over the lazy brown dog", style); CHECK(str == "\"The qu...g\""); @@ -160,7 +160,7 @@ TEST_CASE("serialization") { print_style style; style.strings_maximum_length = test.first; - auto str = fancy_to_string(quick, style); + auto str = styled_to_string(quick, style); CHECK(str == test.second); } } @@ -170,7 +170,7 @@ TEST_CASE("serialization") print_style style; style.strings_maximum_length = 0; - auto str = fancy_to_string( + auto str = styled_to_string( "The quick brown fox jumps over the lazy brown dog", style); CHECK(str == @@ -182,7 +182,7 @@ TEST_CASE("serialization") print_style style; style.strings_maximum_length = 100; - auto str = fancy_to_string( + auto str = styled_to_string( "The quick brown fox jumps over the lazy brown dog", style); CHECK(str == @@ -200,12 +200,12 @@ TEST_CASE("serialization") print_style style; style.depth_limit = 1; - auto str_flat = fancy_to_string({1, {1}}, style); + auto str_flat = styled_to_string({1, {1}}, style); CHECK(str_flat == "[1,[...]]"); style = print_style::preset_multiline; style.depth_limit = 1; - auto str_lines = fancy_to_string({1, {1}}, style); + auto str_lines = styled_to_string({1, {1}}, style); CHECK(str_lines == dedent(R"( [ 1, @@ -218,12 +218,12 @@ TEST_CASE("serialization") print_style style; style.depth_limit = 1; - auto str_flat = fancy_to_string({1, {{"one", 1}}}, style); + auto str_flat = styled_to_string({1, {{"one", 1}}}, style); CHECK(str_flat == "[1,{...}]"); style = print_style::preset_multiline; style.depth_limit = 1; - auto str_lines = fancy_to_string({1, {{"one", 1}}}, style); + auto str_lines = styled_to_string({1, {{"one", 1}}}, style); CHECK(str_lines == dedent(R"( [ 1, @@ -240,7 +240,7 @@ TEST_CASE("serialization") stylizer.get_default_style() = print_style::preset_multiline; stylizer.register_key_matcher_style("one line"); - auto str = fancy_to_string( + auto str = styled_to_string( { { "one line", {1, 2} @@ -267,7 +267,7 @@ TEST_CASE("serialization") stylizer.get_default_style() = print_style::preset_multiline; stylizer.register_key_matcher_style("one line"); - auto str = fancy_to_string( + auto str = styled_to_string( { { "one line", {{"still one line", {1, 2}}} @@ -295,7 +295,7 @@ TEST_CASE("serialization") } ).space_after_comma = true; - auto str = fancy_to_string( + auto str = styled_to_string( { { "each elem on one line", { @@ -339,7 +339,7 @@ TEST_CASE("serialization") } ) = print_style::preset_one_line; - auto str = fancy_to_string( + auto str = styled_to_string( { { "an array", {1, 2, 3} @@ -366,7 +366,7 @@ TEST_CASE("serialization") { print_style style; style.space_after_comma = true; - auto str = fancy_to_string({1, 2, 3}, style); + auto str = styled_to_string({1, 2, 3}, style); CHECK(str == "[1, 2, 3]"); } @@ -374,7 +374,7 @@ TEST_CASE("serialization") { print_style style; style.space_after_colon = true; - auto str = fancy_to_string({{"one", 1}}, style); + auto str = styled_to_string({{"one", 1}}, style); CHECK(str == "{\"one\": 1}"); } @@ -382,7 +382,7 @@ TEST_CASE("serialization") { print_style style = print_style::preset_multiline; style.space_after_colon = false; - auto str = fancy_to_string({{"one", 1}}, style); + auto str = styled_to_string({{"one", 1}}, style); CHECK(str == dedent(R"( { "one":1 @@ -394,7 +394,7 @@ TEST_CASE("serialization") SECTION("given width") { print_style style = print_style::preset_multiline; - auto str = fancy_to_string({"foo", 1, 2, 3, false, {{"one", 1}}}, style); + auto str = styled_to_string({"foo", 1, 2, 3, false, {{"one", 1}}}, style); CHECK(str == dedent(R"( [ "foo", @@ -414,7 +414,7 @@ TEST_CASE("serialization") style.indent_step = 1; style.indent_char = '\t'; - auto str = fancy_to_string({"foo", 1, 2, 3, false, {{"one", 1}}}, style); + auto str = styled_to_string({"foo", 1, 2, 3, false, {{"one", 1}}}, style); CHECK(str == "[\n" "\t\"foo\",\n" @@ -435,7 +435,7 @@ TEST_CASE("serialization") style.indent_step = 300; style.indent_char = 'X'; - auto str = fancy_to_string({1, {1}}, style); + auto str = styled_to_string({1, {1}}, style); std::string indent(300, 'X'); CHECK(str == @@ -453,7 +453,7 @@ TEST_CASE("serialization") style.indent_step = 300; style.indent_char = 'X'; - auto str = fancy_to_string({{"key", {{"key", 1}}}}, style); + auto str = styled_to_string({{"key", {{"key", 1}}}}, style); std::string indent(300, 'X'); CHECK(str ==