mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
38 lines
664 B
C++
38 lines
664 B
C++
// Copyright Benoit Blanchon 2014
|
|
// MIT License
|
|
//
|
|
// Arduino JSON library
|
|
// https://github.com/bblanchon/ArduinoJson
|
|
|
|
#pragma once
|
|
|
|
#include "ForwardDeclarations.hpp"
|
|
#include "JsonBuffer.hpp"
|
|
|
|
namespace ArduinoJson {
|
|
template <int CAPACITY>
|
|
class StaticJsonBuffer : public JsonBuffer {
|
|
friend class JsonObject;
|
|
|
|
public:
|
|
explicit StaticJsonBuffer() : _size(0) {}
|
|
|
|
virtual ~StaticJsonBuffer() {}
|
|
|
|
int capacity() { return CAPACITY; }
|
|
|
|
int size() { return _size; }
|
|
|
|
protected:
|
|
virtual void *allocateNode() {
|
|
if (_size >= CAPACITY) return 0;
|
|
|
|
return &_buffer[_size++];
|
|
}
|
|
|
|
private:
|
|
Internals::JsonNode _buffer[CAPACITY];
|
|
int _size;
|
|
};
|
|
}
|