mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 11:36:36 +02:00
43 lines
568 B
C++
43 lines
568 B
C++
#pragma once
|
|
|
|
#include "JsonBuffer.h"
|
|
#include "JsonObject.h"
|
|
|
|
template<int CAPACITY>
|
|
class StaticJsonBuffer : public JsonBuffer
|
|
{
|
|
friend 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:
|
|
JsonNode _buffer[CAPACITY];
|
|
int _size;
|
|
};
|
|
|