mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
34 lines
689 B
C++
34 lines
689 B
C++
// ArduinoJson - https://arduinojson.org
|
|
// Copyright © 2014-2022, Benoit BLANCHON
|
|
// MIT License
|
|
|
|
#pragma once
|
|
|
|
#include <ostream>
|
|
|
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
|
|
|
template <typename TDestination>
|
|
class Writer<
|
|
TDestination,
|
|
typename enable_if<is_base_of<std::ostream, TDestination>::value>::type> {
|
|
public:
|
|
explicit Writer(std::ostream& os) : _os(&os) {}
|
|
|
|
size_t write(uint8_t c) {
|
|
_os->put(static_cast<char>(c));
|
|
return 1;
|
|
}
|
|
|
|
size_t write(const uint8_t* s, size_t n) {
|
|
_os->write(reinterpret_cast<const char*>(s),
|
|
static_cast<std::streamsize>(n));
|
|
return n;
|
|
}
|
|
|
|
private:
|
|
std::ostream* _os;
|
|
};
|
|
|
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|