JsonBuffer.cpp 678 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. JsonValue JsonBuffer::createValue()
  7. {
  8. JsonNode* node = createNode(JSON_UNDEFINED);
  9. return JsonValue(node);
  10. }
  11. JsonNode* JsonBuffer::createNode(JsonNodeType type)
  12. {
  13. JsonNode* node = allocateNode();
  14. if (!node) return 0;
  15. memset(node, 0, sizeof(JsonNode));
  16. node->type = type;
  17. return node;
  18. }
  19. JsonNode* JsonBuffer::createContainerNode(JsonNodeType type)
  20. {
  21. JsonNode* node = createNode(type);
  22. if (node)
  23. node->content.asContainer.buffer = this;
  24. return node;
  25. }