Rev | Line | |
---|
[209] | 1 | // Copyright Benoit Blanchon 2014-2016
|
---|
| 2 | // MIT License
|
---|
| 3 | //
|
---|
| 4 | // Arduino JSON library
|
---|
| 5 | // https://github.com/bblanchon/ArduinoJson
|
---|
| 6 | // If you like this project, please add a star!
|
---|
| 7 |
|
---|
| 8 | #pragma once
|
---|
| 9 |
|
---|
| 10 | #include "IndentedPrint.hpp"
|
---|
| 11 |
|
---|
| 12 | namespace ArduinoJson {
|
---|
| 13 | namespace Internals {
|
---|
| 14 |
|
---|
| 15 | // Converts a compact JSON string into an indented one.
|
---|
| 16 | class Prettyfier : public Print {
|
---|
| 17 | public:
|
---|
| 18 | explicit Prettyfier(IndentedPrint& p) : _sink(p) {
|
---|
| 19 | _previousChar = 0;
|
---|
| 20 | _inString = false;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | virtual size_t write(uint8_t);
|
---|
| 24 |
|
---|
| 25 | private:
|
---|
| 26 | Prettyfier& operator=(const Prettyfier&); // cannot be assigned
|
---|
| 27 |
|
---|
| 28 | bool inEmptyBlock() { return _previousChar == '{' || _previousChar == '['; }
|
---|
| 29 |
|
---|
| 30 | size_t handleStringChar(uint8_t);
|
---|
| 31 | size_t handleMarkupChar(uint8_t);
|
---|
| 32 |
|
---|
| 33 | size_t handleBlockClose(uint8_t);
|
---|
| 34 | size_t handleBlockOpen(uint8_t);
|
---|
| 35 | size_t handleColon();
|
---|
| 36 | size_t handleComma();
|
---|
| 37 | size_t handleQuoteOpen();
|
---|
| 38 | size_t handleNormalChar(uint8_t);
|
---|
| 39 | size_t indentIfNeeded();
|
---|
| 40 | size_t unindentIfNeeded();
|
---|
| 41 |
|
---|
| 42 | uint8_t _previousChar;
|
---|
| 43 | IndentedPrint& _sink;
|
---|
| 44 | bool _inString;
|
---|
| 45 | };
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.