forked from bblanchon/ArduinoJson
Move sizeofArray()
and sizeofObject()
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <ArduinoJson/Array/ArrayData.hpp>
|
#include <ArduinoJson/Array/ArrayData.hpp>
|
||||||
#include <ArduinoJson/Variant/VariantCompare.hpp>
|
#include <ArduinoJson/Variant/VariantCompare.hpp>
|
||||||
|
#include <ArduinoJson/Variant/VariantSlot.hpp>
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
@ -70,4 +71,9 @@ inline bool ArrayData::addValue(T&& value, ResourceManager* resources) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the size (in bytes) of an array with n elements.
|
||||||
|
constexpr size_t sizeofArray(size_t n) {
|
||||||
|
return n * sizeof(VariantSlot);
|
||||||
|
}
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <ArduinoJson/Object/ObjectData.hpp>
|
#include <ArduinoJson/Object/ObjectData.hpp>
|
||||||
#include <ArduinoJson/Variant/VariantCompare.hpp>
|
#include <ArduinoJson/Variant/VariantCompare.hpp>
|
||||||
|
#include <ArduinoJson/Variant/VariantSlot.hpp>
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
@ -67,4 +68,9 @@ inline VariantData* ObjectData::addMember(TAdaptedString key,
|
|||||||
return valueSlot.data();
|
return valueSlot.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the size (in bytes) of an object with n members.
|
||||||
|
constexpr size_t sizeofObject(size_t n) {
|
||||||
|
return 2 * n * sizeof(VariantSlot);
|
||||||
|
}
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
@ -24,14 +24,4 @@ union VariantSlot {
|
|||||||
FreeSlot free;
|
FreeSlot free;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the size (in bytes) of an array with n elements.
|
|
||||||
constexpr size_t sizeofArray(size_t n) {
|
|
||||||
return n * sizeof(VariantSlot);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the size (in bytes) of an object with n members.
|
|
||||||
constexpr size_t sizeofObject(size_t n) {
|
|
||||||
return 2 * n * sizeof(VariantSlot);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
Reference in New Issue
Block a user