forked from bblanchon/ArduinoJson
Test that JsonObject.size() is increased when values are added
This commit is contained in:
38
srcs/JsonObject.cpp
Normal file
38
srcs/JsonObject.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
//#include "JsonBuffer.h"
|
||||
#include "JsonObject.h"
|
||||
#include "JsonValue.h"
|
||||
//#include "JsonNode.h"
|
||||
|
||||
|
||||
//JsonValue& JsonObject::operator[](char const* key)
|
||||
//{
|
||||
// addNodeAt(key, innerObject._node);
|
||||
// return innerObject;
|
||||
//}
|
||||
//
|
||||
//void JsonObject::addNodeAt(const char* key, JsonNode& node)
|
||||
//{
|
||||
// JsonNode& keyNode = _buffer.createNode();
|
||||
// keyNode.becomeKey(key, node);
|
||||
// appendChild(keyNode);
|
||||
//}
|
||||
//
|
||||
//void JsonObject::appendChild(JsonNode& newChild)
|
||||
//{
|
||||
// JsonNode* lastChild = _node.asObjectNode.child;
|
||||
// while (lastChild->next)
|
||||
// {
|
||||
// lastChild = lastChild->next;
|
||||
// }
|
||||
//
|
||||
// if (lastChild)
|
||||
// lastChild->next = &newChild;
|
||||
// else
|
||||
// _node.asObjectNode.child = &newChild;
|
||||
//}
|
||||
|
||||
JsonValue JsonObject::operator[](char const* key)
|
||||
{
|
||||
_size++;
|
||||
return JsonValue();
|
||||
}
|
@ -1,42 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
class JsonBuffer;
|
||||
struct JsonNode;
|
||||
class JsonValue;
|
||||
struct JsonNode;
|
||||
|
||||
class JsonObject
|
||||
{
|
||||
// friend class JsonValue;
|
||||
//
|
||||
//public:
|
||||
// JsonObject(JsonBuffer& buffer, JsonNode& node)
|
||||
// : _buffer(buffer), _node(node)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// JsonObject createObject(const char* key)
|
||||
// {
|
||||
// JsonObject innerObject = _buffer.createObject();
|
||||
// addNodeAt(key, innerObject._node);
|
||||
// return innerObject;
|
||||
// }
|
||||
//
|
||||
// JsonValue& operator[](const char* key);
|
||||
// friend class JsonValue;
|
||||
//
|
||||
//public:
|
||||
// JsonObject(JsonBuffer& buffer, JsonNode& node)
|
||||
// : _buffer(buffer), _node(node)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// JsonObject createObject(const char* key)
|
||||
// {
|
||||
// JsonObject innerObject = _buffer.createObject();
|
||||
// addNodeAt(key, innerObject._node);
|
||||
// return innerObject;
|
||||
// }
|
||||
//
|
||||
|
||||
public:
|
||||
|
||||
int size()
|
||||
|
||||
explicit JsonObject()
|
||||
: _size(0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//private:
|
||||
// JsonBuffer& _buffer;
|
||||
// JsonNode& _node;
|
||||
//
|
||||
// void addNodeAt(char const* key, JsonNode& node);
|
||||
// JsonNode& getNodeAt(const char* key);
|
||||
//
|
||||
// // TODO: pull up
|
||||
// void appendChild(JsonNode& newChild);
|
||||
int size()
|
||||
{
|
||||
return _size;
|
||||
}
|
||||
|
||||
JsonValue operator[](const char* key);
|
||||
|
||||
private:
|
||||
|
||||
int _size;
|
||||
|
||||
// JsonBuffer& _buffer;
|
||||
// JsonNode& _node;
|
||||
//
|
||||
// void addNodeAt(char const* key, JsonNode& node);
|
||||
// JsonNode& getNodeAt(const char* key);
|
||||
//
|
||||
// // TODO: pull up
|
||||
// void appendChild(JsonNode& newChild);
|
||||
};
|
26
srcs/JsonValue.h
Normal file
26
srcs/JsonValue.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
//class JsonBuffer;
|
||||
//class JsonNode;
|
||||
//class JsonObject;
|
||||
|
||||
class JsonValue
|
||||
{
|
||||
//public:
|
||||
//
|
||||
// JsonValue(JsonBuffer& buffer, JsonNode& node)
|
||||
// : _buffer(buffer), _node(node)
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// void operator=(const JsonObject& object);
|
||||
// void operator=(int);
|
||||
//
|
||||
// operator JsonObject();
|
||||
// operator int();
|
||||
//
|
||||
//private:
|
||||
// JsonBuffer& _buffer;
|
||||
// JsonNode& _node;
|
||||
};
|
||||
|
@ -66,8 +66,12 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="JsonObject.h" />
|
||||
<ClInclude Include="JsonValue.h" />
|
||||
<ClInclude Include="StaticJsonBuffer.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="JsonObject.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
@ -21,5 +21,13 @@
|
||||
<ClInclude Include="JsonObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="JsonValue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="JsonObject.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user