mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
31 lines
930 B
C++
31 lines
930 B
C++
// ArduinoJson - arduinojson.org
|
|
// Copyright Benoit Blanchon 2014-2018
|
|
// MIT License
|
|
|
|
#pragma once
|
|
|
|
#include "Data/List.hpp"
|
|
#include "JsonPair.hpp"
|
|
#include "Memory/JsonBufferAllocated.hpp"
|
|
#include "Polyfills/type_traits.hpp"
|
|
|
|
// Returns the size (in bytes) of an object with n elements.
|
|
// Can be very handy to determine the size of a StaticJsonBuffer.
|
|
#define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \
|
|
(sizeof(ArduinoJson::Internals::JsonObjectData) + \
|
|
(NUMBER_OF_ELEMENTS) * \
|
|
sizeof(ArduinoJson::Internals::JsonObjectData::node_type))
|
|
|
|
namespace ArduinoJson {
|
|
namespace Internals {
|
|
struct JsonObjectData : List<JsonPairData>, JsonBufferAllocated {
|
|
JsonVariantData* addSlot(JsonBuffer* buffer, const char* key) {
|
|
iterator it = add(buffer);
|
|
if (it == end()) return 0;
|
|
it->key = key;
|
|
return &it->value;
|
|
}
|
|
};
|
|
} // namespace Internals
|
|
} // namespace ArduinoJson
|