From 3ae732768755664fd054e841a76e512c736afc45 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 26 Aug 2014 10:08:54 +0200 Subject: [PATCH] Renamed PrettyPrintDecorator into JsonPrettyPrint --- JsonGenerator/JsonGenerator.vcxproj | 4 ++-- JsonGenerator/JsonGenerator.vcxproj.filters | 8 +++---- ...PrintDecorator.cpp => JsonPrettyPrint.cpp} | 24 +++++++++---------- ...ettyPrintDecorator.h => JsonPrettyPrint.h} | 4 ++-- JsonGenerator/JsonPrintable.h | 4 ++-- .../PrettyPrint_Array_Tests.cpp | 4 ++-- .../PrettyPrint_Object_Tests.cpp | 4 ++-- .../PrettyPrint_String_Tests.cpp | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) rename JsonGenerator/{PrettyPrintDecorator.cpp => JsonPrettyPrint.cpp} (63%) rename JsonGenerator/{PrettyPrintDecorator.h => JsonPrettyPrint.h} (87%) diff --git a/JsonGenerator/JsonGenerator.vcxproj b/JsonGenerator/JsonGenerator.vcxproj index f51ddb92..bbbb623b 100644 --- a/JsonGenerator/JsonGenerator.vcxproj +++ b/JsonGenerator/JsonGenerator.vcxproj @@ -13,7 +13,7 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/JsonGenerator/JsonGenerator.vcxproj.filters b/JsonGenerator/JsonGenerator.vcxproj.filters index fe8df2dd..9046b7e3 100644 --- a/JsonGenerator/JsonGenerator.vcxproj.filters +++ b/JsonGenerator/JsonGenerator.vcxproj.filters @@ -45,10 +45,10 @@ Header Files - + Header Files - + Header Files @@ -71,10 +71,10 @@ Source Files - + Source Files - + Source Files diff --git a/JsonGenerator/PrettyPrintDecorator.cpp b/JsonGenerator/JsonPrettyPrint.cpp similarity index 63% rename from JsonGenerator/PrettyPrintDecorator.cpp rename to JsonGenerator/JsonPrettyPrint.cpp index 65280b70..defa8617 100644 --- a/JsonGenerator/PrettyPrintDecorator.cpp +++ b/JsonGenerator/JsonPrettyPrint.cpp @@ -3,18 +3,18 @@ * Benoit Blanchon 2014 - MIT License */ -#include "PrettyPrintDecorator.h" +#include "JsonPrettyPrint.h" using namespace ArduinoJson::Generator; -size_t PrettyPrintDecorator::write(uint8_t c) +size_t JsonPrettyPrint::write(uint8_t c) { size_t n = inString ? handleStringChar(c) : handleMarkupChar(c); previousChar = c; return n; } -size_t PrettyPrintDecorator::handleStringChar(uint8_t c) +size_t JsonPrettyPrint::handleStringChar(uint8_t c) { bool isQuote = c == '"' && previousChar != '\\'; @@ -23,7 +23,7 @@ size_t PrettyPrintDecorator::handleStringChar(uint8_t c) return sink.write(c); } -size_t PrettyPrintDecorator::handleMarkupChar(uint8_t c) +size_t JsonPrettyPrint::handleMarkupChar(uint8_t c) { switch (c) { @@ -49,38 +49,38 @@ size_t PrettyPrintDecorator::handleMarkupChar(uint8_t c) } } -size_t PrettyPrintDecorator::handleBlockOpen(uint8_t c) +size_t JsonPrettyPrint::handleBlockOpen(uint8_t c) { return indentIfNeeded() + sink.write(c); } -size_t PrettyPrintDecorator::handleBlockClose(uint8_t c) +size_t JsonPrettyPrint::handleBlockClose(uint8_t c) { return unindentIfNeeded() + sink.write(c); } -size_t PrettyPrintDecorator::handleColumn() +size_t JsonPrettyPrint::handleColumn() { return sink.write(':') + sink.write(' '); } -size_t PrettyPrintDecorator::handleComma() +size_t JsonPrettyPrint::handleComma() { return sink.write(',') + sink.println(); } -size_t PrettyPrintDecorator::handleQuoteOpen() +size_t JsonPrettyPrint::handleQuoteOpen() { inString = true; return indentIfNeeded() + sink.write('"'); } -size_t PrettyPrintDecorator::handleNormalChar(uint8_t c) +size_t JsonPrettyPrint::handleNormalChar(uint8_t c) { return indentIfNeeded() + sink.write(c); } -size_t PrettyPrintDecorator::indentIfNeeded() +size_t JsonPrettyPrint::indentIfNeeded() { if (!inEmptyBlock()) return 0; @@ -88,7 +88,7 @@ size_t PrettyPrintDecorator::indentIfNeeded() return sink.println(); } -size_t PrettyPrintDecorator::unindentIfNeeded() +size_t JsonPrettyPrint::unindentIfNeeded() { if (inEmptyBlock()) return 0; diff --git a/JsonGenerator/PrettyPrintDecorator.h b/JsonGenerator/JsonPrettyPrint.h similarity index 87% rename from JsonGenerator/PrettyPrintDecorator.h rename to JsonGenerator/JsonPrettyPrint.h index b28018eb..4c98c489 100644 --- a/JsonGenerator/PrettyPrintDecorator.h +++ b/JsonGenerator/JsonPrettyPrint.h @@ -12,11 +12,11 @@ namespace ArduinoJson { namespace Generator { - class PrettyPrintDecorator : public Print + class JsonPrettyPrint : public Print { public: - PrettyPrintDecorator(IndentedPrint& p) + JsonPrettyPrint(IndentedPrint& p) : sink(p) { previousChar = 0; diff --git a/JsonGenerator/JsonPrintable.h b/JsonGenerator/JsonPrintable.h index 10e58c49..cac48599 100644 --- a/JsonGenerator/JsonPrintable.h +++ b/JsonGenerator/JsonPrintable.h @@ -8,7 +8,7 @@ #include "JsonValue.h" #include "Print.h" #include "Printable.h" -#include "PrettyPrintDecorator.h" +#include "JsonPrettyPrint.h" namespace ArduinoJson { @@ -28,7 +28,7 @@ namespace ArduinoJson size_t prettyPrintTo(IndentedPrint& p) const { - PrettyPrintDecorator decorator(p); + JsonPrettyPrint decorator(p); return printTo(decorator); } diff --git a/JsonGeneratorTests/PrettyPrint_Array_Tests.cpp b/JsonGeneratorTests/PrettyPrint_Array_Tests.cpp index 549733dd..e60b1b25 100644 --- a/JsonGeneratorTests/PrettyPrint_Array_Tests.cpp +++ b/JsonGeneratorTests/PrettyPrint_Array_Tests.cpp @@ -4,7 +4,7 @@ */ #include "CppUnitTest.h" -#include "PrettyPrintDecorator.h" +#include "JsonPrettyPrint.h" #include "StringBuilder.h" using namespace ArduinoJson::Internals; @@ -77,7 +77,7 @@ namespace JsonGeneratorTests { StringBuilder sb(buffer, sizeof(buffer)); IndentedPrint indentedPrint(sb); - PrettyPrintDecorator decorator(indentedPrint); + JsonPrettyPrint decorator(indentedPrint); returnValue = decorator.print(input); } diff --git a/JsonGeneratorTests/PrettyPrint_Object_Tests.cpp b/JsonGeneratorTests/PrettyPrint_Object_Tests.cpp index d0a693c4..6efad33f 100644 --- a/JsonGeneratorTests/PrettyPrint_Object_Tests.cpp +++ b/JsonGeneratorTests/PrettyPrint_Object_Tests.cpp @@ -4,7 +4,7 @@ */ #include "CppUnitTest.h" -#include "PrettyPrintDecorator.h" +#include "JsonPrettyPrint.h" #include "StringBuilder.h" using namespace ArduinoJson::Internals; @@ -75,7 +75,7 @@ namespace JsonGeneratorTests { StringBuilder sb(buffer, sizeof(buffer)); IndentedPrint indentedPrint(sb); - PrettyPrintDecorator decorator(indentedPrint); + JsonPrettyPrint decorator(indentedPrint); returnValue = decorator.print(input); } diff --git a/JsonGeneratorTests/PrettyPrint_String_Tests.cpp b/JsonGeneratorTests/PrettyPrint_String_Tests.cpp index 70b02dab..a6660973 100644 --- a/JsonGeneratorTests/PrettyPrint_String_Tests.cpp +++ b/JsonGeneratorTests/PrettyPrint_String_Tests.cpp @@ -4,7 +4,7 @@ */ #include "CppUnitTest.h" -#include "PrettyPrintDecorator.h" +#include "JsonPrettyPrint.h" #include "StringBuilder.h" using namespace ArduinoJson::Internals; @@ -62,7 +62,7 @@ namespace JsonGeneratorTests { StringBuilder sb(buffer, sizeof(buffer)); IndentedPrint indentedPrint(sb); - PrettyPrintDecorator decorator(indentedPrint); + JsonPrettyPrint decorator(indentedPrint); returnValue = decorator.print(input); }