Epic refactoring int progress...

This commit is contained in:
Benoit Blanchon
2014-10-27 22:50:50 +01:00
parent 8988cb4761
commit 852256c1af
34 changed files with 334 additions and 256 deletions

42
src/JsonPrintable.cpp Normal file
View File

@@ -0,0 +1,42 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#include "ArduinoJson/JsonPrintable.hpp"
#include "ArduinoJson/JsonBuffer.hpp"
#include "ArduinoJson/Internals/StringBuilder.hpp"
#include "ArduinoJson/Internals/CompactJsonWriter.hpp"
#include "ArduinoJson/Internals/PrettyJsonWriter.hpp"
using namespace ArduinoJson;
using namespace ArduinoJson::Internals;
size_t JsonPrintable::printTo(char *buffer, size_t bufferSize) const {
StringBuilder sb(buffer, bufferSize);
return printTo(sb);
}
size_t JsonPrintable::printTo(Print &p) const {
CompactJsonWriter writer(&p);
writeTo(writer);
return writer.bytesWritten();
}
size_t JsonPrintable::prettyPrintTo(char *buffer, size_t bufferSize) const {
StringBuilder sb(buffer, bufferSize);
return prettyPrintTo(sb);
}
size_t JsonPrintable::prettyPrintTo(IndentedPrint &p) const {
PrettyJsonWriter writer(&p);
writeTo(writer);
return writer.bytesWritten();
}
size_t JsonPrintable::prettyPrintTo(Print &print) const {
IndentedPrint indentedPrint = IndentedPrint(print);
return prettyPrintTo(indentedPrint);
}