Benoit Blanchon 11 лет назад
Родитель
Сommit
f127ef6019

+ 1 - 0
JsonGenerator/JsonArrayBase.h

@@ -6,6 +6,7 @@
 #pragma once
 
 #include "JsonPrintable.h"
+#include "JsonValue.h"
 
 namespace ArduinoJson
 {

+ 1 - 0
JsonGenerator/JsonGenerator.vcxproj

@@ -30,6 +30,7 @@
     <ClCompile Include="JsonPrettyPrint.cpp" />
     <ClCompile Include="JsonArrayBase.cpp" />
     <ClCompile Include="JsonObjectBase.cpp" />
+    <ClCompile Include="JsonPrintable.cpp" />
     <ClCompile Include="JsonValue.cpp" />
     <ClCompile Include="Print.cpp" />
     <ClCompile Include="StringBuilder.cpp" />

+ 3 - 0
JsonGenerator/JsonGenerator.vcxproj.filters

@@ -77,5 +77,8 @@
     <ClCompile Include="JsonPrettyPrint.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="JsonPrintable.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 1 - 0
JsonGenerator/JsonObjectBase.h

@@ -6,6 +6,7 @@
 #pragma once
 
 #include "JsonPrintable.h"
+#include "JsonValue.h"
 #include "EscapedString.h"
 
 namespace ArduinoJson

+ 29 - 0
JsonGenerator/JsonPrintable.cpp

@@ -0,0 +1,29 @@
+/*
+* Arduino JSON library
+* Benoit Blanchon 2014 - MIT License
+*/
+
+#include "JsonPrintable.h"
+#include "JsonPrettyPrint.h"
+#include "StringBuilder.h"
+
+using namespace ArduinoJson::Generator;
+using namespace ArduinoJson::Internals;
+
+size_t JsonPrintable::printTo(char* buffer, size_t bufferSize)
+{
+    StringBuilder sb(buffer, bufferSize);
+    return printTo(sb);
+}
+
+size_t JsonPrintable::prettyPrintTo(IndentedPrint& p) const
+{
+    JsonPrettyPrint prettyPrint(p);
+    return printTo(prettyPrint);
+}
+
+size_t JsonPrintable::prettyPrintTo(Print& p) const
+{
+    IndentedPrint indentedPrint(p);
+    return printTo(indentedPrint);
+}

+ 5 - 21
JsonGenerator/JsonPrintable.h

@@ -5,10 +5,9 @@
 
 #pragma once
 
-#include "JsonValue.h"
 #include "Print.h"
 #include "Printable.h"
-#include "JsonPrettyPrint.h"
+#include "IndentedPrint.h"
 
 namespace ArduinoJson
 {
@@ -18,27 +17,12 @@ namespace ArduinoJson
         {
         public:
 
-            size_t printTo(char* buffer, size_t bufferSize)
-            {
-                using namespace Internals;
-
-                StringBuilder sb(buffer, bufferSize);
-                return printTo(sb);
-            }
-
-            size_t prettyPrintTo(IndentedPrint& p) const
-            {
-                JsonPrettyPrint decorator(p);
-                return printTo(decorator);
-            }
+            virtual size_t printTo(Print& p) const = 0;
 
-            size_t prettyPrintTo(Print& p) const
-            {
-                IndentedPrint decorator(p);
-                return printTo(decorator);
-            }
+            size_t printTo(char* buffer, size_t bufferSize);
 
-            virtual size_t printTo(Print& p) const = 0;
+            size_t prettyPrintTo(IndentedPrint& p) const;
+            size_t prettyPrintTo(Print& p) const;
         };
     }
 }