CustomReader.hpp 502 B

1234567891011121314151617181920212223242526
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #pragma once
  5. #include <sstream>
  6. class CustomReader {
  7. std::stringstream _stream;
  8. public:
  9. CustomReader(const char* input) : _stream(input) {}
  10. int read() {
  11. return _stream.get();
  12. }
  13. size_t readBytes(char* buffer, size_t length) {
  14. _stream.read(buffer, static_cast<std::streamsize>(length));
  15. return static_cast<size_t>(_stream.gcount());
  16. }
  17. private:
  18. CustomReader(const CustomReader&);
  19. };