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 | #include "../../include/ArduinoJson/Internals/IndentedPrint.hpp"
|
---|
| 9 |
|
---|
| 10 | using namespace ArduinoJson::Internals;
|
---|
| 11 |
|
---|
| 12 | size_t IndentedPrint::write(uint8_t c) {
|
---|
| 13 | size_t n = 0;
|
---|
| 14 |
|
---|
| 15 | if (isNewLine) n += writeTabs();
|
---|
| 16 |
|
---|
| 17 | n += sink->write(c);
|
---|
| 18 |
|
---|
| 19 | isNewLine = c == '\n';
|
---|
| 20 |
|
---|
| 21 | return n;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | inline size_t IndentedPrint::writeTabs() {
|
---|
| 25 | size_t n = 0;
|
---|
| 26 |
|
---|
| 27 | for (int i = 0; i < level * tabSize; i++) n += sink->write(' ');
|
---|
| 28 |
|
---|
| 29 | return n;
|
---|
| 30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.