mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Renamed JsonKey to JsonString
				
					
				
			This commit is contained in:
		| @@ -8,6 +8,7 @@ HEAD | |||||||
| * Restored the monotonic allocator because the code was getting too big | * Restored the monotonic allocator because the code was getting too big | ||||||
| * Reduced the memory usage | * Reduced the memory usage | ||||||
| * Reduced the code size | * Reduced the code size | ||||||
|  | * Renamed `JsonKey` to `JsonString` | ||||||
| * Removed spurious files in the Particle library | * Removed spurious files in the Particle library | ||||||
|  |  | ||||||
| v6.6.0-beta (2018-11-13) | v6.6.0-beta (2018-11-13) | ||||||
|   | |||||||
| @@ -38,9 +38,9 @@ typedef ARDUINOJSON_NAMESPACE::Pair JsonPair; | |||||||
| typedef ARDUINOJSON_NAMESPACE::UInt JsonUInt; | typedef ARDUINOJSON_NAMESPACE::UInt JsonUInt; | ||||||
| typedef ARDUINOJSON_NAMESPACE::VariantRef JsonVariant; | typedef ARDUINOJSON_NAMESPACE::VariantRef JsonVariant; | ||||||
| typedef ARDUINOJSON_NAMESPACE::VariantConstRef JsonVariantConst; | typedef ARDUINOJSON_NAMESPACE::VariantConstRef JsonVariantConst; | ||||||
|  | typedef ARDUINOJSON_NAMESPACE::String JsonString; | ||||||
| using ARDUINOJSON_NAMESPACE::DeserializationError; | using ARDUINOJSON_NAMESPACE::DeserializationError; | ||||||
| using ARDUINOJSON_NAMESPACE::DynamicJsonDocument; | using ARDUINOJSON_NAMESPACE::DynamicJsonDocument; | ||||||
| using ARDUINOJSON_NAMESPACE::Key; |  | ||||||
| using ARDUINOJSON_NAMESPACE::serialized; | using ARDUINOJSON_NAMESPACE::serialized; | ||||||
| using ARDUINOJSON_NAMESPACE::StaticJsonDocument; | using ARDUINOJSON_NAMESPACE::StaticJsonDocument; | ||||||
| }  // namespace ArduinoJson | }  // namespace ArduinoJson | ||||||
|   | |||||||
| @@ -101,7 +101,7 @@ class ArrayRef : public ArrayRefBase<CollectionData>, public Visitable { | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // bool add(TValue); |   // bool add(TValue); | ||||||
|   // TValue = char*, const char*, const FlashStringHelper* |   // TValue = char*, const char*, const __FlashStringHelper* | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool add(T* value) const { |   FORCE_INLINE bool add(T* value) const { | ||||||
|     return add().set(value); |     return add().set(value); | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ class ArraySubscript : public VariantOperators<ArraySubscript>, | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // operator=(TValue) |   // operator=(TValue) | ||||||
|   // TValue = char*, const char*, const FlashStringHelper* |   // TValue = char*, const char*, const __FlashStringHelper* | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE ArraySubscript& operator=(T* src) { |   FORCE_INLINE ArraySubscript& operator=(T* src) { | ||||||
|     get_impl().set(src); |     get_impl().set(src); | ||||||
| @@ -73,7 +73,7 @@ class ArraySubscript : public VariantOperators<ArraySubscript>, | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // bool set(TValue) |   // bool set(TValue) | ||||||
|   // TValue = char*, const char*, const FlashStringHelper* |   // TValue = char*, const char*, const __FlashStringHelper* | ||||||
|   template <typename TValue> |   template <typename TValue> | ||||||
|   FORCE_INLINE bool set(TValue* value) const { |   FORCE_INLINE bool set(TValue* value) const { | ||||||
|     return get_impl().set(value); |     return get_impl().set(value); | ||||||
|   | |||||||
| @@ -53,9 +53,9 @@ inline bool CollectionData::copyFrom(const CollectionData& src, | |||||||
|     VariantData* var; |     VariantData* var; | ||||||
|     if (s->key() != 0) { |     if (s->key() != 0) { | ||||||
|       if (s->ownsKey()) |       if (s->ownsKey()) | ||||||
|         var = add(ZeroTerminatedRamString(s->key()), pool); |         var = add(RamStringWrapper(s->key()), pool); | ||||||
|       else |       else | ||||||
|         var = add(ZeroTerminatedRamStringConst(s->key()), pool); |         var = add(ConstRamStringWrapper(s->key()), pool); | ||||||
|     } else { |     } else { | ||||||
|       var = add(pool); |       var = add(pool); | ||||||
|     } |     } | ||||||
| @@ -69,7 +69,7 @@ inline bool CollectionData::equalsObject(const CollectionData& other) const { | |||||||
|   size_t count = 0; |   size_t count = 0; | ||||||
|   for (VariantSlot* slot = _head; slot; slot = slot->next()) { |   for (VariantSlot* slot = _head; slot; slot = slot->next()) { | ||||||
|     VariantData* v1 = slot->data(); |     VariantData* v1 = slot->data(); | ||||||
|     VariantData* v2 = other.get(makeString(slot->key())); |     VariantData* v2 = other.get(wrapString(slot->key())); | ||||||
|     if (!variantEquals(v1, v2)) return false; |     if (!variantEquals(v1, v2)) return false; | ||||||
|     count++; |     count++; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -51,7 +51,7 @@ inline SafeCharPointerReader makeReader(TChar* input, size_t n) { | |||||||
| } | } | ||||||
|  |  | ||||||
| #if ARDUINOJSON_ENABLE_ARDUINO_STRING | #if ARDUINOJSON_ENABLE_ARDUINO_STRING | ||||||
| inline SafeCharPointerReader makeReader(const String& input) { | inline SafeCharPointerReader makeReader(const ::String& input) { | ||||||
|   return SafeCharPointerReader(input.c_str(), input.length()); |   return SafeCharPointerReader(input.c_str(), input.length()); | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -35,7 +35,7 @@ deserialize(JsonDocument &doc, const TString &input) { | |||||||
| } | } | ||||||
| // | // | ||||||
| // DeserializationError deserialize(JsonDocument& doc, TChar* input); | // DeserializationError deserialize(JsonDocument& doc, TChar* input); | ||||||
| // TChar* = char*, const char*, const FlashStringHelper* | // TChar* = char*, const char*, const __FlashStringHelper* | ||||||
| template <template <typename, typename> class TDeserializer, typename TChar> | template <template <typename, typename> class TDeserializer, typename TChar> | ||||||
| DeserializationError deserialize(JsonDocument &doc, TChar *input) { | DeserializationError deserialize(JsonDocument &doc, TChar *input) { | ||||||
|   doc.clear(); |   doc.clear(); | ||||||
| @@ -47,7 +47,7 @@ DeserializationError deserialize(JsonDocument &doc, TChar *input) { | |||||||
| // | // | ||||||
| // DeserializationError deserialize(JsonDocument& doc, TChar* input, size_t | // DeserializationError deserialize(JsonDocument& doc, TChar* input, size_t | ||||||
| // inputSize); | // inputSize); | ||||||
| // TChar* = char*, const char*, const FlashStringHelper* | // TChar* = char*, const char*, const __FlashStringHelper* | ||||||
| template <template <typename, typename> class TDeserializer, typename TChar> | template <template <typename, typename> class TDeserializer, typename TChar> | ||||||
| DeserializationError deserialize(JsonDocument &doc, TChar *input, | DeserializationError deserialize(JsonDocument &doc, TChar *input, | ||||||
|                                  size_t inputSize) { |                                  size_t inputSize) { | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| #include "../Strings/StringTypes.hpp" | #include "../Strings/StringWrappers.hpp" | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
|  |  | ||||||
| @@ -58,7 +58,7 @@ inline SerializedValue<T> serialized(T str) { | |||||||
|  |  | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline SerializedValue<TChar*> serialized(TChar* p) { | inline SerializedValue<TChar*> serialized(TChar* p) { | ||||||
|   return SerializedValue<TChar*>(p, makeString(p).size()); |   return SerializedValue<TChar*>(p, wrapString(p).size()); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
|   | |||||||
| @@ -1,33 +0,0 @@ | |||||||
| // ArduinoJson - arduinojson.org |  | ||||||
| // Copyright Benoit Blanchon 2014-2018 |  | ||||||
| // MIT License |  | ||||||
|  |  | ||||||
| #pragma once |  | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { |  | ||||||
|  |  | ||||||
| class Key { |  | ||||||
|  public: |  | ||||||
|   Key(const VariantSlot* slot) : _slot(slot) {} |  | ||||||
|  |  | ||||||
|   operator const char*() const { |  | ||||||
|     return c_str(); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   const char* c_str() const { |  | ||||||
|     return _slot ? _slot->key() : 0; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   bool isNull() const { |  | ||||||
|     return _slot == 0 || _slot->key() == 0; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   friend bool operator==(Key lhs, const char* rhs) { |  | ||||||
|     if (lhs.isNull()) return rhs == 0; |  | ||||||
|     return rhs ? !strcmp(lhs, rhs) : false; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|  private: |  | ||||||
|   const VariantSlot* _slot; |  | ||||||
| }; |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
| @@ -28,14 +28,14 @@ class ObjectRefBase { | |||||||
|   // TKey = const std::string&, const String& |   // TKey = const std::string&, const String& | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE bool containsKey(const TKey& key) const { |   FORCE_INLINE bool containsKey(const TKey& key) const { | ||||||
|     return objectContainsKey(_data, makeString(key)); |     return objectContainsKey(_data, wrapString(key)); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // bool containsKey(TKey); |   // bool containsKey(TKey); | ||||||
|   // TKey = char*, const char*, char[], const char[], const FlashStringHelper* |   // TKey = char*, const char*, char[], const char[], const __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE bool containsKey(TKey* key) const { |   FORCE_INLINE bool containsKey(TKey* key) const { | ||||||
|     return objectContainsKey(_data, makeString(key)); |     return objectContainsKey(_data, wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE bool isNull() const { |   FORCE_INLINE bool isNull() const { | ||||||
| @@ -79,16 +79,16 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   //          std::string, String, ArrayConstRef, ObjectConstRef |   //          std::string, String, ArrayConstRef, ObjectConstRef | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantConstRef get(const TKey& key) const { |   FORCE_INLINE VariantConstRef get(const TKey& key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // TValue get<TValue>(TKey) const; |   // TValue get<TValue>(TKey) const; | ||||||
|   // TKey = char*, const char*, const FlashStringHelper* |   // TKey = char*, const char*, const __FlashStringHelper* | ||||||
|   // TValue = bool, char, long, int, short, float, double, |   // TValue = bool, char, long, int, short, float, double, | ||||||
|   //          std::string, String, ArrayConstRef, ObjectConstRef |   //          std::string, String, ArrayConstRef, ObjectConstRef | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantConstRef get(TKey* key) const { |   FORCE_INLINE VariantConstRef get(TKey* key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // |   // | ||||||
| @@ -97,15 +97,15 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TKey>::value, VariantConstRef>::type |   FORCE_INLINE typename enable_if<IsString<TKey>::value, VariantConstRef>::type | ||||||
|   operator[](const TKey& key) const { |   operator[](const TKey& key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // VariantConstRef operator[](TKey) const; |   // VariantConstRef operator[](TKey) const; | ||||||
|   // TKey = const char*, const char[N], const FlashStringHelper* |   // TKey = const char*, const char[N], const __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TKey*>::value, VariantConstRef>::type |   FORCE_INLINE typename enable_if<IsString<TKey*>::value, VariantConstRef>::type | ||||||
|   operator[](TKey* key) const { |   operator[](TKey* key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE bool operator==(ObjectConstRef rhs) const { |   FORCE_INLINE bool operator==(ObjectConstRef rhs) const { | ||||||
| @@ -163,7 +163,7 @@ class ObjectRef : public ObjectRefBase<CollectionData>, public Visitable { | |||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE ArrayRef createNestedArray(const TKey& key) const; |   FORCE_INLINE ArrayRef createNestedArray(const TKey& key) const; | ||||||
|   // ArrayRef createNestedArray(TKey); |   // ArrayRef createNestedArray(TKey); | ||||||
|   // TKey = char*, const char*, char[], const char[], const FlashStringHelper* |   // TKey = char*, const char*, char[], const char[], const __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE ArrayRef createNestedArray(TKey* key) const; |   FORCE_INLINE ArrayRef createNestedArray(TKey* key) const; | ||||||
|  |  | ||||||
| @@ -177,7 +177,7 @@ class ObjectRef : public ObjectRefBase<CollectionData>, public Visitable { | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // ObjectRef createNestedObject(TKey); |   // ObjectRef createNestedObject(TKey); | ||||||
|   // TKey = char*, const char*, char[], const char[], const FlashStringHelper* |   // TKey = char*, const char*, char[], const char[], const __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE ObjectRef createNestedObject(TKey* key) const { |   FORCE_INLINE ObjectRef createNestedObject(TKey* key) const { | ||||||
|     return set(key).template to<ObjectRef>(); |     return set(key).template to<ObjectRef>(); | ||||||
| @@ -191,16 +191,16 @@ class ObjectRef : public ObjectRefBase<CollectionData>, public Visitable { | |||||||
|   //          std::string, String, ArrayRef, ObjectRef |   //          std::string, String, ArrayRef, ObjectRef | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantRef get(const TKey& key) const { |   FORCE_INLINE VariantRef get(const TKey& key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // TValue get<TValue>(TKey) const; |   // TValue get<TValue>(TKey) const; | ||||||
|   // TKey = char*, const char*, const FlashStringHelper* |   // TKey = char*, const char*, const __FlashStringHelper* | ||||||
|   // TValue = bool, char, long, int, short, float, double, |   // TValue = bool, char, long, int, short, float, double, | ||||||
|   //          std::string, String, ArrayRef, ObjectRef |   //          std::string, String, ArrayRef, ObjectRef | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantRef get(TKey* key) const { |   FORCE_INLINE VariantRef get(TKey* key) const { | ||||||
|     return get_impl(makeString(key)); |     return get_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets or sets the value associated with the specified key. |   // Gets or sets the value associated with the specified key. | ||||||
| @@ -213,7 +213,8 @@ class ObjectRef : public ObjectRefBase<CollectionData>, public Visitable { | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // ObjectSubscript operator[](TKey) |   // ObjectSubscript operator[](TKey) | ||||||
|   // TKey = char*, const char*, char[], const char[N], const FlashStringHelper* |   // TKey = char*, const char*, char[], const char[N], const | ||||||
|  |   // __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE ObjectSubscript<TKey*> operator[](TKey* key) const { |   FORCE_INLINE ObjectSubscript<TKey*> operator[](TKey* key) const { | ||||||
|     return ObjectSubscript<TKey*>(*this, key); |     return ObjectSubscript<TKey*>(*this, key); | ||||||
| @@ -234,24 +235,24 @@ class ObjectRef : public ObjectRefBase<CollectionData>, public Visitable { | |||||||
|   // TKey = const std::string&, const String& |   // TKey = const std::string&, const String& | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE void remove(const TKey& key) const { |   FORCE_INLINE void remove(const TKey& key) const { | ||||||
|     objectRemove(_data, makeString(key)); |     objectRemove(_data, wrapString(key)); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // void remove(TKey); |   // void remove(TKey); | ||||||
|   // TKey = char*, const char*, char[], const char[], const FlashStringHelper* |   // TKey = char*, const char*, char[], const char[], const __FlashStringHelper* | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE void remove(TKey* key) const { |   FORCE_INLINE void remove(TKey* key) const { | ||||||
|     objectRemove(_data, makeString(key)); |     objectRemove(_data, wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantRef set(TKey* key) const { |   FORCE_INLINE VariantRef set(TKey* key) const { | ||||||
|     return set_impl(makeString(key)); |     return set_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TKey> |   template <typename TKey> | ||||||
|   FORCE_INLINE VariantRef set(const TKey& key) const { |   FORCE_INLINE VariantRef set(const TKey& key) const { | ||||||
|     return set_impl(makeString(key)); |     return set_impl(wrapString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ class ObjectSubscript : public VariantOperators<ObjectSubscript<TStringRef> >, | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // operator=(TValue); |   // operator=(TValue); | ||||||
|   // TValue = char*, const char*, const FlashStringHelper* |   // TValue = char*, const char*, const __FlashStringHelper* | ||||||
|   template <typename TValue> |   template <typename TValue> | ||||||
|   FORCE_INLINE this_type &operator=(TValue *src) { |   FORCE_INLINE this_type &operator=(TValue *src) { | ||||||
|     set_impl().set(src); |     set_impl().set(src); | ||||||
| @@ -85,7 +85,7 @@ class ObjectSubscript : public VariantOperators<ObjectSubscript<TStringRef> >, | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // bool set(TValue); |   // bool set(TValue); | ||||||
|   // TValue = char*, const char, const FlashStringHelper* |   // TValue = char*, const char, const __FlashStringHelper* | ||||||
|   template <typename TValue> |   template <typename TValue> | ||||||
|   FORCE_INLINE bool set(const TValue *value) { |   FORCE_INLINE bool set(const TValue *value) { | ||||||
|     return set_impl().set(value); |     return set_impl().set(value); | ||||||
|   | |||||||
| @@ -4,20 +4,21 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
|  | #include "../Strings/String.hpp" | ||||||
| #include "../Variant/VariantRef.hpp" | #include "../Variant/VariantRef.hpp" | ||||||
| #include "Key.hpp" |  | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| // A key value pair for CollectionData. | // A key value pair for CollectionData. | ||||||
| class Pair { | class Pair { | ||||||
|  public: |  public: | ||||||
|   Pair(MemoryPool* pool, VariantSlot* slot) : _key(slot) { |   Pair(MemoryPool* pool, VariantSlot* slot) { | ||||||
|     if (slot) { |     if (slot) { | ||||||
|  |       _key = slot->key(); | ||||||
|       _value = VariantRef(pool, slot->data()); |       _value = VariantRef(pool, slot->data()); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Key key() const { |   String key() const { | ||||||
|     return _key; |     return _key; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -26,19 +27,20 @@ class Pair { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   Key _key; |   String _key; | ||||||
|   VariantRef _value; |   VariantRef _value; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class PairConst { | class PairConst { | ||||||
|  public: |  public: | ||||||
|   PairConst(const VariantSlot* slot) : _key(slot) { |   PairConst(const VariantSlot* slot) { | ||||||
|     if (slot) { |     if (slot) { | ||||||
|  |       _key = slot->key(); | ||||||
|       _value = VariantConstRef(slot->data()); |       _value = VariantConstRef(slot->data()); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   Key key() const { |   String key() const { | ||||||
|     return _key; |     return _key; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -47,7 +49,7 @@ class PairConst { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   Key _key; |   String _key; | ||||||
|   VariantConstRef _value; |   VariantConstRef _value; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -21,28 +21,28 @@ class VariantComparisons { | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T *>::value, bool>::type operator==( |   friend typename enable_if<IsString<T *>::value, bool>::type operator==( | ||||||
|       T *lhs, TVariant rhs) { |       T *lhs, TVariant rhs) { | ||||||
|     return makeString(lhs).equals(rhs.template as<const char *>()); |     return wrapString(lhs).equals(rhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // std::string == TVariant |   // std::string == TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T>::value, bool>::type operator==( |   friend typename enable_if<IsString<T>::value, bool>::type operator==( | ||||||
|       const T &lhs, TVariant rhs) { |       const T &lhs, TVariant rhs) { | ||||||
|     return makeString(lhs).equals(rhs.template as<const char *>()); |     return wrapString(lhs).equals(rhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant == const char* |   // TVariant == const char* | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T *>::value, bool>::type operator==( |   friend typename enable_if<IsString<T *>::value, bool>::type operator==( | ||||||
|       TVariant lhs, T *rhs) { |       TVariant lhs, T *rhs) { | ||||||
|     return makeString(rhs).equals(lhs.template as<const char *>()); |     return wrapString(rhs).equals(lhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant == std::string |   // TVariant == std::string | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T>::value, bool>::type operator==( |   friend typename enable_if<IsString<T>::value, bool>::type operator==( | ||||||
|       TVariant lhs, const T &rhs) { |       TVariant lhs, const T &rhs) { | ||||||
|     return makeString(rhs).equals(lhs.template as<const char *>()); |     return wrapString(rhs).equals(lhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // bool/int/float == TVariant |   // bool/int/float == TVariant | ||||||
| @@ -63,28 +63,28 @@ class VariantComparisons { | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T *>::value, bool>::type operator!=( |   friend typename enable_if<IsString<T *>::value, bool>::type operator!=( | ||||||
|       T *lhs, TVariant rhs) { |       T *lhs, TVariant rhs) { | ||||||
|     return !makeString(lhs).equals(rhs.template as<const char *>()); |     return !wrapString(lhs).equals(rhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // std::string != TVariant |   // std::string != TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T>::value, bool>::type operator!=( |   friend typename enable_if<IsString<T>::value, bool>::type operator!=( | ||||||
|       const T &lhs, TVariant rhs) { |       const T &lhs, TVariant rhs) { | ||||||
|     return !makeString(lhs).equals(rhs.template as<const char *>()); |     return !wrapString(lhs).equals(rhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant != const char* |   // TVariant != const char* | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T *>::value, bool>::type operator!=( |   friend typename enable_if<IsString<T *>::value, bool>::type operator!=( | ||||||
|       TVariant lhs, T *rhs) { |       TVariant lhs, T *rhs) { | ||||||
|     return !makeString(rhs).equals(lhs.template as<const char *>()); |     return !wrapString(rhs).equals(lhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant != std::string |   // TVariant != std::string | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsString<T>::value, bool>::type operator!=( |   friend typename enable_if<IsString<T>::value, bool>::type operator!=( | ||||||
|       TVariant lhs, const T &rhs) { |       TVariant lhs, const T &rhs) { | ||||||
|     return !makeString(rhs).equals(lhs.template as<const char *>()); |     return !wrapString(rhs).equals(lhs.template as<const char *>()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // bool/int/float != TVariant |   // bool/int/float != TVariant | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include "../Polyfills/attributes.hpp" | #include "../Polyfills/attributes.hpp" | ||||||
| #include "../Polyfills/type_traits.hpp" | #include "../Polyfills/type_traits.hpp" | ||||||
| #include "../Strings/StringTypes.hpp" | #include "../Strings/StringWrappers.hpp" | ||||||
| #include "../Variant/VariantAs.hpp" | #include "../Variant/VariantAs.hpp" | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| @@ -37,7 +37,7 @@ class VariantSubscripts { | |||||||
|   operator[](const TString &key) const; |   operator[](const TString &key) const; | ||||||
|   // |   // | ||||||
|   // ObjectSubscript operator[](TKey) const; |   // ObjectSubscript operator[](TKey) const; | ||||||
|   // TKey = const char*, const char[N], const FlashStringHelper* |   // TKey = const char*, const char[N], const __FlashStringHelper* | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString *>::value, |   FORCE_INLINE typename enable_if<IsString<TString *>::value, | ||||||
|                                   ObjectSubscript<TString *> >::type |                                   ObjectSubscript<TString *> >::type | ||||||
|   | |||||||
| @@ -8,9 +8,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class ArduinoString { | class ArduinoStringWrapper { | ||||||
|  public: |  public: | ||||||
|   ArduinoString(const ::String& str) : _str(&str) {} |   ArduinoStringWrapper(const ::String& str) : _str(&str) {} | ||||||
| 
 | 
 | ||||||
|   char* save(MemoryPool* pool) const { |   char* save(MemoryPool* pool) const { | ||||||
|     if (isNull()) return NULL; |     if (isNull()) return NULL; | ||||||
| @@ -50,8 +50,8 @@ struct IsString< ::String> : true_type {}; | |||||||
| template <> | template <> | ||||||
| struct IsString< ::StringSumHelper> : true_type {}; | struct IsString< ::StringSumHelper> : true_type {}; | ||||||
| 
 | 
 | ||||||
| inline ArduinoString makeString(const ::String& str) { | inline ArduinoStringWrapper wrapString(const ::String& str) { | ||||||
|   return ArduinoString(str); |   return ArduinoStringWrapper(str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
| @@ -9,9 +9,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class ZeroTerminatedRamStringConst { | class ConstRamStringWrapper { | ||||||
|  public: |  public: | ||||||
|   ZeroTerminatedRamStringConst(const char* str = 0) : _str(str) {} |   ConstRamStringWrapper(const char* str = 0) : _str(str) {} | ||||||
| 
 | 
 | ||||||
|   bool equals(const char* expected) const { |   bool equals(const char* expected) const { | ||||||
|     const char* actual = _str; |     const char* actual = _str; | ||||||
| @@ -40,8 +40,8 @@ class ZeroTerminatedRamStringConst { | |||||||
|   const char* _str; |   const char* _str; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| inline ZeroTerminatedRamStringConst makeString(const char* str) { | inline ConstRamStringWrapper wrapString(const char* str) { | ||||||
|   return ZeroTerminatedRamStringConst(str); |   return ConstRamStringWrapper(str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
| @@ -6,9 +6,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class ZeroTerminatedFlashString { | class FlashStringWrapper { | ||||||
|  public: |  public: | ||||||
|   ZeroTerminatedFlashString(const __FlashStringHelper* str) : _str(str) {} |   FlashStringWrapper(const __FlashStringHelper* str) : _str(str) {} | ||||||
| 
 | 
 | ||||||
|   bool equals(const char* expected) const { |   bool equals(const char* expected) const { | ||||||
|     const char* actual = reinterpret_cast<const char*>(_str); |     const char* actual = reinterpret_cast<const char*>(_str); | ||||||
| @@ -36,8 +36,8 @@ class ZeroTerminatedFlashString { | |||||||
|   const __FlashStringHelper* _str; |   const __FlashStringHelper* _str; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| inline ZeroTerminatedFlashString makeString(const __FlashStringHelper* str) { | inline FlashStringWrapper wrapString(const __FlashStringHelper* str) { | ||||||
|   return ZeroTerminatedFlashString(str); |   return FlashStringWrapper(str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template <> | template <> | ||||||
| @@ -4,14 +4,13 @@ | |||||||
| 
 | 
 | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include "ZeroTerminatedRamStringConst.hpp" | #include "ConstRamStringWrapper.hpp" | ||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class ZeroTerminatedRamString : public ZeroTerminatedRamStringConst { | class RamStringWrapper : public ConstRamStringWrapper { | ||||||
|  public: |  public: | ||||||
|   ZeroTerminatedRamString(const char* str) |   RamStringWrapper(const char* str) : ConstRamStringWrapper(str) {} | ||||||
|       : ZeroTerminatedRamStringConst(str) {} |  | ||||||
| 
 | 
 | ||||||
|   char* save(MemoryPool* pool) const { |   char* save(MemoryPool* pool) const { | ||||||
|     if (!_str) return NULL; |     if (!_str) return NULL; | ||||||
| @@ -23,12 +22,12 @@ class ZeroTerminatedRamString : public ZeroTerminatedRamStringConst { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline ZeroTerminatedRamString makeString(const TChar* str) { | inline RamStringWrapper wrapString(const TChar* str) { | ||||||
|   return ZeroTerminatedRamString(reinterpret_cast<const char*>(str)); |   return RamStringWrapper(reinterpret_cast<const char*>(str)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| inline ZeroTerminatedRamString makeString(char* str) { | inline RamStringWrapper wrapString(char* str) { | ||||||
|   return ZeroTerminatedRamString(str); |   return RamStringWrapper(str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| @@ -6,9 +6,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class FixedSizeFlashString { | class SizedFlashStringWrapper { | ||||||
|  public: |  public: | ||||||
|   FixedSizeFlashString(const __FlashStringHelper* str, size_t sz) |   SizedFlashStringWrapper(const __FlashStringHelper* str, size_t sz) | ||||||
|       : _str(str), _size(sz) {} |       : _str(str), _size(sz) {} | ||||||
| 
 | 
 | ||||||
|   bool equals(const char* expected) const { |   bool equals(const char* expected) const { | ||||||
| @@ -37,8 +37,8 @@ class FixedSizeFlashString { | |||||||
|   size_t _size; |   size_t _size; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| inline FixedSizeFlashString makeString(const __FlashStringHelper* str, | inline SizedFlashStringWrapper wrapString(const __FlashStringHelper* str, | ||||||
|                                        size_t sz) { |                                           size_t sz) { | ||||||
|   return FixedSizeFlashString(str, sz); |   return SizedFlashStringWrapper(str, sz); | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
| @@ -8,9 +8,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class FixedSizeRamString { | class SizedRamStringWrapper { | ||||||
|  public: |  public: | ||||||
|   FixedSizeRamString(const char* str, size_t n) : _str(str), _size(n) {} |   SizedRamStringWrapper(const char* str, size_t n) : _str(str), _size(n) {} | ||||||
| 
 | 
 | ||||||
|   bool equals(const char* expected) const { |   bool equals(const char* expected) const { | ||||||
|     const char* actual = reinterpret_cast<const char*>(_str); |     const char* actual = reinterpret_cast<const char*>(_str); | ||||||
| @@ -39,8 +39,8 @@ class FixedSizeRamString { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline FixedSizeRamString makeString(const TChar* str, size_t size) { | inline SizedRamStringWrapper wrapString(const TChar* str, size_t size) { | ||||||
|   return FixedSizeRamString(reinterpret_cast<const char*>(str), size); |   return SizedRamStringWrapper(reinterpret_cast<const char*>(str), size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
| @@ -8,9 +8,9 @@ | |||||||
| 
 | 
 | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| 
 | 
 | ||||||
| class StlString { | class StlStringWrapper { | ||||||
|  public: |  public: | ||||||
|   StlString(const std::string& str) : _str(&str) {} |   StlStringWrapper(const std::string& str) : _str(&str) {} | ||||||
| 
 | 
 | ||||||
|   char* save(MemoryPool* pool) const { |   char* save(MemoryPool* pool) const { | ||||||
|     size_t n = _str->length() + 1; |     size_t n = _str->length() + 1; | ||||||
| @@ -43,8 +43,8 @@ class StlString { | |||||||
| template <> | template <> | ||||||
| struct IsString<std::string> : true_type {}; | struct IsString<std::string> : true_type {}; | ||||||
| 
 | 
 | ||||||
| inline StlString makeString(const std::string& str) { | inline StlStringWrapper wrapString(const std::string& str) { | ||||||
|   return StlString(str); |   return StlStringWrapper(str); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
							
								
								
									
										32
									
								
								src/ArduinoJson/Strings/String.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/ArduinoJson/Strings/String.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | |||||||
|  | // ArduinoJson - arduinojson.org | ||||||
|  | // Copyright Benoit Blanchon 2014-2018 | ||||||
|  | // MIT License | ||||||
|  |  | ||||||
|  | #pragma once | ||||||
|  |  | ||||||
|  | namespace ARDUINOJSON_NAMESPACE { | ||||||
|  |  | ||||||
|  | class String { | ||||||
|  |  public: | ||||||
|  |   String() : _data(0) {} | ||||||
|  |   String(const char* slot) : _data(slot) {} | ||||||
|  |  | ||||||
|  |   const char* c_str() const { | ||||||
|  |     return _data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   bool isNull() const { | ||||||
|  |     return !_data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   friend bool operator==(String lhs, String rhs) { | ||||||
|  |     if (lhs._data == rhs._data) return true; | ||||||
|  |     if (!lhs._data) return false; | ||||||
|  |     if (!rhs._data) return false; | ||||||
|  |     return strcmp(lhs._data, rhs._data) == 0; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  private: | ||||||
|  |   const char* _data; | ||||||
|  | }; | ||||||
|  | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
| @@ -18,19 +18,19 @@ template <typename T> | |||||||
| struct IsString<T&> : IsString<T> {}; | struct IsString<T&> : IsString<T> {}; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE
 | }  // namespace ARDUINOJSON_NAMESPACE
 | ||||||
| 
 | 
 | ||||||
| #include "FixedSizeRamString.hpp" | #include "ConstRamStringWrapper.hpp" | ||||||
| #include "ZeroTerminatedRamString.hpp" | #include "RamStringWrapper.hpp" | ||||||
| #include "ZeroTerminatedRamStringConst.hpp" | #include "SizedRamStringWrapper.hpp" | ||||||
| 
 | 
 | ||||||
| #if ARDUINOJSON_ENABLE_STD_STRING | #if ARDUINOJSON_ENABLE_STD_STRING | ||||||
| #include "StlString.hpp" | #include "StlStringWrapper.hpp" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if ARDUINOJSON_ENABLE_ARDUINO_STRING | #if ARDUINOJSON_ENABLE_ARDUINO_STRING | ||||||
| #include "ArduinoString.hpp" | #include "ArduinoStringWrapper.hpp" | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if ARDUINOJSON_ENABLE_PROGMEM | #if ARDUINOJSON_ENABLE_PROGMEM | ||||||
| #include "FixedSizeFlashString.hpp" | #include "FlashStringWrapper.hpp" | ||||||
| #include "ZeroTerminatedFlashString.hpp" | #include "SizedFlashStringWrapper.hpp" | ||||||
| #endif | #endif | ||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include "../Memory/MemoryPool.hpp" | #include "../Memory/MemoryPool.hpp" | ||||||
| #include "../Polyfills/assert.hpp" | #include "../Polyfills/assert.hpp" | ||||||
| #include "../Strings/StringTypes.hpp" | #include "../Strings/StringWrappers.hpp" | ||||||
| #include "VariantData.hpp" | #include "VariantData.hpp" | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
| @@ -20,7 +20,7 @@ inline bool slotSetKey(VariantSlot* var, TKey key, MemoryPool* pool) { | |||||||
|   return true; |   return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool slotSetKey(VariantSlot* var, ZeroTerminatedRamStringConst key, | inline bool slotSetKey(VariantSlot* var, ConstRamStringWrapper key, | ||||||
|                        MemoryPool*) { |                        MemoryPool*) { | ||||||
|   if (!var) return false; |   if (!var) return false; | ||||||
|   var->setLinkedKey(key.c_str()); |   var->setLinkedKey(key.c_str()); | ||||||
|   | |||||||
| @@ -95,8 +95,7 @@ class VariantData { | |||||||
|       case VALUE_IS_OBJECT: |       case VALUE_IS_OBJECT: | ||||||
|         return toObject().copyFrom(src._content.asCollection, pool); |         return toObject().copyFrom(src._content.asCollection, pool); | ||||||
|       case VALUE_IS_OWNED_STRING: |       case VALUE_IS_OWNED_STRING: | ||||||
|         return setOwnedString(ZeroTerminatedRamString(src._content.asString), |         return setOwnedString(RamStringWrapper(src._content.asString), pool); | ||||||
|                               pool); |  | ||||||
|       case VALUE_IS_OWNED_RAW: |       case VALUE_IS_OWNED_RAW: | ||||||
|         return setOwnedRaw( |         return setOwnedRaw( | ||||||
|             serialized(src._content.asRaw.data, src._content.asRaw.size), pool); |             serialized(src._content.asRaw.data, src._content.asRaw.size), pool); | ||||||
| @@ -190,7 +189,7 @@ class VariantData { | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   bool setOwnedRaw(SerializedValue<T> value, MemoryPool *pool) { |   bool setOwnedRaw(SerializedValue<T> value, MemoryPool *pool) { | ||||||
|     char *dup = makeString(value.data(), value.size()).save(pool); |     char *dup = wrapString(value.data(), value.size()).save(pool); | ||||||
|     if (dup) { |     if (dup) { | ||||||
|       setType(VALUE_IS_OWNED_RAW); |       setType(VALUE_IS_OWNED_RAW); | ||||||
|       _content.asRaw.data = dup; |       _content.asRaw.data = dup; | ||||||
|   | |||||||
| @@ -183,7 +183,7 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   FORCE_INLINE bool set( |   FORCE_INLINE bool set( | ||||||
|       const T &value, |       const T &value, | ||||||
|       typename enable_if<IsString<T>::value>::type * = 0) const { |       typename enable_if<IsString<T>::value>::type * = 0) const { | ||||||
|     return variantSetOwnedString(_data, makeString(value), _pool); |     return variantSetOwnedString(_data, wrapString(value), _pool); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // set(char*) |   // set(char*) | ||||||
| @@ -191,7 +191,7 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool set( |   FORCE_INLINE bool set( | ||||||
|       T *value, typename enable_if<IsString<T *>::value>::type * = 0) const { |       T *value, typename enable_if<IsString<T *>::value>::type * = 0) const { | ||||||
|     return variantSetOwnedString(_data, makeString(value), _pool); |     return variantSetOwnedString(_data, wrapString(value), _pool); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // set(const char*); |   // set(const char*); | ||||||
| @@ -304,17 +304,17 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<IsString<TString>::value, VariantConstRef>::type |       typename enable_if<IsString<TString>::value, VariantConstRef>::type | ||||||
|       operator[](const TString &key) const { |       operator[](const TString &key) const { | ||||||
|     return VariantConstRef(objectGet(variantAsObject(_data), makeString(key))); |     return VariantConstRef(objectGet(variantAsObject(_data), wrapString(key))); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // VariantConstRef operator[](TKey); |   // VariantConstRef operator[](TKey); | ||||||
|   // TKey = const char*, const char[N], const FlashStringHelper* |   // TKey = const char*, const char[N], const __FlashStringHelper* | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<IsString<TString *>::value, VariantConstRef>::type |       typename enable_if<IsString<TString *>::value, VariantConstRef>::type | ||||||
|       operator[](TString *key) const { |       operator[](TString *key) const { | ||||||
|     const CollectionData *obj = variantAsObject(_data); |     const CollectionData *obj = variantAsObject(_data); | ||||||
|     return VariantConstRef(obj ? obj->get(makeString(key)) : 0); |     return VariantConstRef(obj ? obj->get(wrapString(key)) : 0); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user