JsonBuffer.cpp 674 B

123456789101112131415161718192021222324252627282930313233
  1. #include "JsonBuffer.h"
  2. #include <string.h> // for memset
  3. #include "JsonObject.h"
  4. #include "JsonValue.h"
  5. #include "Internals/JsonNode.h"
  6. JsonObject JsonBuffer::createObject()
  7. {
  8. JsonNode* node = createNode(JSON_OBJECT);
  9. if (node)
  10. node->content.asContainer.buffer = this;
  11. return JsonObject(node);
  12. }
  13. JsonValue JsonBuffer::createValue()
  14. {
  15. JsonNode* node = createNode(JSON_UNDEFINED);
  16. return JsonValue(node);
  17. }
  18. JsonNode* JsonBuffer::createNode(JsonNodeType type)
  19. {
  20. JsonNode* node = allocateNode();
  21. if (!node) return 0;
  22. memset(node, 0, sizeof(JsonNode));
  23. node->type = type;
  24. return node;
  25. }