Files
ArduinoJson/JsonGenerator/PrettyPrintDecorator.h

51 lines
1.2 KiB
C
Raw Normal View History

/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
#include "Print.h"
#include "IndentedPrintDecorator.h"
namespace ArduinoJson
{
namespace Generator
{
class PrettyPrintDecorator : public Print
{
public:
PrettyPrintDecorator(IndentedPrintDecorator& p)
: sink(p)
{
previousChar = 0;
inString = false;
}
virtual size_t write(uint8_t);
2014-08-25 09:52:42 +02:00
private:
uint8_t previousChar;
IndentedPrintDecorator& sink;
bool inString;
2014-08-25 12:41:49 +02:00
bool inEmptyBlock()
{
return previousChar == '{' || previousChar == '[';
}
2014-08-25 13:14:09 +02:00
size_t handleStringChar(uint8_t);
size_t handleMarkupChar(uint8_t);
2014-08-25 13:14:09 +02:00
size_t handleBlockClose(uint8_t);
size_t handleBlockOpen(uint8_t);
size_t handleColumn();
size_t handleComma();
size_t handleQuoteOpen();
size_t handleNormalChar(uint8_t);
size_t indentIfNeeded();
2014-08-26 09:49:59 +02:00
size_t unindentIfNeeded();
};
}
}