Skip to content

Commit 1d24caf

Browse files
committed
Added InvalidConversion to identify invalid conversions (closes #1585)
1 parent dc76c51 commit 1d24caf

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ HEAD
88
* Fixed error `[Pe070]: incomplete type is not allowed` on IAR (issue #1560)
99
* Fixed `serializeJson(doc, String)` when allocation fails (issue #1572)
1010
* Fixed clang-tidy warnings (issue #1574, PR #1577 by @armandas)
11+
* Added fake class `InvalidConversion<T1,T2>` to easily identify invalid conversions (issue #1585)
1112

1213
v6.18.0 (2021-05-05)
1314
-------

src/ArduinoJson/Array/ArrayRef.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ struct Converter<ArrayRef> {
193193
return ArrayRef(pool, data != 0 ? data->asArray() : 0);
194194
}
195195

196+
static InvalidConversion<VariantConstRef, ArrayRef> fromJson(VariantConstRef);
197+
196198
static bool checkJson(VariantConstRef) {
197199
return false;
198200
}

src/ArduinoJson/Object/ObjectRef.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ struct Converter<ObjectRef> {
265265
return ObjectRef(pool, data != 0 ? data->asObject() : 0);
266266
}
267267

268+
static InvalidConversion<VariantConstRef, ObjectRef> fromJson(
269+
VariantConstRef);
270+
268271
static bool checkJson(VariantConstRef) {
269272
return false;
270273
}

src/ArduinoJson/Variant/Converter.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ namespace ARDUINOJSON_NAMESPACE {
99
template <typename T, typename Enable = void>
1010
struct Converter;
1111

12+
// clang-format off
13+
template <typename T1, typename T2>
14+
class InvalidConversion; // Error here? See https://arduinojson.org/v6/invalid-conversion/
15+
// clang-format on
16+
1217
} // namespace ARDUINOJSON_NAMESPACE

src/ArduinoJson/Variant/VariantRef.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,19 @@ struct Converter<VariantRef> {
342342
static bool toJson(VariantRef src, VariantRef dst) {
343343
return variantCopyFrom(getData(dst), getData(src), getPool(dst));
344344
}
345+
345346
static VariantRef fromJson(VariantRef src) {
346347
return src;
347348
}
349+
350+
static InvalidConversion<VariantConstRef, VariantRef> fromJson(
351+
VariantConstRef);
352+
348353
static bool checkJson(VariantRef src) {
349354
VariantData *data = getData(src);
350355
return !!data;
351356
}
357+
352358
static bool checkJson(VariantConstRef) {
353359
return false;
354360
}

0 commit comments

Comments
 (0)