7 #include <ArduinoJson/Polyfills/integer.hpp>
8 #include <ArduinoJson/Polyfills/limits.hpp>
9 #include <ArduinoJson/Polyfills/type_traits.hpp>
10 #include <ArduinoJson/Strings/StoragePolicy.hpp>
11 #include <ArduinoJson/Variant/VariantContent.hpp>
13 namespace ARDUINOJSON_NAMESPACE {
15 typedef int_t<ARDUINOJSON_SLOT_OFFSET_SIZE * 8>::type VariantSlotDiff;
23 VariantSlotDiff _next;
38 return reinterpret_cast<const VariantData*
>(&_content);
42 return _next ?
this + _next : 0;
60 return const_cast<VariantSlot*
>(
this)->next(distance);
64 ARDUINOJSON_ASSERT(!slot || slot -
this >=
66 ARDUINOJSON_ASSERT(!slot || slot -
this <=
68 _next = VariantSlotDiff(slot ? slot -
this : 0);
72 ARDUINOJSON_ASSERT(slot != 0);
73 ARDUINOJSON_ASSERT(slot -
this >=
75 ARDUINOJSON_ASSERT(slot -
this <=
77 _next = VariantSlotDiff(slot -
this);
81 ARDUINOJSON_ASSERT(k != NULL);
82 _flags |= KEY_IS_OWNED;
87 ARDUINOJSON_ASSERT(k != NULL);
92 const char* key()
const {
96 bool ownsKey()
const {
97 return (_flags & KEY_IS_OWNED) != 0;
106 void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance) {
107 if (_flags & KEY_IS_OWNED)
108 _key += stringDistance;
109 if (_flags & VALUE_IS_OWNED)
110 _content.asString += stringDistance;
111 if (_flags & COLLECTION_MASK)
112 _content.asCollection.movePointers(stringDistance, variantDistance);