forked from bblanchon/ArduinoJson
Added comments
This commit is contained in:
@ -11,6 +11,9 @@ namespace ArduinoJson
|
|||||||
{
|
{
|
||||||
namespace Generator
|
namespace Generator
|
||||||
{
|
{
|
||||||
|
// Decorator on top of Print to allow indented output.
|
||||||
|
// This class is used by JsonPrintable::prettyPrintTo() but can also be used
|
||||||
|
// for your own purpose, like logging.
|
||||||
class IndentedPrint : public Print
|
class IndentedPrint : public Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -25,8 +28,13 @@ namespace ArduinoJson
|
|||||||
|
|
||||||
virtual size_t write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
|
|
||||||
|
// Adds one level of indentation
|
||||||
void indent();
|
void indent();
|
||||||
|
|
||||||
|
// Removes one level of indentation
|
||||||
void unindent();
|
void unindent();
|
||||||
|
|
||||||
|
// Set the number of space printed for each level of indentation
|
||||||
void setTabSize(uint8_t n);
|
void setTabSize(uint8_t n);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -12,6 +12,7 @@ namespace ArduinoJson
|
|||||||
{
|
{
|
||||||
namespace Generator
|
namespace Generator
|
||||||
{
|
{
|
||||||
|
// Converts a compact JSON string into an indented one.
|
||||||
class JsonPrettyPrint : public Print
|
class JsonPrettyPrint : public Print
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -13,16 +13,27 @@ namespace ArduinoJson
|
|||||||
{
|
{
|
||||||
namespace Generator
|
namespace Generator
|
||||||
{
|
{
|
||||||
|
// Contains methods to generate a JSON string.
|
||||||
|
// Implemented by both JsonObject and JsonArray
|
||||||
class JsonPrintable : public Printable
|
class JsonPrintable : public Printable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Generates the compact JSON string and sends it to a Print stream
|
||||||
virtual size_t printTo(Print& p) const = 0;
|
virtual size_t printTo(Print& p) const = 0;
|
||||||
|
|
||||||
|
// Generates the compact JSON string and writes it in a buffer
|
||||||
size_t printTo(char* buffer, size_t bufferSize) const;
|
size_t printTo(char* buffer, size_t bufferSize) const;
|
||||||
|
|
||||||
size_t prettyPrintTo(IndentedPrint& p) const;
|
// Generates the indented JSON string and sends it to a Print stream
|
||||||
size_t prettyPrintTo(Print& p) const;
|
size_t prettyPrintTo(Print& p) const;
|
||||||
|
|
||||||
|
// Generates the indented JSON string and sends it to a IndentedPrint stream
|
||||||
|
// This overload allows a finer control of the output because you can customize
|
||||||
|
// the IndentedPrint.
|
||||||
|
size_t prettyPrintTo(IndentedPrint& p) const;
|
||||||
|
|
||||||
|
// Generates the indented JSON string and writes it in a buffer
|
||||||
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
|
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user