Refactoring...

This commit is contained in:
Benoit Blanchon
2014-08-26 10:13:49 +02:00
parent 3ae7327687
commit f127ef6019
6 changed files with 41 additions and 22 deletions

View File

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

View File

@ -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" />

View File

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

View File

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

View File

@ -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);
}

View File

@ -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);
}
size_t prettyPrintTo(Print& p) const
{
IndentedPrint decorator(p);
return printTo(decorator);
}
virtual size_t printTo(Print& p) const = 0;
size_t printTo(char* buffer, size_t bufferSize);
size_t prettyPrintTo(IndentedPrint& p) const;
size_t prettyPrintTo(Print& p) const;
};
}
}