forked from bblanchon/ArduinoJson
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
// ArduinoJson - arduinojson.org
|
|
// Copyright Benoit Blanchon 2014-2019
|
|
// MIT License
|
|
|
|
#pragma once
|
|
|
|
#include "JsonDocument.hpp"
|
|
|
|
namespace ARDUINOJSON_NAMESPACE {
|
|
|
|
template <size_t desiredCapacity>
|
|
class StaticJsonDocument : public JsonDocument {
|
|
static const size_t _capacity =
|
|
AddPadding<Max<1, desiredCapacity>::value>::value;
|
|
|
|
public:
|
|
StaticJsonDocument() : JsonDocument(_buffer, _capacity) {}
|
|
|
|
StaticJsonDocument(const StaticJsonDocument& src)
|
|
: JsonDocument(_buffer, _capacity) {
|
|
set(src);
|
|
}
|
|
|
|
template <typename T>
|
|
StaticJsonDocument(const T& src,
|
|
typename enable_if<IsVisitable<T>::value>::type* = 0)
|
|
: JsonDocument(_buffer, _capacity) {
|
|
set(src);
|
|
}
|
|
|
|
// disambiguate
|
|
StaticJsonDocument(VariantRef src) : JsonDocument(_buffer, _capacity) {
|
|
set(src);
|
|
}
|
|
|
|
StaticJsonDocument operator=(const StaticJsonDocument& src) {
|
|
set(src);
|
|
return *this;
|
|
}
|
|
|
|
template <typename T>
|
|
StaticJsonDocument operator=(const T& src) {
|
|
set(src);
|
|
return *this;
|
|
}
|
|
|
|
private:
|
|
char _buffer[_capacity];
|
|
};
|
|
|
|
} // namespace ARDUINOJSON_NAMESPACE
|