Files
ArduinoJson/JsonGenerator/IndentedPrint.h

46 lines
941 B
C
Raw Normal View History

/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
#include "Print.h"
namespace ArduinoJson
{
namespace Generator
{
class IndentedPrint : public Print
{
public:
IndentedPrint(Print& p)
: sink(p)
{
level = 0;
2014-08-26 11:59:41 +02:00
tabSize = 2;
isNewLine = true;
}
virtual size_t write(uint8_t);
2014-08-26 09:53:32 +02:00
void indent();
void unindent();
2014-08-26 11:58:33 +02:00
void setTabSize(uint8_t n);
private:
Print& sink;
2014-08-26 11:58:33 +02:00
uint8_t level : 4;
uint8_t tabSize : 3;
bool isNewLine : 1;
2014-08-26 11:58:33 +02:00
size_t writeTabs();
2014-08-26 11:58:33 +02:00
2014-08-26 12:03:50 +02:00
static const int MAX_LEVEL = 15; // because it's only 4 bits
static const int MAX_TAB_SIZE = 7; // because it's only 3 bits
};
}
}