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.
Diff: src/ArduinoJson/Deserialization/Readers/RamReader.hpp
- Revision:
- 0:18ba3960b5dd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ArduinoJson/Deserialization/Readers/RamReader.hpp Fri Mar 19 19:30:50 2021 +0000
@@ -0,0 +1,50 @@
+// ArduinoJson - arduinojson.org
+// Copyright Benoit Blanchon 2014-2021
+// MIT License
+
+#pragma once
+
+#include <ArduinoJson/Polyfills/type_traits.hpp>
+
+namespace ARDUINOJSON_NAMESPACE {
+
+template <typename T>
+struct IsCharOrVoid {
+ static const bool value =
+ is_same<T, void>::value || is_same<T, char>::value ||
+ is_same<T, unsigned char>::value || is_same<T, signed char>::value;
+};
+
+template <typename T>
+struct IsCharOrVoid<const T> : IsCharOrVoid<T> {};
+
+template <typename TSource>
+struct Reader<TSource*,
+ typename enable_if<IsCharOrVoid<TSource>::value>::type> {
+ const char* _ptr;
+
+ public:
+ explicit Reader(const void* ptr)
+ : _ptr(ptr ? reinterpret_cast<const char*>(ptr) : "") {}
+
+ int read() {
+ return static_cast<unsigned char>(*_ptr++);
+ }
+
+ size_t readBytes(char* buffer, size_t length) {
+ for (size_t i = 0; i < length; i++) buffer[i] = *_ptr++;
+ return length;
+ }
+};
+
+template <typename TSource>
+struct BoundedReader<TSource*,
+ typename enable_if<IsCharOrVoid<TSource>::value>::type>
+ : public IteratorReader<const char*> {
+ public:
+ explicit BoundedReader(const void* ptr, size_t len)
+ : IteratorReader<const char*>(reinterpret_cast<const char*>(ptr),
+ reinterpret_cast<const char*>(ptr) + len) {}
+};
+
+} // namespace ARDUINOJSON_NAMESPACE