source: rtos_arduino/trunk/arduino_lib/libraries/ArduinoJson/include/ArduinoJson/StaticJsonBuffer.hpp@ 209

Last change on this file since 209 was 209, checked in by ertl-honda, 8 years ago

BlueMix用のフィアルを追加

File size: 827 bytes
Line 
1// Copyright Benoit Blanchon 2014-2016
2// MIT License
3//
4// Arduino JSON library
5// https://github.com/bblanchon/ArduinoJson
6// If you like this project, please add a star!
7
8#pragma once
9
10#include "JsonBuffer.hpp"
11
12namespace ArduinoJson {
13
14// Implements a JsonBuffer with fixed memory allocation.
15// The template paramenter CAPACITY specifies the capacity of the buffer in
16// bytes.
17template <size_t CAPACITY>
18class StaticJsonBuffer : public JsonBuffer {
19 public:
20 explicit StaticJsonBuffer() : _size(0) {}
21
22 size_t capacity() const { return CAPACITY; }
23 size_t size() const { return _size; }
24
25 virtual void* alloc(size_t bytes) {
26 if (_size + bytes > CAPACITY) return NULL;
27 void* p = &_buffer[_size];
28 _size += round_size_up(bytes);
29 return p;
30 }
31
32 private:
33 uint8_t _buffer[CAPACITY];
34 size_t _size;
35};
36}
Note: See TracBrowser for help on using the repository browser.