mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Renamed all .h files into .hpp (so that Sublime Text selects C++ syntax)
This commit is contained in:
44
include/ArduinoJson/StaticJsonBuffer.hpp
Normal file
44
include/ArduinoJson/StaticJsonBuffer.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user