Refactored to use StringBuilder

This commit is contained in:
Benoit Blanchon
2014-09-30 16:40:00 +02:00
parent ab2587f089
commit 6b2705769a
9 changed files with 156 additions and 6 deletions

31
srcs/StringBuilder.h Normal file
View File

@ -0,0 +1,31 @@
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
#include "Print.h"
namespace ArduinoJson
{
namespace Internals
{
class StringBuilder : public Print
{
public:
StringBuilder(char* buf, int size)
: buffer(buf), capacity(size - 1), length(0)
{
buffer[0] = 0;
}
virtual size_t write(uint8_t c);
private:
char* buffer;
int capacity;
int length;
};
}
}