Fixed object keys not being duplicated

This commit is contained in:
Benoit Blanchon
2018-10-04 11:16:23 +02:00
parent 527dc19794
commit 6b985b2d1f
30 changed files with 368 additions and 218 deletions

View File

@@ -4,6 +4,7 @@
#pragma once
#include "../Strings/StringInMemoryPool.hpp"
#include "MemoryPool.hpp"
#include <stdlib.h>
@@ -77,9 +78,9 @@ class DynamicMemoryPoolBase : public MemoryPool {
_head = 0;
}
class String {
class StringBuilder {
public:
String(DynamicMemoryPoolBase* parent)
explicit StringBuilder(DynamicMemoryPoolBase* parent)
: _parent(parent), _start(NULL), _length(0) {}
void append(char c) {
@@ -97,7 +98,7 @@ class DynamicMemoryPoolBase : public MemoryPool {
_length++;
}
const char* c_str() {
StringInMemoryPool complete() {
append(0);
return _start;
}
@@ -108,8 +109,8 @@ class DynamicMemoryPoolBase : public MemoryPool {
size_t _length;
};
String startString() {
return String(this);
StringBuilder startString() {
return StringBuilder(this);
}
private:

View File

@@ -5,15 +5,16 @@
#pragma once
#include "../Polyfills/mpl/max.hpp"
#include "../Strings/StringInMemoryPool.hpp"
#include "MemoryPool.hpp"
namespace ARDUINOJSON_NAMESPACE {
class StaticMemoryPoolBase : public MemoryPool {
public:
class String {
class StringBuilder {
public:
String(StaticMemoryPoolBase* parent) : _parent(parent) {
explicit StringBuilder(StaticMemoryPoolBase* parent) : _parent(parent) {
_start = parent->_buffer + parent->_size;
}
@@ -24,7 +25,7 @@ class StaticMemoryPoolBase : public MemoryPool {
}
}
const char* c_str() const {
StringInMemoryPool complete() const {
if (_parent->canAlloc(1)) {
char* last = static_cast<char*>(_parent->doAlloc(1));
*last = '\0';
@@ -65,8 +66,8 @@ class StaticMemoryPoolBase : public MemoryPool {
_size = 0;
}
String startString() {
return String(this);
StringBuilder startString() {
return StringBuilder(this);
}
protected: