mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 08:48:27 +01:00
Moved .h files to include/
This commit is contained in:
65
include/ArduinoJson/Internals/PrettyJsonWriter.h
Normal file
65
include/ArduinoJson/Internals/PrettyJsonWriter.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include "JsonWriter.h"
|
||||
#include "IndentedPrint.h"
|
||||
|
||||
using namespace ArduinoJson::Generator;
|
||||
|
||||
class PrettyJsonWriter : public JsonWriter
|
||||
{
|
||||
public:
|
||||
explicit PrettyJsonWriter(IndentedPrint* sink)
|
||||
: JsonWriter(sink), _indenter(sink)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void beginArray()
|
||||
{
|
||||
_length += _sink->write('[');
|
||||
indent();
|
||||
}
|
||||
|
||||
virtual void endArray()
|
||||
{
|
||||
unindent();
|
||||
_length += _sink->write(']');
|
||||
}
|
||||
|
||||
virtual void writeColon()
|
||||
{
|
||||
_length += _sink->print(": ");
|
||||
}
|
||||
|
||||
virtual void writeComma()
|
||||
{
|
||||
_length += _sink->write(',');
|
||||
_length += _indenter->println();
|
||||
}
|
||||
|
||||
virtual void beginObject()
|
||||
{
|
||||
_length += _sink->write('{');
|
||||
indent();
|
||||
}
|
||||
|
||||
virtual void endObject()
|
||||
{
|
||||
unindent();
|
||||
_length += _sink->write('}');
|
||||
}
|
||||
|
||||
private:
|
||||
IndentedPrint* _indenter;
|
||||
|
||||
void indent()
|
||||
{
|
||||
_indenter->indent();
|
||||
_length += _indenter->println();
|
||||
}
|
||||
|
||||
void unindent()
|
||||
{
|
||||
_length += _indenter->println();
|
||||
_indenter->unindent();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user