2014-09-27 12:16:20 +02:00
|
|
|
#include "JsonBuffer.h"
|
2014-09-27 16:18:40 +02:00
|
|
|
|
2014-09-27 14:43:19 +02:00
|
|
|
#include <string.h> // for memset
|
2014-09-27 12:16:20 +02:00
|
|
|
|
2014-09-27 16:18:40 +02:00
|
|
|
#include "JsonNode.h"
|
|
|
|
#include "JsonObject.h"
|
|
|
|
#include "JsonValue.h"
|
2014-09-27 12:16:20 +02:00
|
|
|
|
|
|
|
JsonObject JsonBuffer::createObject()
|
|
|
|
{
|
2014-09-27 14:43:19 +02:00
|
|
|
JsonNode* node = createNode(JSON_OBJECT);
|
2014-09-27 15:34:34 +02:00
|
|
|
|
|
|
|
if (node)
|
|
|
|
node->content.asObject.buffer = this;
|
|
|
|
|
|
|
|
return JsonObject(node);
|
2014-09-27 12:16:20 +02:00
|
|
|
}
|
|
|
|
|
2014-09-27 16:18:40 +02:00
|
|
|
JsonValue JsonBuffer::createValue()
|
|
|
|
{
|
|
|
|
JsonNode* node = createNode(JSON_UNDEFINED);
|
|
|
|
return JsonValue(node);
|
|
|
|
}
|
|
|
|
|
2014-09-27 14:43:19 +02:00
|
|
|
JsonNode* JsonBuffer::createNode(JsonNodeType type)
|
2014-09-27 12:16:20 +02:00
|
|
|
{
|
2014-09-27 14:43:19 +02:00
|
|
|
JsonNode* node = allocateNode();
|
|
|
|
if (!node) return 0;
|
|
|
|
|
|
|
|
memset(node, 0, sizeof(JsonNode));
|
|
|
|
node->type = type;
|
|
|
|
return node;
|
2014-09-27 12:16:20 +02:00
|
|
|
}
|