forked from bblanchon/ArduinoJson
Refactoring...
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "JsonPrintable.h"
|
||||
#include "JsonValue.h"
|
||||
|
||||
namespace ArduinoJson
|
||||
{
|
||||
|
@ -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" />
|
||||
|
@ -77,5 +77,8 @@
|
||||
<ClCompile Include="JsonPrettyPrint.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JsonPrintable.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "JsonPrintable.h"
|
||||
#include "JsonValue.h"
|
||||
#include "EscapedString.h"
|
||||
|
||||
namespace ArduinoJson
|
||||
|
29
JsonGenerator/JsonPrintable.cpp
Normal file
29
JsonGenerator/JsonPrintable.cpp
Normal 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);
|
||||
}
|
@ -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;
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user