Redesigned JsonVariant to leverage converting constructors instead of assignment operators

This commit is contained in:
Benoit Blanchon
2015-05-23 15:32:50 +02:00
parent 08d05df00e
commit 756c279cdc
44 changed files with 934 additions and 649 deletions

View File

@@ -39,7 +39,7 @@ class List {
// Returns the numbers of elements in the list.
// For a JsonObject, it would return the number of key-value pairs
int size() const;
size_t size() const;
iterator begin() { return iterator(_firstNode); }
iterator end() { return iterator(NULL); }
@@ -48,19 +48,20 @@ class List {
const_iterator end() const { return const_iterator(NULL); }
protected:
node_type *createNode() {
node_type *addNewNode() {
if (!_buffer) return NULL;
return new (_buffer) node_type();
}
void addNode(node_type *nodeToAdd) {
node_type *newNode = new (_buffer) node_type();
if (_firstNode) {
node_type *lastNode = _firstNode;
while (lastNode->next) lastNode = lastNode->next;
lastNode->next = nodeToAdd;
lastNode->next = newNode;
} else {
_firstNode = nodeToAdd;
_firstNode = newNode;
}
return newNode;
}
void removeNode(node_type *nodeToRemove);