Removed Print class and converted printTo() to a template method (issue #276)

This commit is contained in:
Benoit Blanchon
2017-04-22 11:33:40 +02:00
parent c3e1677b7d
commit 9afa05e2f4
19 changed files with 147 additions and 173 deletions

View File

@@ -11,22 +11,25 @@
#if ARDUINOJSON_ENABLE_STD_STREAM
#include "../Print.hpp"
#include <ostream>
namespace ArduinoJson {
namespace Internals {
class StreamPrintAdapter : public Print {
class StreamPrintAdapter {
public:
explicit StreamPrintAdapter(std::ostream& os) : _os(os) {}
virtual size_t write(uint8_t c) {
_os << static_cast<char>(c);
size_t print(char c) {
_os << c;
return 1;
}
size_t print(const char* s) {
_os << s;
return strlen(s);
}
private:
// cannot be assigned
StreamPrintAdapter& operator=(const StreamPrintAdapter&);