Fix function returns incomplete class type on IAR (issue #2001)

This commit is contained in:
Benoit Blanchon
2023-12-07 14:43:40 +01:00
parent 38441691cd
commit 3e1be980d9
3 changed files with 39 additions and 16 deletions

View File

@ -1,6 +1,11 @@
ArduinoJson: change log ArduinoJson: change log
======================= =======================
HEAD
----
* Fix warning `function returns incomplete class type` on IAR (issue #2001)
v6.21.4 (2023-12-07) v6.21.4 (2023-12-07)
------- -------

View File

@ -110,6 +110,13 @@ inline JsonVariant VariantRefBase<TDerived>::add() const {
variantAddElement(getOrCreateData(), getPool())); variantAddElement(getOrCreateData(), getPool()));
} }
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
VariantRefBase<TDerived>::as() const {
return Converter<T>::fromJson(getVariant());
}
template <typename TDerived> template <typename TDerived>
inline JsonVariant VariantRefBase<TDerived>::getVariant() const { inline JsonVariant VariantRefBase<TDerived>::getVariant() const {
return JsonVariant(getPool(), getData()); return JsonVariant(getPool(), getData());
@ -120,6 +127,29 @@ inline JsonVariant VariantRefBase<TDerived>::getOrCreateVariant() const {
return JsonVariant(getPool(), getOrCreateData()); return JsonVariant(getPool(), getOrCreateData());
} }
template <typename TDerived>
template <typename T>
inline typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
VariantRefBase<TDerived>::is() const {
return Converter<T>::checkJson(getVariant());
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(const T& value) const {
Converter<T>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
template <typename TDerived>
template <typename T>
inline bool VariantRefBase<TDerived>::set(T* value) const {
Converter<T*>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
template <typename TDerived> template <typename TDerived>
template <typename T> template <typename T>
inline typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type inline typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type

View File

@ -57,9 +57,7 @@ class VariantRefBase : public VariantTag {
// https://arduinojson.org/v6/api/jsonvariant/as/ // https://arduinojson.org/v6/api/jsonvariant/as/
template <typename T> template <typename T>
FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type FORCE_INLINE typename enable_if<ConverterNeedsWriteableRef<T>::value, T>::type
as() const { as() const;
return Converter<T>::fromJson(getVariant());
}
template <typename T, template <typename T,
typename = typename enable_if<!is_same<T, TDerived>::value>::type> typename = typename enable_if<!is_same<T, TDerived>::value>::type>
@ -92,9 +90,7 @@ class VariantRefBase : public VariantTag {
template <typename T> template <typename T>
FORCE_INLINE FORCE_INLINE
typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type typename enable_if<ConverterNeedsWriteableRef<T>::value, bool>::type
is() const { is() const;
return Converter<T>::checkJson(getVariant());
}
// Returns true if the value is of the specified type. // Returns true if the value is of the specified type.
// https://arduinojson.org/v6/api/jsonvariant/is/ // https://arduinojson.org/v6/api/jsonvariant/is/
@ -123,20 +119,12 @@ class VariantRefBase : public VariantTag {
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v6/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(const T& value) const { FORCE_INLINE bool set(const T& value) const;
Converter<T>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
// Copies the specified value. // Copies the specified value.
// https://arduinojson.org/v6/api/jsonvariant/set/ // https://arduinojson.org/v6/api/jsonvariant/set/
template <typename T> template <typename T>
FORCE_INLINE bool set(T* value) const { FORCE_INLINE bool set(T* value) const;
Converter<T*>::toJson(value, getOrCreateVariant());
MemoryPool* pool = getPool();
return pool && !pool->overflowed();
}
// Returns the size of the array or object. // Returns the size of the array or object.
// https://arduinojson.org/v6/api/jsonvariant/size/ // https://arduinojson.org/v6/api/jsonvariant/size/