Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
FlashReader.hpp
00001 // ArduinoJson - arduinojson.org 00002 // Copyright Benoit Blanchon 2014-2021 00003 // MIT License 00004 00005 #pragma once 00006 00007 namespace ARDUINOJSON_NAMESPACE { 00008 00009 template <> 00010 struct Reader<const __FlashStringHelper*, void> { 00011 const char* _ptr; 00012 00013 public: 00014 explicit Reader(const __FlashStringHelper* ptr) 00015 : _ptr(reinterpret_cast<const char*>(ptr)) {} 00016 00017 int read() { 00018 return pgm_read_byte(_ptr++); 00019 } 00020 00021 size_t readBytes(char* buffer, size_t length) { 00022 memcpy_P(buffer, _ptr, length); 00023 _ptr += length; 00024 return length; 00025 } 00026 }; 00027 00028 template <> 00029 struct BoundedReader<const __FlashStringHelper*, void> { 00030 const char* _ptr; 00031 const char* _end; 00032 00033 public: 00034 explicit BoundedReader(const __FlashStringHelper* ptr, size_t size) 00035 : _ptr(reinterpret_cast<const char*>(ptr)), _end(_ptr + size) {} 00036 00037 int read() { 00038 if (_ptr < _end) 00039 return pgm_read_byte(_ptr++); 00040 else 00041 return -1; 00042 } 00043 00044 size_t readBytes(char* buffer, size_t length) { 00045 size_t available = static_cast<size_t>(_end - _ptr); 00046 if (available < length) 00047 length = available; 00048 memcpy_P(buffer, _ptr, length); 00049 _ptr += length; 00050 return length; 00051 } 00052 }; 00053 } // namespace ARDUINOJSON_NAMESPACE
Generated on Wed Jul 13 2022 01:10:36 by
1.7.2