Files
ArduinoJson/JsonGenerator/JsonPrintable.h

40 lines
1.3 KiB
C
Raw Normal View History

2014-06-25 13:23:08 +02:00
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
2014-07-01 13:36:22 +02:00
#include "Print.h"
2014-07-01 13:44:36 +02:00
#include "Printable.h"
2014-08-26 10:13:49 +02:00
#include "IndentedPrint.h"
2014-06-25 13:23:08 +02:00
2014-07-03 13:54:27 +02:00
namespace ArduinoJson
2014-06-25 13:23:08 +02:00
{
2014-07-03 13:54:27 +02:00
namespace Generator
2014-06-26 13:39:05 +02:00
{
2014-09-01 21:36:09 +02:00
// Contains methods to generate a JSON string.
// Implemented by both JsonObject and JsonArray
class JsonPrintable : public Printable
2014-07-03 13:54:27 +02:00
{
public:
2014-06-25 13:23:08 +02:00
2014-09-01 21:36:09 +02:00
// Generates the compact JSON string and sends it to a Print stream
2014-08-26 10:13:49 +02:00
virtual size_t printTo(Print& p) const = 0;
2014-09-01 21:36:09 +02:00
// Generates the compact JSON string and writes it in a buffer
2014-09-01 21:22:56 +02:00
size_t printTo(char* buffer, size_t bufferSize) const;
2014-09-01 21:36:09 +02:00
// Generates the indented JSON string and sends it to a Print stream
2014-08-26 10:13:49 +02:00
size_t prettyPrintTo(Print& p) const;
2014-09-01 21:36:09 +02:00
// 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
2014-09-01 21:22:56 +02:00
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
2014-07-03 13:54:27 +02:00
};
}
}