mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 20:12:16 +02:00
41 lines
610 B
C++
41 lines
610 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 JsonNode* allocateNode()
|
|
{
|
|
if (_size >= CAPACITY) return 0;
|
|
|
|
return &_buffer[_size++];
|
|
}
|
|
|
|
private:
|
|
JsonNode _buffer[CAPACITY];
|
|
int _size;
|
|
}; |