mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 08:48:30 +01:00
45 lines
718 B
C++
45 lines
718 B
C++
#pragma once
|
|
|
|
#include "JsonBuffer.hpp"
|
|
#include "JsonObject.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;
|
|
};
|
|
}
|