// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #pragma once #include namespace ARDUINOJSON_NAMESPACE { class ArrayRef; class ArrayConstRef; class ObjectRef; class ObjectConstRef; class VariantRef; class VariantConstRef; // A metafunction that returns the type of the value returned by // VariantRef::as() template struct VariantAs { typedef T type; }; template <> struct VariantAs { typedef const char* type; }; // A metafunction that returns the type of the value returned by // VariantRef::as() template struct VariantConstAs { typedef typename VariantAs::type type; }; template <> struct VariantConstAs { typedef VariantConstRef type; }; template <> struct VariantConstAs { typedef ObjectConstRef type; }; template <> struct VariantConstAs { typedef ArrayConstRef type; }; // --- template inline typename enable_if::value, T>::type variantAs( const VariantData* _data) { return _data != 0 ? _data->asIntegral() : T(0); } template inline typename enable_if::value, T>::type variantAs( const VariantData* _data) { return _data != 0 ? _data->asBoolean() : false; } template inline typename enable_if::value, T>::type variantAs( const VariantData* _data) { return _data != 0 ? _data->asFloat() : T(0); } template inline typename enable_if::value || is_same::value, const char*>::type variantAs(const VariantData* _data) { return _data != 0 ? _data->asString() : 0; } template inline typename enable_if::value, T>::type variantAs( const VariantData* _data); template inline typename enable_if::value, T>::type variantAs( const VariantData* _data); template inline typename enable_if::value, T>::type variantAs(const VariantData* _data); template inline typename enable_if::value, T>::type variantAs( const VariantData* _data); } // namespace ARDUINOJSON_NAMESPACE