Files
nixie-clock/firmware/uniclock/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp
T
mangavalkandClaude Opus 5.5 b347f1c63f Import ESP_UniClock (upstream 1189810)
Vendored from https://github.com/gpeter62/ESP_UniClock: the sketch
source, the web UI and the libraries the ESP8266 build needs, unpacked
from the bundled zips. Adds a PlatformIO project for the ESP-12. The
source is unchanged; local changes follow as separate commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 20:48:04 +01:00

56 lines
1.2 KiB
C++

// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// MIT License
#pragma once
#include <Arduino.h>
namespace ARDUINOJSON_NAMESPACE {
template <>
struct Reader<const __FlashStringHelper*, void> {
const char* _ptr;
public:
explicit Reader(const __FlashStringHelper* ptr)
: _ptr(reinterpret_cast<const char*>(ptr)) {}
int read() {
return pgm_read_byte(_ptr++);
}
size_t readBytes(char* buffer, size_t length) {
memcpy_P(buffer, _ptr, length);
_ptr += length;
return length;
}
};
template <>
struct BoundedReader<const __FlashStringHelper*, void> {
const char* _ptr;
const char* _end;
public:
explicit BoundedReader(const __FlashStringHelper* ptr, size_t size)
: _ptr(reinterpret_cast<const char*>(ptr)), _end(_ptr + size) {}
int read() {
if (_ptr < _end)
return pgm_read_byte(_ptr++);
else
return -1;
}
size_t readBytes(char* buffer, size_t length) {
size_t available = static_cast<size_t>(_end - _ptr);
if (available < length)
length = available;
memcpy_P(buffer, _ptr, length);
_ptr += length;
return length;
}
};
} // namespace ARDUINOJSON_NAMESPACE