Files
ArduinoJson/extras/tests/Helpers/CustomReader.hpp
T

25 lines
512 B
C++
Raw Normal View History

// ArduinoJson - https://arduinojson.org
2024-01-03 08:47:06 +01:00
// Copyright © 2014-2024, Benoit BLANCHON
2019-10-25 11:39:04 +02:00
// MIT License
#pragma once
#include <sstream>
class CustomReader {
std::stringstream stream_;
2019-10-25 11:39:04 +02:00
public:
CustomReader(const char* input) : stream_(input) {}
CustomReader(const CustomReader&) = delete;
2019-10-25 11:39:04 +02:00
int read() {
return stream_.get();
2019-10-25 11:39:04 +02:00
}
size_t readBytes(char* buffer, size_t length) {
stream_.read(buffer, static_cast<std::streamsize>(length));
return static_cast<size_t>(stream_.gcount());
2019-10-25 11:39:04 +02:00
}
};