mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Replace ARDUINOJSON_NAMESPACE with an inline namespace (#1820)
				
					
				
			This commit is contained in:
		| @@ -49,36 +49,3 @@ | ||||
| #include "ArduinoJson/MsgPack/MsgPackSerializer.hpp" | ||||
|  | ||||
| #include "ArduinoJson/compatibility.hpp" | ||||
|  | ||||
| namespace ArduinoJson { | ||||
| using ARDUINOJSON_NAMESPACE::BasicJsonDocument; | ||||
| using ARDUINOJSON_NAMESPACE::copyArray; | ||||
| using ARDUINOJSON_NAMESPACE::DeserializationError; | ||||
| using ARDUINOJSON_NAMESPACE::deserializeJson; | ||||
| using ARDUINOJSON_NAMESPACE::deserializeMsgPack; | ||||
| using ARDUINOJSON_NAMESPACE::DynamicJsonDocument; | ||||
| using ARDUINOJSON_NAMESPACE::JsonArray; | ||||
| using ARDUINOJSON_NAMESPACE::JsonArrayConst; | ||||
| using ARDUINOJSON_NAMESPACE::JsonDocument; | ||||
| using ARDUINOJSON_NAMESPACE::JsonFloat; | ||||
| using ARDUINOJSON_NAMESPACE::JsonInteger; | ||||
| using ARDUINOJSON_NAMESPACE::JsonObject; | ||||
| using ARDUINOJSON_NAMESPACE::JsonObjectConst; | ||||
| using ARDUINOJSON_NAMESPACE::JsonPair; | ||||
| using ARDUINOJSON_NAMESPACE::JsonPairConst; | ||||
| using ARDUINOJSON_NAMESPACE::JsonString; | ||||
| using ARDUINOJSON_NAMESPACE::JsonUInt; | ||||
| using ARDUINOJSON_NAMESPACE::JsonVariant; | ||||
| using ARDUINOJSON_NAMESPACE::JsonVariantConst; | ||||
| using ARDUINOJSON_NAMESPACE::measureJson; | ||||
| using ARDUINOJSON_NAMESPACE::serialized; | ||||
| using ARDUINOJSON_NAMESPACE::serializeJson; | ||||
| using ARDUINOJSON_NAMESPACE::serializeJsonPretty; | ||||
| using ARDUINOJSON_NAMESPACE::serializeMsgPack; | ||||
| using ARDUINOJSON_NAMESPACE::StaticJsonDocument; | ||||
|  | ||||
| namespace DeserializationOption { | ||||
| using ARDUINOJSON_NAMESPACE::Filter; | ||||
| using ARDUINOJSON_NAMESPACE::NestingLimit; | ||||
| }  // namespace DeserializationOption | ||||
| }  // namespace ArduinoJson | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Variant/VariantRefBase.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A proxy class to get or set an element of an array. | ||||
| // https://arduinojson.org/v6/api/jsonarray/subscript/ | ||||
| @@ -57,4 +57,4 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream> >, | ||||
|   size_t _index; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,14 +7,14 @@ | ||||
| #include <ArduinoJson/Array/ElementProxy.hpp> | ||||
| #include <ArduinoJson/Array/JsonArrayConst.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class JsonObject; | ||||
|  | ||||
| // A reference to an array in a JsonDocument | ||||
| // https://arduinojson.org/v6/api/jsonarray/ | ||||
| class JsonArray : public VariantOperators<JsonArray> { | ||||
|   friend class VariantAttorney; | ||||
| class JsonArray : public detail::VariantOperators<JsonArray> { | ||||
|   friend class detail::VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   typedef JsonArrayIterator iterator; | ||||
| @@ -23,14 +23,14 @@ class JsonArray : public VariantOperators<JsonArray> { | ||||
|   FORCE_INLINE JsonArray() : _data(0), _pool(0) {} | ||||
|  | ||||
|   // INTERNAL USE ONLY | ||||
|   FORCE_INLINE JsonArray(MemoryPool* pool, CollectionData* data) | ||||
|   FORCE_INLINE JsonArray(detail::MemoryPool* pool, detail::CollectionData* data) | ||||
|       : _data(data), _pool(pool) {} | ||||
|  | ||||
|   // Returns a JsonVariant pointing to the array. | ||||
|   // https://arduinojson.org/v6/api/jsonvariant/ | ||||
|   operator JsonVariant() { | ||||
|     void* data = _data;  // prevent warning cast-align | ||||
|     return JsonVariant(_pool, reinterpret_cast<VariantData*>(data)); | ||||
|     return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data)); | ||||
|   } | ||||
|  | ||||
|   // Returns a read-only reference to the array. | ||||
| @@ -118,8 +118,8 @@ class JsonArray : public VariantOperators<JsonArray> { | ||||
|  | ||||
|   // Gets or sets the element at the specified index. | ||||
|   // https://arduinojson.org/v6/api/jsonarray/subscript/ | ||||
|   FORCE_INLINE ElementProxy<JsonArray> operator[](size_t index) const { | ||||
|     return ElementProxy<JsonArray>(*this, index); | ||||
|   FORCE_INLINE detail::ElementProxy<JsonArray> operator[](size_t index) const { | ||||
|     return {*this, index}; | ||||
|   } | ||||
|  | ||||
|   // Creates an object and appends it to the array. | ||||
| @@ -167,35 +167,35 @@ class JsonArray : public VariantOperators<JsonArray> { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   MemoryPool* getPool() const { | ||||
|   detail::MemoryPool* getPool() const { | ||||
|     return _pool; | ||||
|   } | ||||
|  | ||||
|   VariantData* getData() const { | ||||
|   detail::VariantData* getData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   VariantData* getOrCreateData() const { | ||||
|   detail::VariantData* getOrCreateData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   CollectionData* _data; | ||||
|   MemoryPool* _pool; | ||||
|   detail::CollectionData* _data; | ||||
|   detail::MemoryPool* _pool; | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct Converter<JsonArray> : private VariantAttorney { | ||||
| struct Converter<JsonArray> : private detail::VariantAttorney { | ||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||
|   } | ||||
|  | ||||
|   static JsonArray fromJson(JsonVariant src) { | ||||
|     VariantData* data = getData(src); | ||||
|     MemoryPool* pool = getPool(src); | ||||
|     auto data = getData(src); | ||||
|     auto pool = getPool(src); | ||||
|     return JsonArray(pool, data != 0 ? data->asArray() : 0); | ||||
|   } | ||||
|  | ||||
|   static InvalidConversion<JsonVariantConst, JsonArray> fromJson( | ||||
|   static detail::InvalidConversion<JsonVariantConst, JsonArray> fromJson( | ||||
|       JsonVariantConst); | ||||
|  | ||||
|   static bool checkJson(JsonVariantConst) { | ||||
| @@ -203,8 +203,9 @@ struct Converter<JsonArray> : private VariantAttorney { | ||||
|   } | ||||
|  | ||||
|   static bool checkJson(JsonVariant src) { | ||||
|     VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data && data->isArray(); | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -8,15 +8,15 @@ | ||||
| #include <ArduinoJson/Variant/VariantAttorney.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class JsonObject; | ||||
|  | ||||
| // A read-only reference to an array in a JsonDocument | ||||
| // https://arduinojson.org/v6/api/jsonarrayconst/ | ||||
| class JsonArrayConst : public VariantOperators<JsonArrayConst> { | ||||
| class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> { | ||||
|   friend class JsonArray; | ||||
|   friend class VariantAttorney; | ||||
|   friend class detail::VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   typedef JsonArrayConstIterator iterator; | ||||
| @@ -39,7 +39,8 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> { | ||||
|   FORCE_INLINE JsonArrayConst() : _data(0) {} | ||||
|  | ||||
|   // INTERNAL USE ONLY | ||||
|   FORCE_INLINE JsonArrayConst(const CollectionData* data) : _data(data) {} | ||||
|   FORCE_INLINE JsonArrayConst(const detail::CollectionData* data) | ||||
|       : _data(data) {} | ||||
|  | ||||
|   // Compares the content of two arrays. | ||||
|   // Returns true if the two arrays are equal. | ||||
| @@ -107,28 +108,28 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   const VariantData* getData() const { | ||||
|   const detail::VariantData* getData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   const CollectionData* _data; | ||||
|   const detail::CollectionData* _data; | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct Converter<JsonArrayConst> : private VariantAttorney { | ||||
| struct Converter<JsonArrayConst> : private detail::VariantAttorney { | ||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||
|   } | ||||
|  | ||||
|   static JsonArrayConst fromJson(JsonVariantConst src) { | ||||
|     const VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data ? data->asArray() : 0; | ||||
|   } | ||||
|  | ||||
|   static bool checkJson(JsonVariantConst src) { | ||||
|     const VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data && data->isArray(); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -7,12 +7,16 @@ | ||||
| #include <ArduinoJson/Array/JsonArray.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| inline JsonObject JsonArray::createNestedObject() const { | ||||
|   return add().to<JsonObject>(); | ||||
| } | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TDerived> | ||||
| inline JsonArray VariantRefBase<TDerived>::createNestedArray() const { | ||||
|   return add().template to<JsonArray>(); | ||||
| @@ -29,4 +33,4 @@ inline ElementProxy<TDerived> VariantRefBase<TDerived>::operator[]( | ||||
|   return ElementProxy<TDerived>(derived(), index); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,11 +7,12 @@ | ||||
| #include <ArduinoJson/Variant/JsonVariant.hpp> | ||||
| #include <ArduinoJson/Variant/SlotFunctions.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class VariantPtr { | ||||
|  public: | ||||
|   VariantPtr(MemoryPool* pool, VariantData* data) : _variant(pool, data) {} | ||||
|   VariantPtr(detail::MemoryPool* pool, detail::VariantData* data) | ||||
|       : _variant(pool, data) {} | ||||
|  | ||||
|   JsonVariant* operator->() { | ||||
|     return &_variant; | ||||
| @@ -30,7 +31,8 @@ class JsonArrayIterator { | ||||
|  | ||||
|  public: | ||||
|   JsonArrayIterator() : _slot(0) {} | ||||
|   explicit JsonArrayIterator(MemoryPool* pool, VariantSlot* slot) | ||||
|   explicit JsonArrayIterator(detail::MemoryPool* pool, | ||||
|                              detail::VariantSlot* slot) | ||||
|       : _pool(pool), _slot(slot) {} | ||||
|  | ||||
|   JsonVariant operator*() const { | ||||
| @@ -59,13 +61,13 @@ class JsonArrayIterator { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   MemoryPool* _pool; | ||||
|   VariantSlot* _slot; | ||||
|   detail::MemoryPool* _pool; | ||||
|   detail::VariantSlot* _slot; | ||||
| }; | ||||
|  | ||||
| class VariantConstPtr { | ||||
|  public: | ||||
|   VariantConstPtr(const VariantData* data) : _variant(data) {} | ||||
|   VariantConstPtr(const detail::VariantData* data) : _variant(data) {} | ||||
|  | ||||
|   JsonVariantConst* operator->() { | ||||
|     return &_variant; | ||||
| @@ -84,7 +86,8 @@ class JsonArrayConstIterator { | ||||
|  | ||||
|  public: | ||||
|   JsonArrayConstIterator() : _slot(0) {} | ||||
|   explicit JsonArrayConstIterator(const VariantSlot* slot) : _slot(slot) {} | ||||
|   explicit JsonArrayConstIterator(const detail::VariantSlot* slot) | ||||
|       : _slot(slot) {} | ||||
|  | ||||
|   JsonVariantConst operator*() const { | ||||
|     return JsonVariantConst(_slot->data()); | ||||
| @@ -112,6 +115,7 @@ class JsonArrayConstIterator { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   const VariantSlot* _slot; | ||||
|   const detail::VariantSlot* _slot; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -7,21 +7,21 @@ | ||||
| #include <ArduinoJson/Array/JsonArray.hpp> | ||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Copies a value to a JsonVariant. | ||||
| // This is a degenerated form of copyArray() to stop the recursion. | ||||
| template <typename T> | ||||
| inline typename enable_if<!is_array<T>::value, bool>::type copyArray( | ||||
|     const T& src, JsonVariant dst) { | ||||
| inline typename detail::enable_if<!detail::is_array<T>::value, bool>::type | ||||
| copyArray(const T& src, JsonVariant dst) { | ||||
|   return dst.set(src); | ||||
| } | ||||
|  | ||||
| // Copies values from an array to a JsonArray or a JsonVariant. | ||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | ||||
| template <typename T, size_t N, typename TDestination> | ||||
| inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value, | ||||
|                           bool>::type | ||||
| inline typename detail::enable_if< | ||||
|     !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type | ||||
| copyArray(T (&src)[N], const TDestination& dst) { | ||||
|   return copyArray(src, N, dst); | ||||
| } | ||||
| @@ -29,8 +29,8 @@ copyArray(T (&src)[N], const TDestination& dst) { | ||||
| // Copies values from an array to a JsonArray or a JsonVariant. | ||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | ||||
| template <typename T, typename TDestination> | ||||
| inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value, | ||||
|                           bool>::type | ||||
| inline typename detail::enable_if< | ||||
|     !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type | ||||
| copyArray(const T* src, size_t len, const TDestination& dst) { | ||||
|   bool ok = true; | ||||
|   for (size_t i = 0; i < len; i++) { | ||||
| @@ -63,8 +63,8 @@ inline bool copyArray(const T* src, size_t len, JsonDocument& dst) { | ||||
| // Copies a value from a JsonVariant. | ||||
| // This is a degenerated form of copyArray() to stop the recursion. | ||||
| template <typename T> | ||||
| inline typename enable_if<!is_array<T>::value, size_t>::type copyArray( | ||||
|     JsonVariantConst src, T& dst) { | ||||
| inline typename detail::enable_if<!detail::is_array<T>::value, size_t>::type | ||||
| copyArray(JsonVariantConst src, T& dst) { | ||||
|   dst = src.as<T>(); | ||||
|   return 1; | ||||
| } | ||||
| @@ -103,11 +103,12 @@ inline size_t copyArray(JsonVariantConst src, char (&dst)[N]) { | ||||
| // Copies values from a JsonDocument to an array. | ||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | ||||
| template <typename TSource, typename T> | ||||
| inline typename enable_if<is_array<T>::value && | ||||
|                               is_base_of<JsonDocument, TSource>::value, | ||||
|                           size_t>::type | ||||
| inline typename detail::enable_if< | ||||
|     detail::is_array<T>::value && | ||||
|         detail::is_base_of<JsonDocument, TSource>::value, | ||||
|     size_t>::type | ||||
| copyArray(const TSource& src, T& dst) { | ||||
|   return copyArray(src.template as<JsonArrayConst>(), dst); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
| #include <stddef.h>  // size_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class MemoryPool; | ||||
| class VariantData; | ||||
| @@ -91,4 +91,5 @@ inline VariantData* collectionToVariant(CollectionData* collection) { | ||||
|   void* data = collection;  // prevent warning cast-align | ||||
|   return reinterpret_cast<VariantData*>(data); | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { | ||||
|   VariantSlot* slot = pool->allocVariant(); | ||||
| @@ -194,4 +194,4 @@ inline void CollectionData::movePointers(ptrdiff_t stringDistance, | ||||
|     slot->movePointers(stringDistance, variantDistance); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
| #  include <ostream> | ||||
| #endif | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class DeserializationError { | ||||
|  public: | ||||
| @@ -82,7 +82,7 @@ class DeserializationError { | ||||
|     ARDUINOJSON_DEFINE_PROGMEM_ARRAY( | ||||
|         const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); | ||||
|     return reinterpret_cast<const __FlashStringHelper*>( | ||||
|         pgm_read(messages + _code)); | ||||
|         detail::pgm_read(messages + _code)); | ||||
|   } | ||||
| #endif | ||||
|  | ||||
| @@ -103,4 +103,4 @@ inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) { | ||||
| } | ||||
| #endif | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,8 +6,9 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| namespace DeserializationOption { | ||||
| class Filter { | ||||
|  public: | ||||
|   explicit Filter(JsonVariantConst v) : _variant(v) {} | ||||
| @@ -39,7 +40,9 @@ class Filter { | ||||
|  private: | ||||
|   JsonVariantConst _variant; | ||||
| }; | ||||
| }  // namespace DeserializationOption | ||||
|  | ||||
| namespace detail { | ||||
| struct AllowAllFilter { | ||||
|   bool allow() const { | ||||
|     return true; | ||||
| @@ -62,5 +65,6 @@ struct AllowAllFilter { | ||||
|     return AllowAllFilter(); | ||||
|   } | ||||
| }; | ||||
| }  // namespace detail | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -7,8 +7,9 @@ | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| namespace DeserializationOption { | ||||
| class NestingLimit { | ||||
|  public: | ||||
|   NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} | ||||
| @@ -26,4 +27,6 @@ class NestingLimit { | ||||
|  private: | ||||
|   uint8_t _value; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| }  // namespace DeserializationOption | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <stdlib.h>  // for size_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // The default reader is a simple wrapper for Readers that are not copiable | ||||
| template <typename TSource, typename Enable = void> | ||||
| @@ -33,7 +33,8 @@ struct BoundedReader { | ||||
|   // no default implementation because we need to pass the size to the | ||||
|   // constructor | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #include <ArduinoJson/Deserialization/Readers/IteratorReader.hpp> | ||||
| #include <ArduinoJson/Deserialization/Readers/RamReader.hpp> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TSource> | ||||
| struct Reader<TSource, | ||||
| @@ -28,4 +28,4 @@ struct Reader<TSource, | ||||
|   Stream* _stream; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TSource> | ||||
| struct Reader<TSource, | ||||
| @@ -16,4 +16,4 @@ struct Reader<TSource, | ||||
|       : BoundedReader<const char*>(s.c_str(), s.length()) {} | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <> | ||||
| struct Reader<const __FlashStringHelper*, void> { | ||||
| @@ -52,4 +52,5 @@ struct BoundedReader<const __FlashStringHelper*, void> { | ||||
|     return length; | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TIterator> | ||||
| class IteratorReader { | ||||
| @@ -41,4 +41,5 @@ struct Reader<TSource, typename void_<typename TSource::const_iterator>::type> | ||||
|       : IteratorReader<typename TSource::const_iterator>(source.begin(), | ||||
|                                                          source.end()) {} | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct IsCharOrVoid { | ||||
| @@ -48,4 +48,4 @@ struct BoundedReader<TSource*, | ||||
|                                     reinterpret_cast<const char*>(ptr) + len) {} | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <istream> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TSource> | ||||
| struct Reader<TSource, typename enable_if< | ||||
| @@ -26,4 +26,5 @@ struct Reader<TSource, typename enable_if< | ||||
|  private: | ||||
|   std::istream* _stream; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | ||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TVariant> | ||||
| struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type> | ||||
| @@ -16,4 +16,4 @@ struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type> | ||||
|       : Reader<char*, void>(x.template as<const char*>()) {} | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
| #include <ArduinoJson/Deserialization/Reader.hpp> | ||||
| #include <ArduinoJson/StringStorage/StringStorage.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <template <typename, typename> class TDeserializer, typename TReader, | ||||
|           typename TWriter> | ||||
| @@ -28,9 +28,10 @@ TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool, | ||||
| // deserialize(JsonDocument&, const __FlashStringHelper*, NestingLimit, Filter); | ||||
| template <template <typename, typename> class TDeserializer, typename TString, | ||||
|           typename TFilter> | ||||
| typename enable_if<!is_array<TString>::value, DeserializationError>::type | ||||
| deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit, | ||||
|             TFilter filter) { | ||||
| typename detail::enable_if<!is_array<TString>::value, | ||||
|                            DeserializationError>::type | ||||
| deserialize(JsonDocument& doc, const TString& input, | ||||
|             DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||
|   Reader<TString> reader(input); | ||||
|   VariantData* data = VariantAttorney::getData(doc); | ||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||
| @@ -45,9 +46,9 @@ deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit, | ||||
| // deserialize(JsonDocument&, const __FlashStringHelper*, size_t, NL, Filter); | ||||
| template <template <typename, typename> class TDeserializer, typename TChar, | ||||
|           typename TFilter> | ||||
| DeserializationError deserialize(JsonDocument& doc, TChar* input, | ||||
|                                  size_t inputSize, NestingLimit nestingLimit, | ||||
|                                  TFilter filter) { | ||||
| DeserializationError deserialize( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||
|   BoundedReader<TChar*> reader(input, inputSize); | ||||
|   VariantData* data = VariantAttorney::getData(doc); | ||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||
| @@ -61,8 +62,9 @@ DeserializationError deserialize(JsonDocument& doc, TChar* input, | ||||
| // deserialize(JsonDocument&, Stream&, NestingLimit, Filter); | ||||
| template <template <typename, typename> class TDeserializer, typename TStream, | ||||
|           typename TFilter> | ||||
| DeserializationError deserialize(JsonDocument& doc, TStream& input, | ||||
|                                  NestingLimit nestingLimit, TFilter filter) { | ||||
| DeserializationError deserialize( | ||||
|     JsonDocument& doc, TStream& input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||
|   Reader<TStream> reader(input); | ||||
|   VariantData* data = VariantAttorney::getData(doc); | ||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||
| @@ -72,4 +74,4 @@ DeserializationError deserialize(JsonDocument& doc, TStream& input, | ||||
|       .parse(*data, filter, nestingLimit); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Helper to implement the "base-from-member" idiom | ||||
| // (we need to store the allocator before constructing JsonDocument) | ||||
| @@ -62,13 +62,14 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | ||||
|  | ||||
|   // Construct from variant, array, or object | ||||
|   template <typename T> | ||||
|   BasicJsonDocument( | ||||
|       const T& src, | ||||
|       typename enable_if< | ||||
|           is_same<T, JsonVariant>::value || | ||||
|           is_same<T, JsonVariantConst>::value || is_same<T, JsonArray>::value || | ||||
|           is_same<T, JsonArrayConst>::value || is_same<T, JsonObject>::value || | ||||
|           is_same<T, JsonObjectConst>::value>::type* = 0) | ||||
|   BasicJsonDocument(const T& src, | ||||
|                     typename detail::enable_if< | ||||
|                         detail::is_same<T, JsonVariant>::value || | ||||
|                         detail::is_same<T, JsonVariantConst>::value || | ||||
|                         detail::is_same<T, JsonArray>::value || | ||||
|                         detail::is_same<T, JsonArrayConst>::value || | ||||
|                         detail::is_same<T, JsonObject>::value || | ||||
|                         detail::is_same<T, JsonObjectConst>::value>::type* = 0) | ||||
|       : JsonDocument(allocPool(src.memoryUsage())) { | ||||
|     set(src); | ||||
|   } | ||||
| @@ -134,17 +135,17 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | ||||
|   using AllocatorOwner<TAllocator>::allocator; | ||||
|  | ||||
|  private: | ||||
|   MemoryPool allocPool(size_t requiredSize) { | ||||
|     size_t capa = addPadding(requiredSize); | ||||
|     return MemoryPool(reinterpret_cast<char*>(this->allocate(capa)), capa); | ||||
|   detail::MemoryPool allocPool(size_t requiredSize) { | ||||
|     size_t capa = detail::addPadding(requiredSize); | ||||
|     return {reinterpret_cast<char*>(this->allocate(capa)), capa}; | ||||
|   } | ||||
|  | ||||
|   void reallocPool(size_t requiredSize) { | ||||
|     size_t capa = addPadding(requiredSize); | ||||
|     size_t capa = detail::addPadding(requiredSize); | ||||
|     if (capa == _pool.capacity()) | ||||
|       return; | ||||
|     freePool(); | ||||
|     replacePool(allocPool(addPadding(requiredSize))); | ||||
|     replacePool(allocPool(detail::addPadding(requiredSize))); | ||||
|   } | ||||
|  | ||||
|   void freePool() { | ||||
| @@ -161,8 +162,8 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | ||||
|     _data = src._data; | ||||
|     _pool = src._pool; | ||||
|     src._data.setNull(); | ||||
|     src._pool = MemoryPool(0, 0); | ||||
|     src._pool = {0, 0}; | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <stdlib.h>  // malloc, free | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // The allocator of DynamicJsonDocument. | ||||
| struct DefaultAllocator { | ||||
| @@ -29,4 +29,4 @@ struct DefaultAllocator { | ||||
| // https://arduinojson.org/v6/api/dynamicjsondocument/ | ||||
| typedef BasicJsonDocument<DefaultAllocator> DynamicJsonDocument; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -12,12 +12,12 @@ | ||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||
| #include <ArduinoJson/Variant/VariantTo.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // A JSON document. | ||||
| // https://arduinojson.org/v6/api/jsondocument/ | ||||
| class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|   friend class VariantAttorney; | ||||
| class JsonDocument : public detail::VariantOperators<const JsonDocument&> { | ||||
|   friend class detail::VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   // Casts the root to the specified type. | ||||
| @@ -100,15 +100,16 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|   // Replaces the root with the specified value. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/set/ | ||||
|   template <typename T> | ||||
|   typename enable_if<!is_base_of<JsonDocument, T>::value, bool>::type set( | ||||
|       const T& src) { | ||||
|   typename detail::enable_if<!detail::is_base_of<JsonDocument, T>::value, | ||||
|                              bool>::type | ||||
|   set(const T& src) { | ||||
|     return to<JsonVariant>().set(src); | ||||
|   } | ||||
|  | ||||
|   // Clears the document and converts it to the specified type. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/to/ | ||||
|   template <typename T> | ||||
|   typename VariantTo<T>::type to() { | ||||
|   typename detail::VariantTo<T>::type to() { | ||||
|     clear(); | ||||
|     return getVariant().template to<T>(); | ||||
|   } | ||||
| @@ -157,56 +158,58 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|   // https://arduinojson.org/v6/api/jsondocument/containskey/ | ||||
|   template <typename TChar> | ||||
|   bool containsKey(TChar* key) const { | ||||
|     return _data.getMember(adaptString(key)) != 0; | ||||
|     return _data.getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Returns true if the root object contains the specified key. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/containskey/ | ||||
|   template <typename TString> | ||||
|   bool containsKey(const TString& key) const { | ||||
|     return _data.getMember(adaptString(key)) != 0; | ||||
|     return _data.getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Gets or sets a root object's member. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, | ||||
|                                   MemberProxy<JsonDocument&, TString> >::type | ||||
|   FORCE_INLINE typename detail::enable_if< | ||||
|       detail::IsString<TString>::value, | ||||
|       detail::MemberProxy<JsonDocument&, TString> >::type | ||||
|   operator[](const TString& key) { | ||||
|     return MemberProxy<JsonDocument&, TString>(*this, key); | ||||
|     return {*this, key}; | ||||
|   } | ||||
|  | ||||
|   // Gets or sets a root object's member. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, | ||||
|                                   MemberProxy<JsonDocument&, TChar*> >::type | ||||
|   FORCE_INLINE typename detail::enable_if< | ||||
|       detail::IsString<TChar*>::value, | ||||
|       detail::MemberProxy<JsonDocument&, TChar*> >::type | ||||
|   operator[](TChar* key) { | ||||
|     return MemberProxy<JsonDocument&, TChar*>(*this, key); | ||||
|     return {*this, key}; | ||||
|   } | ||||
|  | ||||
|   // Gets a root object's member. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE | ||||
|       typename enable_if<IsString<TString>::value, JsonVariantConst>::type | ||||
|       operator[](const TString& key) const { | ||||
|     return JsonVariantConst(_data.getMember(adaptString(key))); | ||||
|   FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, | ||||
|                                           JsonVariantConst>::type | ||||
|   operator[](const TString& key) const { | ||||
|     return JsonVariantConst(_data.getMember(detail::adaptString(key))); | ||||
|   } | ||||
|  | ||||
|   // Gets a root object's member. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE | ||||
|       typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type | ||||
|       operator[](TChar* key) const { | ||||
|     return JsonVariantConst(_data.getMember(adaptString(key))); | ||||
|   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, | ||||
|                                           JsonVariantConst>::type | ||||
|   operator[](TChar* key) const { | ||||
|     return JsonVariantConst(_data.getMember(detail::adaptString(key))); | ||||
|   } | ||||
|  | ||||
|   // Gets or sets a root array's element. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||
|   FORCE_INLINE ElementProxy<JsonDocument&> operator[](size_t index) { | ||||
|     return ElementProxy<JsonDocument&>(*this, index); | ||||
|   FORCE_INLINE detail::ElementProxy<JsonDocument&> operator[](size_t index) { | ||||
|     return {*this, index}; | ||||
|   } | ||||
|  | ||||
|   // Gets a root array's member. | ||||
| @@ -247,18 +250,19 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|   // ⚠️ Doesn't release the memory associated with the removed element. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/remove/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove( | ||||
|       TChar* key) { | ||||
|     _data.remove(adaptString(key)); | ||||
|   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value>::type | ||||
|   remove(TChar* key) { | ||||
|     _data.remove(detail::adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   // Removes a member of the root object. | ||||
|   // ⚠️ Doesn't release the memory associated with the removed element. | ||||
|   // https://arduinojson.org/v6/api/jsondocument/remove/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( | ||||
|       const TString& key) { | ||||
|     _data.remove(adaptString(key)); | ||||
|   FORCE_INLINE | ||||
|       typename detail::enable_if<detail::IsString<TString>::value>::type | ||||
|       remove(const TString& key) { | ||||
|     _data.remove(detail::adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE operator JsonVariant() { | ||||
| @@ -274,7 +278,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|     _data.init(); | ||||
|   } | ||||
|  | ||||
|   JsonDocument(MemoryPool pool) : _pool(pool) { | ||||
|   JsonDocument(detail::MemoryPool pool) : _pool(pool) { | ||||
|     _data.init(); | ||||
|   } | ||||
|  | ||||
| @@ -284,7 +288,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|  | ||||
|   ~JsonDocument() {} | ||||
|  | ||||
|   void replacePool(MemoryPool pool) { | ||||
|   void replacePool(detail::MemoryPool pool) { | ||||
|     _pool = pool; | ||||
|   } | ||||
|  | ||||
| @@ -296,27 +300,27 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|     return JsonVariantConst(&_data); | ||||
|   } | ||||
|  | ||||
|   MemoryPool _pool; | ||||
|   VariantData _data; | ||||
|   detail::MemoryPool _pool; | ||||
|   detail::VariantData _data; | ||||
|  | ||||
|  private: | ||||
|   JsonDocument(const JsonDocument&); | ||||
|   JsonDocument& operator=(const JsonDocument&); | ||||
|  | ||||
|  protected: | ||||
|   MemoryPool* getPool() { | ||||
|   detail::MemoryPool* getPool() { | ||||
|     return &_pool; | ||||
|   } | ||||
|  | ||||
|   VariantData* getData() { | ||||
|   detail::VariantData* getData() { | ||||
|     return &_data; | ||||
|   } | ||||
|  | ||||
|   const VariantData* getData() const { | ||||
|   const detail::VariantData* getData() const { | ||||
|     return &_data; | ||||
|   } | ||||
|  | ||||
|   VariantData* getOrCreateData() { | ||||
|   detail::VariantData* getOrCreateData() { | ||||
|     return &_data; | ||||
|   } | ||||
| }; | ||||
| @@ -325,4 +329,4 @@ inline void convertToJson(const JsonDocument& src, JsonVariant dst) { | ||||
|   dst.set(src.as<JsonVariantConst>()); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,13 +6,13 @@ | ||||
|  | ||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // A JsonDocument with a memory pool on the stack. | ||||
| template <size_t desiredCapacity> | ||||
| class StaticJsonDocument : public JsonDocument { | ||||
|   static const size_t _capacity = | ||||
|       AddPadding<Max<1, desiredCapacity>::value>::value; | ||||
|       detail::AddPadding<detail::Max<1, desiredCapacity>::value>::value; | ||||
|  | ||||
|  public: | ||||
|   StaticJsonDocument() : JsonDocument(_buffer, _capacity) {} | ||||
| @@ -25,7 +25,8 @@ class StaticJsonDocument : public JsonDocument { | ||||
|   template <typename T> | ||||
|   StaticJsonDocument( | ||||
|       const T& src, | ||||
|       typename enable_if<is_convertible<T, JsonVariantConst>::value>::type* = 0) | ||||
|       typename detail::enable_if< | ||||
|           detail::is_convertible<T, JsonVariantConst>::value>::type* = 0) | ||||
|       : JsonDocument(_buffer, _capacity) { | ||||
|     set(src); | ||||
|   } | ||||
| @@ -57,4 +58,4 @@ class StaticJsonDocument : public JsonDocument { | ||||
|   char _buffer[_capacity]; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class EscapeSequence { | ||||
|  public: | ||||
| @@ -36,4 +36,5 @@ class EscapeSequence { | ||||
|     return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0]; | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TReader, typename TStringStorage> | ||||
| class JsonDeserializer { | ||||
| @@ -29,7 +29,7 @@ class JsonDeserializer { | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError parse(VariantData& variant, TFilter filter, | ||||
|                              NestingLimit nestingLimit) { | ||||
|                              DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     err = parseVariant(variant, filter, nestingLimit); | ||||
| @@ -59,8 +59,9 @@ class JsonDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code parseVariant(VariantData& variant, TFilter filter, | ||||
|                                           NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code parseVariant( | ||||
|       VariantData& variant, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     err = skipSpacesAndComments(); | ||||
| @@ -110,7 +111,8 @@ class JsonDeserializer { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   DeserializationError::Code skipVariant(NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code skipVariant( | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     err = skipSpacesAndComments(); | ||||
| @@ -143,8 +145,9 @@ class JsonDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code parseArray(CollectionData& array, TFilter filter, | ||||
|                                         NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code parseArray( | ||||
|       CollectionData& array, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -196,7 +199,8 @@ class JsonDeserializer { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   DeserializationError::Code skipArray(NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code skipArray( | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -227,8 +231,9 @@ class JsonDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code parseObject(CollectionData& object, TFilter filter, | ||||
|                                          NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code parseObject( | ||||
|       CollectionData& object, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -312,7 +317,8 @@ class JsonDeserializer { | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   DeserializationError::Code skipObject(NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code skipObject( | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -661,12 +667,17 @@ class JsonDeserializer { | ||||
|                      // code | ||||
| }; | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Parses a JSON input and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||
|                                        AllowAllFilter()); | ||||
| } | ||||
| @@ -675,16 +686,21 @@ DeserializationError deserializeJson( | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, const TString& input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeJson(JsonDocument& doc, const TString& input, | ||||
|                                      NestingLimit nestingLimit, Filter filter) { | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -693,7 +709,8 @@ DeserializationError deserializeJson(JsonDocument& doc, const TString& input, | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TStream& input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||
|                                        AllowAllFilter()); | ||||
| } | ||||
| @@ -702,16 +719,20 @@ DeserializationError deserializeJson( | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TStream& input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TStream& input, DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeJson(JsonDocument& doc, TStream& input, | ||||
|                                      NestingLimit nestingLimit, Filter filter) { | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TStream& input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -720,7 +741,8 @@ DeserializationError deserializeJson(JsonDocument& doc, TStream& input, | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||
|                                        AllowAllFilter()); | ||||
| } | ||||
| @@ -729,16 +751,20 @@ DeserializationError deserializeJson( | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TChar* input, DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | ||||
|                                      NestingLimit nestingLimit, Filter filter) { | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -747,7 +773,8 @@ DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                        AllowAllFilter()); | ||||
| } | ||||
| @@ -756,8 +783,11 @@ DeserializationError deserializeJson( | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = | ||||
|         DeserializationOption::NestingLimit()) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                        filter); | ||||
| } | ||||
| @@ -765,11 +795,13 @@ DeserializationError deserializeJson( | ||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | ||||
|                                      size_t inputSize, | ||||
|                                      NestingLimit nestingLimit, Filter filter) { | ||||
| DeserializationError deserializeJson( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                        filter); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| #include <ArduinoJson/Serialization/serialize.hpp> | ||||
| #include <ArduinoJson/Variant/Visitor.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TWriter> | ||||
| class JsonSerializer : public Visitor<size_t> { | ||||
| @@ -115,10 +115,15 @@ class JsonSerializer : public Visitor<size_t> { | ||||
|   TextFormatter<TWriter> _formatter; | ||||
| }; | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Produces a minified JSON document. | ||||
| // https://arduinojson.org/v6/api/json/serializejson/ | ||||
| template <typename TDestination> | ||||
| size_t serializeJson(JsonVariantConst source, TDestination& destination) { | ||||
|   using namespace detail; | ||||
|   return serialize<JsonSerializer>(source, destination); | ||||
| } | ||||
|  | ||||
| @@ -126,23 +131,25 @@ size_t serializeJson(JsonVariantConst source, TDestination& destination) { | ||||
| // https://arduinojson.org/v6/api/json/serializejson/ | ||||
| inline size_t serializeJson(JsonVariantConst source, void* buffer, | ||||
|                             size_t bufferSize) { | ||||
|   using namespace detail; | ||||
|   return serialize<JsonSerializer>(source, buffer, bufferSize); | ||||
| } | ||||
|  | ||||
| // Computes the length of the document that serializeJson() produces. | ||||
| // https://arduinojson.org/v6/api/json/measurejson/ | ||||
| inline size_t measureJson(JsonVariantConst source) { | ||||
|   using namespace detail; | ||||
|   return measure<JsonSerializer>(source); | ||||
| } | ||||
|  | ||||
| #if ARDUINOJSON_ENABLE_STD_STREAM | ||||
| template <typename T> | ||||
| inline typename enable_if<is_convertible<T, JsonVariantConst>::value, | ||||
|                           std::ostream&>::type | ||||
| inline typename detail::enable_if< | ||||
|     detail::is_convertible<T, JsonVariantConst>::value, std::ostream&>::type | ||||
| operator<<(std::ostream& os, const T& source) { | ||||
|   serializeJson(source, os); | ||||
|   return os; | ||||
| } | ||||
| #endif | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TReader> | ||||
| class Latch { | ||||
| @@ -53,4 +53,4 @@ class Latch { | ||||
| #endif | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| #include <ArduinoJson/Serialization/measure.hpp> | ||||
| #include <ArduinoJson/Serialization/serialize.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TWriter> | ||||
| class PrettyJsonSerializer : public JsonSerializer<TWriter> { | ||||
| @@ -71,10 +71,15 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> { | ||||
|   uint8_t _nesting; | ||||
| }; | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Produces JsonDocument to create a prettified JSON document. | ||||
| // https://arduinojson.org/v6/api/json/serializejsonpretty/ | ||||
| template <typename TDestination> | ||||
| size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return serialize<PrettyJsonSerializer>(source, destination); | ||||
| } | ||||
|  | ||||
| @@ -82,13 +87,15 @@ size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { | ||||
| // https://arduinojson.org/v6/api/json/serializejsonpretty/ | ||||
| inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer, | ||||
|                                   size_t bufferSize) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return serialize<PrettyJsonSerializer>(source, buffer, bufferSize); | ||||
| } | ||||
|  | ||||
| // Computes the length of the document that serializeJsonPretty() produces. | ||||
| // https://arduinojson.org/v6/api/json/measurejsonpretty/ | ||||
| inline size_t measureJsonPretty(JsonVariantConst source) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return measure<PrettyJsonSerializer>(source); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -15,7 +15,7 @@ | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Serialization/CountingDecorator.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TWriter> | ||||
| class TextFormatter { | ||||
| @@ -170,4 +170,5 @@ class TextFormatter { | ||||
|  private: | ||||
|   TextFormatter& operator=(const TextFormatter&);  // cannot be assigned | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -18,7 +18,7 @@ | ||||
| #  endif | ||||
| #endif | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| namespace Utf16 { | ||||
| inline bool isHighSurrogate(uint16_t codeunit) { | ||||
| @@ -58,7 +58,7 @@ class Codepoint { | ||||
|   uint32_t _codepoint; | ||||
| }; | ||||
| }  // namespace Utf16 | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #if defined(__GNUC__) | ||||
| #  if __GNUC__ >= 8 | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| namespace Utf8 { | ||||
| template <typename TStringBuilder> | ||||
| @@ -43,4 +43,4 @@ inline void encodeCodepoint(uint32_t codepoint32, TStringBuilder& str) { | ||||
|   } | ||||
| } | ||||
| }  // namespace Utf8 | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <stddef.h>  // size_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| #if ARDUINOJSON_ENABLE_ALIGNMENT | ||||
|  | ||||
| @@ -57,4 +57,4 @@ inline T* addPadding(T* p) { | ||||
|   return reinterpret_cast<T*>(address); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -17,14 +17,14 @@ | ||||
| // Computes the size required to store an array in a JsonDocument. | ||||
| // https://arduinojson.org/v6/how-to/determine-the-capacity-of-the-jsondocument/ | ||||
| #define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ | ||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) | ||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot)) | ||||
|  | ||||
| // Returns the size (in bytes) of an object with n elements. | ||||
| // Can be very handy to determine the size of a StaticMemoryPool. | ||||
| #define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \ | ||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) | ||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot)) | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // _begin                                   _end | ||||
| // v                                           v | ||||
| @@ -250,4 +250,4 @@ bool storeString(MemoryPool* pool, TAdaptedString str, TCallback callback) { | ||||
|   return storeString(pool, str, str.storagePolicy(), callback); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // A special type of data that can be used to insert pregenerated JSON portions. | ||||
| template <typename T> | ||||
| @@ -58,11 +58,12 @@ inline SerializedValue<T> serialized(T str) { | ||||
|  | ||||
| template <typename TChar> | ||||
| inline SerializedValue<TChar*> serialized(TChar* p) { | ||||
|   return SerializedValue<TChar*>(p, adaptString(p).size()); | ||||
|   return SerializedValue<TChar*>(p, detail::adaptString(p).size()); | ||||
| } | ||||
|  | ||||
| template <typename TChar> | ||||
| inline SerializedValue<TChar*> serialized(TChar* p, size_t n) { | ||||
|   return SerializedValue<TChar*>(p, n); | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TReader, typename TStringStorage> | ||||
| class MsgPackDeserializer { | ||||
| @@ -25,7 +25,7 @@ class MsgPackDeserializer { | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError parse(VariantData& variant, TFilter filter, | ||||
|                              NestingLimit nestingLimit) { | ||||
|                              DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|     err = parseVariant(&variant, filter, nestingLimit); | ||||
|     return _foundSomething ? err : DeserializationError::EmptyInput; | ||||
| @@ -33,8 +33,9 @@ class MsgPackDeserializer { | ||||
|  | ||||
|  private: | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code parseVariant(VariantData* variant, TFilter filter, | ||||
|                                           NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code parseVariant( | ||||
|       VariantData* variant, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     uint8_t code = 0;  // TODO: why do we need to initialize this variable? | ||||
| @@ -395,8 +396,9 @@ class MsgPackDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TSize, typename TFilter> | ||||
|   DeserializationError::Code readArray(VariantData* variant, TFilter filter, | ||||
|                                        NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code readArray( | ||||
|       VariantData* variant, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|     TSize size; | ||||
|  | ||||
| @@ -408,9 +410,9 @@ class MsgPackDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code readArray(VariantData* variant, size_t n, | ||||
|                                        TFilter filter, | ||||
|                                        NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code readArray( | ||||
|       VariantData* variant, size_t n, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -449,8 +451,9 @@ class MsgPackDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TSize, typename TFilter> | ||||
|   DeserializationError::Code readObject(VariantData* variant, TFilter filter, | ||||
|                                         NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code readObject( | ||||
|       VariantData* variant, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|     TSize size; | ||||
|  | ||||
| @@ -462,9 +465,9 @@ class MsgPackDeserializer { | ||||
|   } | ||||
|  | ||||
|   template <typename TFilter> | ||||
|   DeserializationError::Code readObject(VariantData* variant, size_t n, | ||||
|                                         TFilter filter, | ||||
|                                         NestingLimit nestingLimit) { | ||||
|   DeserializationError::Code readObject( | ||||
|       VariantData* variant, size_t n, TFilter filter, | ||||
|       DeserializationOption::NestingLimit nestingLimit) { | ||||
|     DeserializationError::Code err; | ||||
|  | ||||
|     if (nestingLimit.reached()) | ||||
| @@ -557,12 +560,17 @@ class MsgPackDeserializer { | ||||
|   bool _foundSomething; | ||||
| }; | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Parses a MessagePack input and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||
|                                           AllowAllFilter()); | ||||
| } | ||||
| @@ -571,17 +579,21 @@ DeserializationError deserializeMsgPack( | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, const TString& input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TString> | ||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, const TString& input, | ||||
|                                         NestingLimit nestingLimit, | ||||
|                                         Filter filter) { | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, const TString& input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -590,7 +602,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, const TString& input, | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TStream& input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||
|                                           AllowAllFilter()); | ||||
| } | ||||
| @@ -599,17 +612,20 @@ DeserializationError deserializeMsgPack( | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TStream& input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TStream& input, DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TStream> | ||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TStream& input, | ||||
|                                         NestingLimit nestingLimit, | ||||
|                                         Filter filter) { | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TStream& input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -618,7 +634,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, TStream& input, | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||
|                                           AllowAllFilter()); | ||||
| } | ||||
| @@ -627,17 +644,20 @@ DeserializationError deserializeMsgPack( | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TChar* input, DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | ||||
|                                         NestingLimit nestingLimit, | ||||
|                                         Filter filter) { | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||
| } | ||||
|  | ||||
| @@ -646,7 +666,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                           AllowAllFilter()); | ||||
| } | ||||
| @@ -655,8 +676,10 @@ DeserializationError deserializeMsgPack( | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, Filter filter, | ||||
|     NestingLimit nestingLimit = NestingLimit()) { | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     DeserializationOption::Filter filter, | ||||
|     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                           filter); | ||||
| } | ||||
| @@ -664,12 +687,13 @@ DeserializationError deserializeMsgPack( | ||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||
| template <typename TChar> | ||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | ||||
|                                         size_t inputSize, | ||||
|                                         NestingLimit nestingLimit, | ||||
|                                         Filter filter) { | ||||
| DeserializationError deserializeMsgPack( | ||||
|     JsonDocument& doc, TChar* input, size_t inputSize, | ||||
|     DeserializationOption::NestingLimit nestingLimit, | ||||
|     DeserializationOption::Filter filter) { | ||||
|   using namespace detail; | ||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||
|                                           filter); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
| #include <ArduinoJson/Serialization/serialize.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TWriter> | ||||
| class MsgPackSerializer : public Visitor<size_t> { | ||||
| @@ -197,10 +197,15 @@ class MsgPackSerializer : public Visitor<size_t> { | ||||
|   CountingDecorator<TWriter> _writer; | ||||
| }; | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // Produces a MessagePack document. | ||||
| // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | ||||
| template <typename TDestination> | ||||
| inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return serialize<MsgPackSerializer>(source, output); | ||||
| } | ||||
|  | ||||
| @@ -208,13 +213,15 @@ inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { | ||||
| // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | ||||
| inline size_t serializeMsgPack(JsonVariantConst source, void* output, | ||||
|                                size_t size) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return serialize<MsgPackSerializer>(source, output, size); | ||||
| } | ||||
|  | ||||
| // Computes the length of the document that serializeMsgPack() produces. | ||||
| // https://arduinojson.org/v6/api/msgpack/measuremsgpack/ | ||||
| inline size_t measureMsgPack(JsonVariantConst source) { | ||||
|   using namespace ArduinoJson::detail; | ||||
|   return measure<MsgPackSerializer>(source); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| #if ARDUINOJSON_LITTLE_ENDIAN | ||||
| inline void swapBytes(uint8_t& a, uint8_t& b) { | ||||
| @@ -43,4 +43,4 @@ template <typename T> | ||||
| inline void fixEndianess(T&) {} | ||||
| #endif | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { | ||||
|   f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5)); | ||||
| @@ -15,4 +15,4 @@ inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { | ||||
|   f[3] = uint8_t((d[3] << 3) | (d[4] >> 5)); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,11 +8,11 @@ | ||||
| #include <ArduinoJson/Polyfills/preprocessor.hpp> | ||||
| #include <ArduinoJson/version.hpp> | ||||
|  | ||||
| #ifndef ARDUINOJSON_NAMESPACE | ||||
| #ifndef ARDUINOJSON_VERSION_NAMESPACE | ||||
|  | ||||
| #  define ARDUINOJSON_NAMESPACE                                               \ | ||||
| #  define ARDUINOJSON_VERSION_NAMESPACE                                       \ | ||||
|     ARDUINOJSON_CONCAT4(                                                      \ | ||||
|         ARDUINOJSON_CONCAT4(ArduinoJson, ARDUINOJSON_VERSION_MAJOR,           \ | ||||
|         ARDUINOJSON_CONCAT4(V, ARDUINOJSON_VERSION_MAJOR,                     \ | ||||
|                             ARDUINOJSON_VERSION_MINOR,                        \ | ||||
|                             ARDUINOJSON_VERSION_REVISION),                    \ | ||||
|         _,                                                                    \ | ||||
| @@ -24,3 +24,21 @@ | ||||
|             ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE)) | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #define ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE \ | ||||
|   namespace ArduinoJson {                  \ | ||||
|   inline namespace ARDUINOJSON_VERSION_NAMESPACE { | ||||
|  | ||||
| #define ARDUINOJSON_END_PUBLIC_NAMESPACE \ | ||||
|   }                                      \ | ||||
|   } | ||||
|  | ||||
| #define ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE        \ | ||||
|   namespace ArduinoJson {                          \ | ||||
|   inline namespace ARDUINOJSON_VERSION_NAMESPACE { \ | ||||
|   namespace detail { | ||||
|  | ||||
| #define ARDUINOJSON_END_PRIVATE_NAMESPACE \ | ||||
|   }                                       \ | ||||
|   }                                       \ | ||||
|   } | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include <ArduinoJson/Numbers/FloatTraits.hpp> | ||||
| #include <ArduinoJson/Polyfills/math.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TFloat> | ||||
| struct FloatParts { | ||||
| @@ -84,4 +84,5 @@ struct FloatParts { | ||||
|     return powersOf10; | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -14,7 +14,7 @@ | ||||
| #include <ArduinoJson/Polyfills/preprocessor.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T, size_t = sizeof(T)> | ||||
| struct FloatTraits {}; | ||||
| @@ -262,4 +262,5 @@ struct FloatTraits<T, 4 /*32bits*/> { | ||||
|     return forge(0xFf7fffff); | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,11 +7,12 @@ | ||||
| #include <ArduinoJson/Configuration.hpp> | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| #if ARDUINOJSON_USE_DOUBLE | ||||
| typedef double JsonFloat; | ||||
| #else | ||||
| typedef float JsonFloat; | ||||
| #endif | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
| #include <stdint.h>  // int64_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| #if ARDUINOJSON_USE_LONG_LONG | ||||
| typedef int64_t JsonInteger; | ||||
| @@ -19,10 +19,10 @@ typedef long JsonInteger; | ||||
| typedef unsigned long JsonUInt; | ||||
| #endif | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|  | ||||
| #define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T)                  \ | ||||
|   static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::JsonInteger), \ | ||||
|   static_assert(sizeof(T) <= sizeof(ArduinoJson::JsonInteger),           \ | ||||
|                 "To use 64-bit integers with ArduinoJson, you must set " \ | ||||
|                 "ARDUINOJSON_USE_LONG_LONG to 1. See "                   \ | ||||
|                 "https://arduinojson.org/v6/api/config/use_long_long/"); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <ArduinoJson/Numbers/JsonInteger.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| enum CompareResult { | ||||
|   COMPARE_RESULT_DIFFER = 0, | ||||
| @@ -117,4 +117,4 @@ CompareResult arithmeticCompareNegateRight( | ||||
|   return arithmeticCompare(static_cast<T1>(rhs), -lhs); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -17,7 +17,7 @@ | ||||
| #include <ArduinoJson/Polyfills/limits.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // uint32 -> int32 | ||||
| // uint64 -> int32 | ||||
| @@ -126,7 +126,7 @@ template <typename TOut, typename TIn> | ||||
| TOut convertNumber(TIn value) { | ||||
|   return canConvertNumber<TOut>(value) ? TOut(value) : 0; | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #if defined(__clang__) | ||||
| #  pragma clang diagnostic pop | ||||
|   | ||||
| @@ -13,7 +13,7 @@ | ||||
| #include <ArduinoJson/Variant/Converter.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename A, typename B> | ||||
| struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {}; | ||||
| @@ -150,4 +150,4 @@ inline T parseNumber(const char* s) { | ||||
|   parseNumber(s, value); | ||||
|   return Converter<T>::fromJson(JsonVariantConst(&value)); | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,14 +7,14 @@ | ||||
| #include <ArduinoJson/Object/JsonObjectConst.hpp> | ||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class JsonArray; | ||||
|  | ||||
| // A reference to an object in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/jsonobject/ | ||||
| class JsonObject : public VariantOperators<JsonObject> { | ||||
|   friend class VariantAttorney; | ||||
| class JsonObject : public detail::VariantOperators<JsonObject> { | ||||
|   friend class detail::VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   typedef JsonObjectIterator iterator; | ||||
| @@ -23,12 +23,12 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|   FORCE_INLINE JsonObject() : _data(0), _pool(0) {} | ||||
|  | ||||
|   // INTERNAL USE ONLY | ||||
|   FORCE_INLINE JsonObject(MemoryPool* buf, CollectionData* data) | ||||
|   FORCE_INLINE JsonObject(detail::MemoryPool* buf, detail::CollectionData* data) | ||||
|       : _data(data), _pool(buf) {} | ||||
|  | ||||
|   operator JsonVariant() const { | ||||
|     void* data = _data;  // prevent warning cast-align | ||||
|     return JsonVariant(_pool, reinterpret_cast<VariantData*>(data)); | ||||
|     return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data)); | ||||
|   } | ||||
|  | ||||
|   operator JsonObjectConst() const { | ||||
| @@ -108,19 +108,21 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|   // Gets or sets the member with specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, | ||||
|                                   MemberProxy<JsonObject, TString> >::type | ||||
|   FORCE_INLINE typename detail::enable_if< | ||||
|       detail::IsString<TString>::value, | ||||
|       detail::MemberProxy<JsonObject, TString> >::type | ||||
|   operator[](const TString& key) const { | ||||
|     return MemberProxy<JsonObject, TString>(*this, key); | ||||
|     return {*this, key}; | ||||
|   } | ||||
|  | ||||
|   // Gets or sets the member with specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, | ||||
|                                   MemberProxy<JsonObject, TChar*> >::type | ||||
|   operator[](TChar* key) const { | ||||
|     return MemberProxy<JsonObject, TChar*>(*this, key); | ||||
|   FORCE_INLINE | ||||
|       typename detail::enable_if<detail::IsString<TChar*>::value, | ||||
|                                  detail::MemberProxy<JsonObject, TChar*> >::type | ||||
|       operator[](TChar* key) const { | ||||
|     return {*this, key}; | ||||
|   } | ||||
|  | ||||
|   // Removes the member at the specified iterator. | ||||
| @@ -137,7 +139,7 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|   // https://arduinojson.org/v6/api/jsonobject/remove/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE void remove(const TString& key) const { | ||||
|     removeMember(adaptString(key)); | ||||
|     removeMember(detail::adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   // Removes the member with the specified key. | ||||
| @@ -145,23 +147,25 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|   // https://arduinojson.org/v6/api/jsonobject/remove/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE void remove(TChar* key) const { | ||||
|     removeMember(adaptString(key)); | ||||
|     removeMember(detail::adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   // Returns true if the object contains the specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobject/containskey/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||
|   containsKey(const TString& key) const { | ||||
|     return getMember(adaptString(key)) != 0; | ||||
|   FORCE_INLINE | ||||
|       typename detail::enable_if<detail::IsString<TString>::value, bool>::type | ||||
|       containsKey(const TString& key) const { | ||||
|     return getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Returns true if the object contains the specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobject/containskey/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||
|   containsKey(TChar* key) const { | ||||
|     return getMember(adaptString(key)) != 0; | ||||
|   FORCE_INLINE | ||||
|       typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type | ||||
|       containsKey(TChar* key) const { | ||||
|     return getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Creates an array and adds it to the object. | ||||
| @@ -189,20 +193,20 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   MemoryPool* getPool() const { | ||||
|   detail::MemoryPool* getPool() const { | ||||
|     return _pool; | ||||
|   } | ||||
|  | ||||
|   VariantData* getData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   detail::VariantData* getData() const { | ||||
|     return detail::collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   VariantData* getOrCreateData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   detail::VariantData* getOrCreateData() const { | ||||
|     return detail::collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   template <typename TAdaptedString> | ||||
|   inline VariantData* getMember(TAdaptedString key) const { | ||||
|   inline detail::VariantData* getMember(TAdaptedString key) const { | ||||
|     if (!_data) | ||||
|       return 0; | ||||
|     return _data->getMember(key); | ||||
| @@ -215,23 +219,23 @@ class JsonObject : public VariantOperators<JsonObject> { | ||||
|     _data->removeMember(key); | ||||
|   } | ||||
|  | ||||
|   CollectionData* _data; | ||||
|   MemoryPool* _pool; | ||||
|   detail::CollectionData* _data; | ||||
|   detail::MemoryPool* _pool; | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct Converter<JsonObject> : private VariantAttorney { | ||||
| struct Converter<JsonObject> : private detail::VariantAttorney { | ||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||
|   } | ||||
|  | ||||
|   static JsonObject fromJson(JsonVariant src) { | ||||
|     VariantData* data = getData(src); | ||||
|     MemoryPool* pool = getPool(src); | ||||
|     auto data = getData(src); | ||||
|     auto pool = getPool(src); | ||||
|     return JsonObject(pool, data != 0 ? data->asObject() : 0); | ||||
|   } | ||||
|  | ||||
|   static InvalidConversion<JsonVariantConst, JsonObject> fromJson( | ||||
|   static detail::InvalidConversion<JsonVariantConst, JsonObject> fromJson( | ||||
|       JsonVariantConst); | ||||
|  | ||||
|   static bool checkJson(JsonVariantConst) { | ||||
| @@ -239,8 +243,9 @@ struct Converter<JsonObject> : private VariantAttorney { | ||||
|   } | ||||
|  | ||||
|   static bool checkJson(JsonVariant src) { | ||||
|     VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data && data->isObject(); | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -7,13 +7,13 @@ | ||||
| #include <ArduinoJson/Object/JsonObjectIterator.hpp> | ||||
| #include <ArduinoJson/Variant/VariantOperators.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // A read-only reference to an object in a JsonDocument. | ||||
| // https://arduinojson.org/v6/api/jsonobjectconst/ | ||||
| class JsonObjectConst : public VariantOperators<JsonObjectConst> { | ||||
| class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> { | ||||
|   friend class JsonObject; | ||||
|   friend class VariantAttorney; | ||||
|   friend class detail::VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   typedef JsonObjectConstIterator iterator; | ||||
| @@ -22,7 +22,7 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | ||||
|   JsonObjectConst() : _data(0) {} | ||||
|  | ||||
|   // INTERNAL USE ONLY | ||||
|   JsonObjectConst(const CollectionData* data) : _data(data) {} | ||||
|   JsonObjectConst(const detail::CollectionData* data) : _data(data) {} | ||||
|  | ||||
|   operator JsonVariantConst() const { | ||||
|     return JsonVariantConst(collectionToVariant(_data)); | ||||
| @@ -76,32 +76,32 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | ||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE bool containsKey(const TString& key) const { | ||||
|     return getMember(adaptString(key)) != 0; | ||||
|     return getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Returns true if the object contains the specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE bool containsKey(TChar* key) const { | ||||
|     return getMember(adaptString(key)) != 0; | ||||
|     return getMember(detail::adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // Gets the member with specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE | ||||
|       typename enable_if<IsString<TString>::value, JsonVariantConst>::type | ||||
|       operator[](const TString& key) const { | ||||
|     return JsonVariantConst(getMember(adaptString(key))); | ||||
|   FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, | ||||
|                                           JsonVariantConst>::type | ||||
|   operator[](const TString& key) const { | ||||
|     return JsonVariantConst(getMember(detail::adaptString(key))); | ||||
|   } | ||||
|  | ||||
|   // Gets the member with specified key. | ||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE | ||||
|       typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type | ||||
|       operator[](TChar* key) const { | ||||
|     return JsonVariantConst(getMember(adaptString(key))); | ||||
|   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, | ||||
|                                           JsonVariantConst>::type | ||||
|   operator[](TChar* key) const { | ||||
|     return JsonVariantConst(getMember(detail::adaptString(key))); | ||||
|   } | ||||
|  | ||||
|   // Compares objects. | ||||
| @@ -122,35 +122,35 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   const VariantData* getData() const { | ||||
|   const detail::VariantData* getData() const { | ||||
|     return collectionToVariant(_data); | ||||
|   } | ||||
|  | ||||
|   template <typename TAdaptedString> | ||||
|   const VariantData* getMember(TAdaptedString key) const { | ||||
|   const detail::VariantData* getMember(TAdaptedString key) const { | ||||
|     if (!_data) | ||||
|       return 0; | ||||
|     return _data->getMember(key); | ||||
|   } | ||||
|  | ||||
|   const CollectionData* _data; | ||||
|   const detail::CollectionData* _data; | ||||
| }; | ||||
|  | ||||
| template <> | ||||
| struct Converter<JsonObjectConst> : private VariantAttorney { | ||||
| struct Converter<JsonObjectConst> : private detail::VariantAttorney { | ||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||
|   } | ||||
|  | ||||
|   static JsonObjectConst fromJson(JsonVariantConst src) { | ||||
|     const VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data != 0 ? data->asObject() : 0; | ||||
|   } | ||||
|  | ||||
|   static bool checkJson(JsonVariantConst src) { | ||||
|     const VariantData* data = getData(src); | ||||
|     auto data = getData(src); | ||||
|     return data && data->isObject(); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <ArduinoJson/Array/JsonArray.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| template <typename TString> | ||||
| inline JsonArray JsonObject::createNestedArray(const TString& key) const { | ||||
| @@ -19,6 +19,10 @@ inline JsonArray JsonObject::createNestedArray(TChar* key) const { | ||||
|   return operator[](key).template to<JsonArray>(); | ||||
| } | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TDerived> | ||||
| template <typename TString> | ||||
| inline JsonArray VariantRefBase<TDerived>::createNestedArray( | ||||
| @@ -78,4 +82,4 @@ VariantRefBase<TDerived>::operator[](const TString& key) const { | ||||
|   return MemberProxy<TDerived, TString>(derived(), key); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,11 +7,12 @@ | ||||
| #include <ArduinoJson/Object/JsonPair.hpp> | ||||
| #include <ArduinoJson/Variant/SlotFunctions.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| class JsonPairPtr { | ||||
|  public: | ||||
|   JsonPairPtr(MemoryPool* pool, VariantSlot* slot) : _pair(pool, slot) {} | ||||
|   JsonPairPtr(detail::MemoryPool* pool, detail::VariantSlot* slot) | ||||
|       : _pair(pool, slot) {} | ||||
|  | ||||
|   const JsonPair* operator->() const { | ||||
|     return &_pair; | ||||
| @@ -31,7 +32,8 @@ class JsonObjectIterator { | ||||
|  public: | ||||
|   JsonObjectIterator() : _slot(0) {} | ||||
|  | ||||
|   explicit JsonObjectIterator(MemoryPool* pool, VariantSlot* slot) | ||||
|   explicit JsonObjectIterator(detail::MemoryPool* pool, | ||||
|                               detail::VariantSlot* slot) | ||||
|       : _pool(pool), _slot(slot) {} | ||||
|  | ||||
|   JsonPair operator*() const { | ||||
| @@ -60,13 +62,13 @@ class JsonObjectIterator { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   MemoryPool* _pool; | ||||
|   VariantSlot* _slot; | ||||
|   detail::MemoryPool* _pool; | ||||
|   detail::VariantSlot* _slot; | ||||
| }; | ||||
|  | ||||
| class JsonPairConstPtr { | ||||
|  public: | ||||
|   JsonPairConstPtr(const VariantSlot* slot) : _pair(slot) {} | ||||
|   JsonPairConstPtr(const detail::VariantSlot* slot) : _pair(slot) {} | ||||
|  | ||||
|   const JsonPairConst* operator->() const { | ||||
|     return &_pair; | ||||
| @@ -86,7 +88,8 @@ class JsonObjectConstIterator { | ||||
|  public: | ||||
|   JsonObjectConstIterator() : _slot(0) {} | ||||
|  | ||||
|   explicit JsonObjectConstIterator(const VariantSlot* slot) : _slot(slot) {} | ||||
|   explicit JsonObjectConstIterator(const detail::VariantSlot* slot) | ||||
|       : _slot(slot) {} | ||||
|  | ||||
|   JsonPairConst operator*() const { | ||||
|     return JsonPairConst(_slot); | ||||
| @@ -114,6 +117,7 @@ class JsonObjectConstIterator { | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   const VariantSlot* _slot; | ||||
|   const detail::VariantSlot* _slot; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -8,14 +8,14 @@ | ||||
| #include <ArduinoJson/Variant/JsonVariant.hpp> | ||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||
|  | ||||
| // A key-value pair. | ||||
| // https://arduinojson.org/v6/api/jsonobject/begin_end/ | ||||
| class JsonPair { | ||||
|  public: | ||||
|   // INTERNAL USE ONLY | ||||
|   JsonPair(MemoryPool* pool, VariantSlot* slot) { | ||||
|   JsonPair(detail::MemoryPool* pool, detail::VariantSlot* slot) { | ||||
|     if (slot) { | ||||
|       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied | ||||
|                                                      : JsonString::Linked); | ||||
| @@ -42,7 +42,7 @@ class JsonPair { | ||||
| // https://arduinojson.org/v6/api/jsonobjectconst/begin_end/ | ||||
| class JsonPairConst { | ||||
|  public: | ||||
|   JsonPairConst(const VariantSlot* slot) { | ||||
|   JsonPairConst(const detail::VariantSlot* slot) { | ||||
|     if (slot) { | ||||
|       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied | ||||
|                                                      : JsonString::Linked); | ||||
| @@ -64,4 +64,5 @@ class JsonPairConst { | ||||
|   JsonString _key; | ||||
|   JsonVariantConst _value; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Variant/VariantRefBase.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A proxy class to get or set a member of an object. | ||||
| // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||
| @@ -61,4 +61,4 @@ class MemberProxy | ||||
|   TStringRef _key; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
| #include <ArduinoJson/Configuration.hpp> | ||||
| #include "math.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T, typename F> | ||||
| struct alias_cast_t { | ||||
| @@ -26,4 +26,5 @@ T alias_cast(F raw_data) { | ||||
|   ac.raw = raw_data; | ||||
|   return ac.data; | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| #ifndef isdigit | ||||
| inline bool isdigit(char c) { | ||||
| @@ -17,4 +17,5 @@ inline bool isdigit(char c) { | ||||
| inline bool issign(char c) { | ||||
|   return '-' == c || c == '+'; | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <int Bits> | ||||
| struct int_t; | ||||
| @@ -27,4 +27,5 @@ template <> | ||||
| struct int_t<32> { | ||||
|   typedef int32_t type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
| #  pragma warning(disable : 4310) | ||||
| #endif | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // Differs from standard because we can't use the symbols "min" and "max" | ||||
| template <typename T, typename Enable = void> | ||||
| @@ -38,7 +38,7 @@ struct numeric_limits< | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #ifdef _MSC_VER | ||||
| #  pragma warning(pop) | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // Some libraries #define isnan() and isinf() so we need to check before | ||||
| // using this name | ||||
| @@ -24,4 +24,4 @@ bool isinf(T x) { | ||||
|   return x != 0.0 && x * 2 == x; | ||||
| } | ||||
| #endif | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <stddef.h>  // for size_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that returns the highest value | ||||
| template <size_t X, size_t Y, bool MaxIsX = (X > Y)> | ||||
| @@ -23,4 +23,5 @@ template <size_t X, size_t Y> | ||||
| struct Max<X, Y, false> { | ||||
|   static const size_t value = Y; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -10,17 +10,18 @@ | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
| #include <ArduinoJson/Polyfills/assert.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
| // Wraps a const char* so that the our functions are picked only if the | ||||
| // originals are missing | ||||
| struct pgm_p { | ||||
|   pgm_p(const void* p) : address(reinterpret_cast<const char*>(p)) {} | ||||
|   const char* address; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #ifndef strlen_P | ||||
| inline size_t strlen_P(ARDUINOJSON_NAMESPACE::pgm_p s) { | ||||
| inline size_t strlen_P(ArduinoJson::detail::pgm_p s) { | ||||
|   const char* p = s.address; | ||||
|   ARDUINOJSON_ASSERT(p != NULL); | ||||
|   while (pgm_read_byte(p)) | ||||
| @@ -30,7 +31,7 @@ inline size_t strlen_P(ARDUINOJSON_NAMESPACE::pgm_p s) { | ||||
| #endif | ||||
|  | ||||
| #ifndef strncmp_P | ||||
| inline int strncmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { | ||||
| inline int strncmp_P(const char* a, ArduinoJson::detail::pgm_p b, size_t n) { | ||||
|   const char* s1 = a; | ||||
|   const char* s2 = b.address; | ||||
|   ARDUINOJSON_ASSERT(s1 != NULL); | ||||
| @@ -50,7 +51,7 @@ inline int strncmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { | ||||
| #endif | ||||
|  | ||||
| #ifndef strcmp_P | ||||
| inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) { | ||||
| inline int strcmp_P(const char* a, ArduinoJson::detail::pgm_p b) { | ||||
|   const char* s1 = a; | ||||
|   const char* s2 = b.address; | ||||
|   ARDUINOJSON_ASSERT(s1 != NULL); | ||||
| @@ -69,7 +70,7 @@ inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) { | ||||
| #endif | ||||
|  | ||||
| #ifndef memcmp_P | ||||
| inline int memcmp_P(const void* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { | ||||
| inline int memcmp_P(const void* a, ArduinoJson::detail::pgm_p b, size_t n) { | ||||
|   const uint8_t* p1 = reinterpret_cast<const uint8_t*>(a); | ||||
|   const char* p2 = b.address; | ||||
|   ARDUINOJSON_ASSERT(p1 != NULL); | ||||
| @@ -85,7 +86,7 @@ inline int memcmp_P(const void* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) { | ||||
| #endif | ||||
|  | ||||
| #ifndef memcpy_P | ||||
| inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { | ||||
| inline void* memcpy_P(void* dst, ArduinoJson::detail::pgm_p src, size_t n) { | ||||
|   uint8_t* d = reinterpret_cast<uint8_t*>(dst); | ||||
|   const char* s = src.address; | ||||
|   ARDUINOJSON_ASSERT(d != NULL); | ||||
| @@ -98,7 +99,7 @@ inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) { | ||||
| #endif | ||||
|  | ||||
| #ifndef pgm_read_dword | ||||
| inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) { | ||||
| inline uint32_t pgm_read_dword(ArduinoJson::detail::pgm_p p) { | ||||
|   uint32_t result; | ||||
|   memcpy_P(&result, p.address, 4); | ||||
|   return result; | ||||
| @@ -106,7 +107,7 @@ inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) { | ||||
| #endif | ||||
|  | ||||
| #ifndef pgm_read_ptr | ||||
| inline void* pgm_read_ptr(ARDUINOJSON_NAMESPACE::pgm_p p) { | ||||
| inline void* pgm_read_ptr(ArduinoJson::detail::pgm_p p) { | ||||
|   void* result; | ||||
|   memcpy_P(&result, p.address, sizeof(result)); | ||||
|   return result; | ||||
|   | ||||
| @@ -11,7 +11,7 @@ | ||||
| #  include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #endif | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| #if ARDUINOJSON_ENABLE_PROGMEM | ||||
|  | ||||
| @@ -42,4 +42,4 @@ inline T pgm_read(const T* p) { | ||||
|  | ||||
| #endif | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <bool Condition, class TrueType, class FalseType> | ||||
| struct conditional { | ||||
| @@ -17,4 +17,5 @@ template <class TrueType, class FalseType> | ||||
| struct conditional<false, TrueType, FalseType> { | ||||
|   typedef FalseType type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,9 +6,9 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| T declval(); | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that return the type T if Condition is true. | ||||
| template <bool Condition, typename T = void> | ||||
| @@ -16,4 +16,5 @@ template <typename T> | ||||
| struct enable_if<true, T> { | ||||
|   typedef T type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T, T v> | ||||
| struct integral_constant { | ||||
| @@ -16,4 +16,4 @@ struct integral_constant { | ||||
| typedef integral_constant<bool, true> true_type; | ||||
| typedef integral_constant<bool, false> false_type; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| #include <stddef.h>  // size_t | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct is_array : false_type {}; | ||||
| @@ -18,4 +18,5 @@ struct is_array<T[]> : true_type {}; | ||||
|  | ||||
| template <typename T, size_t N> | ||||
| struct is_array<T[N]> : true_type {}; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that returns true if Derived inherits from TBase is an | ||||
| // integral type. | ||||
| @@ -20,4 +20,5 @@ class is_base_of { | ||||
|   static const bool value = | ||||
|       sizeof(probe(reinterpret_cast<TDerived*>(0))) == sizeof(int); | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include "declval.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct is_class { | ||||
| @@ -20,4 +20,4 @@ struct is_class { | ||||
|   static const bool value = sizeof(probe<T>(0)) == sizeof(int); | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include "integral_constant.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that return the type T without the const modifier | ||||
| template <typename T> | ||||
| @@ -14,4 +14,5 @@ struct is_const : false_type {}; | ||||
|  | ||||
| template <typename T> | ||||
| struct is_const<const T> : true_type {}; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -19,7 +19,7 @@ | ||||
| #endif | ||||
| // clang-format on | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename From, typename To> | ||||
| struct is_convertible { | ||||
| @@ -33,7 +33,7 @@ struct is_convertible { | ||||
|   static const bool value = sizeof(probe(_from)) == sizeof(int); | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #ifdef _MSC_VER | ||||
| #  pragma warning(pop) | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
| #include "is_integral.hpp" | ||||
| #include "is_same.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct is_enum { | ||||
| @@ -19,4 +19,4 @@ struct is_enum { | ||||
|                             !is_floating_point<T>::value; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include "is_same.hpp" | ||||
| #include "remove_cv.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <class T> | ||||
| struct is_floating_point | ||||
| @@ -17,4 +17,4 @@ struct is_floating_point | ||||
|           is_same<float, typename remove_cv<T>::type>::value || | ||||
|               is_same<double, typename remove_cv<T>::type>::value> {}; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
| #include "is_same.hpp" | ||||
| #include "remove_cv.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // clang-format off | ||||
| template <typename T> | ||||
| @@ -28,4 +28,5 @@ struct is_integral : integral_constant<bool, | ||||
|     is_same<typename remove_cv<T>::type, char>::value || | ||||
|     is_same<typename remove_cv<T>::type, bool>::value> {}; | ||||
| // clang-format on | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,11 +6,12 @@ | ||||
|  | ||||
| #include "integral_constant.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct is_pointer : false_type {}; | ||||
|  | ||||
| template <typename T> | ||||
| struct is_pointer<T*> : true_type {}; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include "integral_constant.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that returns true if types T and U are the same. | ||||
| template <typename T, typename U> | ||||
| @@ -14,4 +14,5 @@ struct is_same : false_type {}; | ||||
|  | ||||
| template <typename T> | ||||
| struct is_same<T, T> : true_type {}; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include "is_same.hpp" | ||||
| #include "remove_cv.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // clang-format off | ||||
| template <typename T> | ||||
| @@ -22,4 +22,5 @@ struct is_signed : integral_constant<bool, | ||||
|     is_same<typename remove_cv<T>::type, float>::value || | ||||
|     is_same<typename remove_cv<T>::type, double>::value> {}; | ||||
| // clang-format on | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include "is_same.hpp" | ||||
| #include "remove_cv.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // clang-format off | ||||
| template <typename T> | ||||
| @@ -20,4 +20,5 @@ struct is_unsigned : integral_constant<bool, | ||||
|     is_same<typename remove_cv<T>::type, unsigned long long>::value || | ||||
|     is_same<typename remove_cv<T>::type, bool>::value> {}; | ||||
| // clang-format on | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "type_identity.hpp" | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct make_unsigned; | ||||
| @@ -37,4 +37,5 @@ template <> | ||||
| struct make_unsigned<signed long long> : type_identity<unsigned long long> {}; | ||||
| template <> | ||||
| struct make_unsigned<unsigned long long> : type_identity<unsigned long long> {}; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -4,11 +4,11 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <class = void> | ||||
| struct make_void { | ||||
|   typedef void type; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that return the type T without the const modifier | ||||
| template <typename T> | ||||
| @@ -17,4 +17,5 @@ template <typename T> | ||||
| struct remove_const<const T> { | ||||
|   typedef T type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct remove_cv { | ||||
| @@ -24,4 +24,5 @@ template <typename T> | ||||
| struct remove_cv<const volatile T> { | ||||
|   typedef T type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // A meta-function that return the type T without the reference modifier. | ||||
| template <typename T> | ||||
| @@ -17,4 +17,5 @@ template <typename T> | ||||
| struct remove_reference<T&> { | ||||
|   typedef T type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,10 +6,11 @@ | ||||
|  | ||||
| #include "integral_constant.hpp" | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct type_identity { | ||||
|   typedef T type; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TWriter> | ||||
| class CountingDecorator { | ||||
| @@ -30,4 +30,4 @@ class CountingDecorator { | ||||
|   size_t _count; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| // The default writer is a simple wrapper for Writers that are not copiable | ||||
| template <typename TDestination, typename Enable = void> | ||||
| @@ -26,7 +26,7 @@ class Writer { | ||||
|   TDestination* _dest; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|  | ||||
| #include <ArduinoJson/Serialization/Writers/StaticStringWriter.hpp> | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <> | ||||
| class Writer< ::String, void> { | ||||
| @@ -50,4 +50,4 @@ class Writer< ::String, void> { | ||||
|   size_t _size; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class DummyWriter { | ||||
|  public: | ||||
| @@ -18,4 +18,5 @@ class DummyWriter { | ||||
|     return n; | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <Arduino.h> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TDestination> | ||||
| class Writer< | ||||
| @@ -27,4 +27,4 @@ class Writer< | ||||
|   ::Print* _print; | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class StaticStringWriter { | ||||
|  public: | ||||
| @@ -32,4 +32,5 @@ class StaticStringWriter { | ||||
|   char* end; | ||||
|   char* p; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ostream> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TDestination> | ||||
| class Writer< | ||||
| @@ -29,4 +29,5 @@ class Writer< | ||||
|  private: | ||||
|   std::ostream* _os; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
| #include <string> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <class T> | ||||
| struct is_std_string : false_type {}; | ||||
| @@ -37,4 +37,5 @@ class Writer<TDestination, | ||||
|  private: | ||||
|   TDestination* _str; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,13 +7,13 @@ | ||||
| #include <ArduinoJson/Serialization/Writers/DummyWriter.hpp> | ||||
| #include <ArduinoJson/Variant/VariantFunctions.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <template <typename> class TSerializer> | ||||
| size_t measure(JsonVariantConst source) { | ||||
| size_t measure(ArduinoJson::JsonVariantConst source) { | ||||
|   DummyWriter dp; | ||||
|   TSerializer<DummyWriter> serializer(dp); | ||||
|   return variantAccept(VariantAttorney::getData(source), serializer); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,30 +7,33 @@ | ||||
| #include <ArduinoJson/Serialization/Writer.hpp> | ||||
| #include <ArduinoJson/Variant/VariantFunctions.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <template <typename> class TSerializer, typename TWriter> | ||||
| size_t doSerialize(JsonVariantConst source, TWriter writer) { | ||||
| size_t doSerialize(ArduinoJson::JsonVariantConst source, TWriter writer) { | ||||
|   TSerializer<TWriter> serializer(writer); | ||||
|   return variantAccept(VariantAttorney::getData(source), serializer); | ||||
| } | ||||
|  | ||||
| template <template <typename> class TSerializer, typename TDestination> | ||||
| size_t serialize(JsonVariantConst source, TDestination& destination) { | ||||
| size_t serialize(ArduinoJson::JsonVariantConst source, | ||||
|                  TDestination& destination) { | ||||
|   Writer<TDestination> writer(destination); | ||||
|   return doSerialize<TSerializer>(source, writer); | ||||
| } | ||||
|  | ||||
| template <template <typename> class TSerializer> | ||||
| typename enable_if<!TSerializer<StaticStringWriter>::producesText, size_t>::type | ||||
| serialize(JsonVariantConst source, void* buffer, size_t bufferSize) { | ||||
| serialize(ArduinoJson::JsonVariantConst source, void* buffer, | ||||
|           size_t bufferSize) { | ||||
|   StaticStringWriter writer(reinterpret_cast<char*>(buffer), bufferSize); | ||||
|   return doSerialize<TSerializer>(source, writer); | ||||
| } | ||||
|  | ||||
| template <template <typename> class TSerializer> | ||||
| typename enable_if<TSerializer<StaticStringWriter>::producesText, size_t>::type | ||||
| serialize(JsonVariantConst source, void* buffer, size_t bufferSize) { | ||||
| serialize(ArduinoJson::JsonVariantConst source, void* buffer, | ||||
|           size_t bufferSize) { | ||||
|   StaticStringWriter writer(reinterpret_cast<char*>(buffer), bufferSize); | ||||
|   size_t n = doSerialize<TSerializer>(source, writer); | ||||
|   // add null-terminator for text output (not counted in the size) | ||||
| @@ -41,8 +44,8 @@ serialize(JsonVariantConst source, void* buffer, size_t bufferSize) { | ||||
|  | ||||
| template <template <typename> class TSerializer, typename TChar, size_t N> | ||||
| typename enable_if<IsChar<TChar>::value, size_t>::type serialize( | ||||
|     JsonVariantConst source, TChar (&buffer)[N]) { | ||||
|     ArduinoJson::JsonVariantConst source, TChar (&buffer)[N]) { | ||||
|   return serialize<TSerializer>(source, buffer, N); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Memory/MemoryPool.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class StringCopier { | ||||
|  public: | ||||
| @@ -68,4 +68,5 @@ class StringCopier { | ||||
|   // NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.UninitializedObject) | ||||
|   size_t _size, _capacity; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <ArduinoJson/Namespace.hpp> | ||||
| #include <ArduinoJson/Strings/JsonString.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class StringMover { | ||||
|  public: | ||||
| @@ -44,4 +44,5 @@ class StringMover { | ||||
|   char* _writePtr; | ||||
|   char* _startPtr; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|  | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
| #include <ArduinoJson/StringStorage/StringCopier.hpp> | ||||
| #include <ArduinoJson/StringStorage/StringMover.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename TInput> | ||||
| StringCopier makeStringStorage(TInput&, MemoryPool* pool) { | ||||
| @@ -21,4 +21,4 @@ StringMover makeStringStorage( | ||||
|     typename enable_if<!is_const<TChar>::value>::type* = 0) { | ||||
|   return StringMover(reinterpret_cast<char*>(input)); | ||||
| } | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| #include <ArduinoJson/Strings/Adapters/RamString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| template <typename T> | ||||
| struct StringAdapter< | ||||
| @@ -22,4 +22,4 @@ struct StringAdapter< | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| #include <ArduinoJson/Polyfills/pgmspace.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class FlashString { | ||||
|  public: | ||||
| @@ -88,4 +88,4 @@ struct SizedStringAdapter<const __FlashStringHelper*, void> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include <ArduinoJson/Strings/JsonString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapter.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||
|  | ||||
| class JsonStringAdapter : public SizedRamString { | ||||
|  public: | ||||
| @@ -33,4 +33,4 @@ struct StringAdapter<JsonString> { | ||||
|   } | ||||
| }; | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user