-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prettyfier.h
executable file
·47 lines (37 loc) · 1012 Bytes
/
Prettyfier.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
#include "IndentedPrint.h"
#include "Print.h"
namespace ArduinoJson {
namespace Internals {
// Converts a compact JSON string into an indented one.
class Prettyfier : public Print {
public:
explicit Prettyfier(IndentedPrint& p) : _sink(p) {
_previousChar = 0;
_inString = false;
}
virtual size_t write(uint8_t);
private:
Prettyfier& operator=(const Prettyfier&); // cannot be assigned
bool inEmptyBlock() { return _previousChar == '{' || _previousChar == '['; }
size_t handleStringChar(uint8_t);
size_t handleMarkupChar(uint8_t);
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();
size_t unindentIfNeeded();
uint8_t _previousChar;
IndentedPrint& _sink;
bool _inString;
};
}
}