From f29904e2179a7848279ec5fc4c21a33304fddf18 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 25 Aug 2014 09:06:21 +0200 Subject: [PATCH] Added skeleton of class IndentedPrintDecorator --- JsonGenerator/IndentedPrintDecorator.cpp | 11 +++++++++ JsonGenerator/IndentedPrintDecorator.h | 26 +++++++++++++++++++++ JsonGenerator/JsonGenerator.vcxproj | 2 ++ JsonGenerator/JsonGenerator.vcxproj.filters | 6 +++++ 4 files changed, 45 insertions(+) create mode 100644 JsonGenerator/IndentedPrintDecorator.cpp create mode 100644 JsonGenerator/IndentedPrintDecorator.h diff --git a/JsonGenerator/IndentedPrintDecorator.cpp b/JsonGenerator/IndentedPrintDecorator.cpp new file mode 100644 index 00000000..51add965 --- /dev/null +++ b/JsonGenerator/IndentedPrintDecorator.cpp @@ -0,0 +1,11 @@ +/* +* Arduino JSON library +* Benoit Blanchon 2014 - MIT License +*/ + +#include "IndentedPrintDecorator.h" + +size_t IndentedPrintDecorator::write(uint8_t c) +{ + return print.write(c); +} \ No newline at end of file diff --git a/JsonGenerator/IndentedPrintDecorator.h b/JsonGenerator/IndentedPrintDecorator.h new file mode 100644 index 00000000..631ea255 --- /dev/null +++ b/JsonGenerator/IndentedPrintDecorator.h @@ -0,0 +1,26 @@ +#pragma once +/* +* Arduino JSON library +* Benoit Blanchon 2014 - MIT License +*/ + +#pragma once + +#include "Print.h" + +class IndentedPrintDecorator : public Print +{ +public: + + IndentedPrintDecorator(Print& p) + : currentLevel(0), print(p) + { + } + + virtual size_t write(uint8_t); + +private: + int currentLevel; + Print& print; +}; + diff --git a/JsonGenerator/JsonGenerator.vcxproj b/JsonGenerator/JsonGenerator.vcxproj index 34d5febc..e1f161af 100644 --- a/JsonGenerator/JsonGenerator.vcxproj +++ b/JsonGenerator/JsonGenerator.vcxproj @@ -12,6 +12,7 @@ + @@ -24,6 +25,7 @@ + diff --git a/JsonGenerator/JsonGenerator.vcxproj.filters b/JsonGenerator/JsonGenerator.vcxproj.filters index d8912d64..e6e350a9 100644 --- a/JsonGenerator/JsonGenerator.vcxproj.filters +++ b/JsonGenerator/JsonGenerator.vcxproj.filters @@ -45,6 +45,9 @@ Header Files + + Header Files + @@ -65,5 +68,8 @@ Source Files + + Source Files + \ No newline at end of file