Reduced memory consumption by not duplicating spaces and comments

This commit is contained in:
Benoit Blanchon
2016-12-29 17:26:16 +01:00
parent 8032a4b564
commit 3f96e070ce
20 changed files with 596 additions and 287 deletions

View File

@@ -10,27 +10,34 @@
namespace ArduinoJson {
namespace Internals {
// Parse JSON string to create JsonArrays and JsonObjects
// This internal class is not indended to be used directly.
// Instead, use JsonBuffer.parseArray() or .parseObject()
class StringWriter {
public:
StringWriter(char *buffer) : _ptr(buffer) {}
class String {
public:
String(char** ptr) : _writePtr(ptr), _startPtr(*ptr) {}
const char *startString() {
return _ptr;
}
void append(char c) {
*(*_writePtr)++ = c;
}
void stopString() {
*_ptr++ = 0;
}
const char* c_str() const {
*(*_writePtr)++ = 0;
return _startPtr;
}
void append(char c) {
*_ptr++ = c;
private:
char** _writePtr;
char* _startPtr;
};
StringWriter(char* buffer) : _ptr(buffer) {}
String startString() {
return String(&_ptr);
}
private:
char *_ptr;
char* _ptr;
};
}
}