mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added InvalidConversion to identify invalid conversions (closes #1585)
This commit is contained in:
		| @@ -8,6 +8,7 @@ HEAD | |||||||
| * Fixed error `[Pe070]: incomplete type is not allowed` on IAR (issue #1560) | * Fixed error `[Pe070]: incomplete type is not allowed` on IAR (issue #1560) | ||||||
| * Fixed `serializeJson(doc, String)` when allocation fails (issue #1572) | * Fixed `serializeJson(doc, String)` when allocation fails (issue #1572) | ||||||
| * Fixed clang-tidy warnings (issue #1574, PR #1577 by @armandas) | * Fixed clang-tidy warnings (issue #1574, PR #1577 by @armandas) | ||||||
|  | * Added fake class `InvalidConversion<T1,T2>` to easily identify invalid conversions (issue #1585) | ||||||
|  |  | ||||||
| v6.18.0 (2021-05-05) | v6.18.0 (2021-05-05) | ||||||
| ------- | ------- | ||||||
|   | |||||||
| @@ -193,6 +193,8 @@ struct Converter<ArrayRef> { | |||||||
|     return ArrayRef(pool, data != 0 ? data->asArray() : 0); |     return ArrayRef(pool, data != 0 ? data->asArray() : 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   static InvalidConversion<VariantConstRef, ArrayRef> fromJson(VariantConstRef); | ||||||
|  |  | ||||||
|   static bool checkJson(VariantConstRef) { |   static bool checkJson(VariantConstRef) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -265,6 +265,9 @@ struct Converter<ObjectRef> { | |||||||
|     return ObjectRef(pool, data != 0 ? data->asObject() : 0); |     return ObjectRef(pool, data != 0 ? data->asObject() : 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   static InvalidConversion<VariantConstRef, ObjectRef> fromJson( | ||||||
|  |       VariantConstRef); | ||||||
|  |  | ||||||
|   static bool checkJson(VariantConstRef) { |   static bool checkJson(VariantConstRef) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -9,4 +9,9 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
| template <typename T, typename Enable = void> | template <typename T, typename Enable = void> | ||||||
| struct Converter; | struct Converter; | ||||||
|  |  | ||||||
|  | // clang-format off | ||||||
|  | template <typename T1, typename T2> | ||||||
|  | class InvalidConversion;  // Error here? See https://arduinojson.org/v6/invalid-conversion/ | ||||||
|  | // clang-format on | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -342,13 +342,19 @@ struct Converter<VariantRef> { | |||||||
|   static bool toJson(VariantRef src, VariantRef dst) { |   static bool toJson(VariantRef src, VariantRef dst) { | ||||||
|     return variantCopyFrom(getData(dst), getData(src), getPool(dst)); |     return variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static VariantRef fromJson(VariantRef src) { |   static VariantRef fromJson(VariantRef src) { | ||||||
|     return src; |     return src; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   static InvalidConversion<VariantConstRef, VariantRef> fromJson( | ||||||
|  |       VariantConstRef); | ||||||
|  |  | ||||||
|   static bool checkJson(VariantRef src) { |   static bool checkJson(VariantRef src) { | ||||||
|     VariantData *data = getData(src); |     VariantData *data = getData(src); | ||||||
|     return !!data; |     return !!data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(VariantConstRef) { |   static bool checkJson(VariantConstRef) { | ||||||
|     return false; |     return false; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user