Line | |
---|
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 "../Arduino/Print.hpp"
|
---|
11 | #include "../Arduino/String.hpp"
|
---|
12 |
|
---|
13 | namespace ArduinoJson {
|
---|
14 | namespace Internals {
|
---|
15 |
|
---|
16 | // A Print implementation that allows to write in a String
|
---|
17 | class DynamicStringBuilder : public Print {
|
---|
18 | public:
|
---|
19 | DynamicStringBuilder(String &str) : _str(str) {}
|
---|
20 |
|
---|
21 | virtual size_t write(uint8_t c) {
|
---|
22 | // Need to cast to char, otherwise String will print a number (issue #120)
|
---|
23 | _str += static_cast<char>(c);
|
---|
24 | return 1;
|
---|
25 | }
|
---|
26 |
|
---|
27 | private:
|
---|
28 | DynamicStringBuilder &operator=(const DynamicStringBuilder &);
|
---|
29 |
|
---|
30 | String &_str;
|
---|
31 | };
|
---|
32 | }
|
---|
33 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.