forked from bblanchon/ArduinoJson
Added JsonArray
This commit is contained in:
2
srcs/JsonArray.cpp
Normal file
2
srcs/JsonArray.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "JsonArray.h"
|
||||
|
22
srcs/JsonArray.h
Normal file
22
srcs/JsonArray.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "JsonContainer.h"
|
||||
|
||||
class JsonArray : public JsonContainer
|
||||
{
|
||||
public:
|
||||
JsonArray()
|
||||
{
|
||||
}
|
||||
|
||||
explicit JsonArray(JsonNode* node)
|
||||
: JsonContainer(node)
|
||||
{
|
||||
}
|
||||
|
||||
// JsonValue operator[](int index);
|
||||
|
||||
// template<typename T>
|
||||
// void add(T value);
|
||||
};
|
||||
|
@ -6,16 +6,6 @@
|
||||
#include "JsonValue.h"
|
||||
#include "Internals/JsonNode.h"
|
||||
|
||||
JsonObject JsonBuffer::createObject()
|
||||
{
|
||||
JsonNode* node = createNode(JSON_OBJECT);
|
||||
|
||||
if (node)
|
||||
node->content.asContainer.buffer = this;
|
||||
|
||||
return JsonObject(node);
|
||||
}
|
||||
|
||||
JsonValue JsonBuffer::createValue()
|
||||
{
|
||||
JsonNode* node = createNode(JSON_UNDEFINED);
|
||||
@ -30,4 +20,14 @@ JsonNode* JsonBuffer::createNode(JsonNodeType type)
|
||||
memset(node, 0, sizeof(JsonNode));
|
||||
node->type = type;
|
||||
return node;
|
||||
}
|
||||
|
||||
JsonNode* JsonBuffer::createContainerNode(JsonNodeType type)
|
||||
{
|
||||
JsonNode* node = createNode(type);
|
||||
|
||||
if (node)
|
||||
node->content.asContainer.buffer = this;
|
||||
|
||||
return node;
|
||||
}
|
@ -1,20 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "Internals/JsonNode.h"
|
||||
|
||||
|
||||
class JsonObject;
|
||||
class JsonValue;
|
||||
struct JsonNode;
|
||||
#include "JsonArray.h"
|
||||
#include "JsonObject.h"
|
||||
|
||||
class JsonBuffer
|
||||
{
|
||||
friend class JsonContainer;
|
||||
|
||||
public:
|
||||
// virtual ~JsonBuffer() = 0;
|
||||
virtual ~JsonBuffer() {};
|
||||
|
||||
JsonArray createArray()
|
||||
{
|
||||
return JsonArray(createContainerNode(JSON_ARRAY));
|
||||
}
|
||||
|
||||
JsonObject createObject()
|
||||
{
|
||||
return JsonObject(createContainerNode(JSON_OBJECT));
|
||||
}
|
||||
|
||||
JsonObject createObject();
|
||||
JsonValue createValue();
|
||||
|
||||
protected:
|
||||
@ -22,5 +27,6 @@ protected:
|
||||
|
||||
private:
|
||||
JsonNode* createNode(JsonNodeType type);
|
||||
JsonNode* createContainerNode(JsonNodeType type);
|
||||
};
|
||||
|
||||
|
@ -75,6 +75,7 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Internals\EscapedString.h" />
|
||||
<ClInclude Include="JsonArray.h" />
|
||||
<ClInclude Include="JsonBuffer.h" />
|
||||
<ClInclude Include="Internals\JsonNode.h" />
|
||||
<ClInclude Include="Internals\JsonNodeSerializer.h" />
|
||||
@ -89,6 +90,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Internals\EscapedString.cpp" />
|
||||
<ClCompile Include="JsonArray.cpp" />
|
||||
<ClCompile Include="JsonBuffer.cpp" />
|
||||
<ClCompile Include="Internals\JsonNodeSerializer.cpp" />
|
||||
<ClCompile Include="JsonContainer.cpp" />
|
||||
|
@ -51,6 +51,9 @@
|
||||
<ClInclude Include="Internals\JsonNodeIterator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="JsonArray.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="JsonObject.cpp">
|
||||
@ -77,5 +80,8 @@
|
||||
<ClCompile Include="JsonContainer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="JsonArray.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user