blob: 724638f92a915a240054dedc62b35060d5602390 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// ArduinoJson - https://arduinojson.org
// Copyright Benoit Blanchon 2014-2021
// MIT License
#pragma once
#include <Arduino.h>
namespace ARDUINOJSON_NAMESPACE {
template <typename TSource>
struct Reader<TSource,
typename enable_if<is_base_of<Stream, TSource>::value>::type> {
public:
explicit Reader(Stream& stream) : _stream(&stream) {}
int read() {
// don't use _stream.read() as it ignores the timeout
char c;
return _stream->readBytes(&c, 1) ? static_cast<unsigned char>(c) : -1;
}
size_t readBytes(char* buffer, size_t length) {
return _stream->readBytes(buffer, length);
}
private:
Stream* _stream;
};
} // namespace ARDUINOJSON_NAMESPACE
|