Files
ArduinoJson/JsonGeneratorTests/StringBuilder.cpp

27 lines
433 B
C++
Raw Normal View History

2014-06-26 12:50:48 +02:00
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
2014-06-25 13:02:39 +02:00
#include "StringBuilder.h"
2014-06-25 13:50:28 +02:00
void StringBuilder::append(const char* s)
2014-06-25 13:02:39 +02:00
{
char* tail = buffer + length;
while (*s && length<capacity)
{
buffer[length++] = *s++;
}
2014-06-25 13:02:39 +02:00
buffer[length] = 0;
}
2014-06-26 13:10:52 +02:00
2014-06-30 19:19:39 +02:00
void StringBuilder::append(char c)
{
if (length >= capacity) return;
2014-06-30 19:19:39 +02:00
buffer[length++] = c;
buffer[length] = 0;
2014-06-25 13:02:39 +02:00
}