as<int>()

This commit is contained in:
Benoit Blanchon
2022-03-11 18:49:34 +01:00
parent 6a23b014dc
commit 6691c5170b
5 changed files with 56 additions and 0 deletions

View File

@@ -134,6 +134,8 @@ class VariantData {
template <typename T>
bool isInteger() const {
if (isPointer())
return _content.asPointer->isInteger<T>();
switch (type()) {
case VALUE_IS_UNSIGNED_INTEGER:
return canConvertNumber<T>(_content.asUnsignedInteger);

View File

@@ -17,6 +17,8 @@ namespace ARDUINOJSON_NAMESPACE {
template <typename T>
inline T VariantData::asIntegral() const {
if (isPointer())
return _content.asPointer->asIntegral<T>();
switch (type()) {
case VALUE_IS_BOOLEAN:
return _content.asBoolean;