2014-10-01 16:13:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2014-10-01 16:56:22 +02:00
|
|
|
#include "Arduino/Printable.h"
|
|
|
|
#include "Internals/JsonNodeIterator.h"
|
|
|
|
#include "Internals/JsonNode.h"
|
2014-10-07 11:22:10 +02:00
|
|
|
#include "Internals/IndentedPrint.h"
|
2014-10-01 16:13:36 +02:00
|
|
|
|
|
|
|
struct JsonNode;
|
2014-10-01 16:56:22 +02:00
|
|
|
class JsonValue;
|
2014-10-05 15:13:00 +02:00
|
|
|
class JsonArray;
|
2014-10-01 16:13:36 +02:00
|
|
|
|
|
|
|
class JsonContainer : public Printable
|
|
|
|
{
|
2014-10-01 16:56:22 +02:00
|
|
|
friend JsonValue;
|
2014-10-05 15:13:00 +02:00
|
|
|
friend JsonArray;
|
2014-10-01 16:56:22 +02:00
|
|
|
|
2014-10-01 16:13:36 +02:00
|
|
|
public:
|
|
|
|
JsonContainer()
|
|
|
|
: _node(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
JsonContainer(JsonNode* node)
|
|
|
|
: _node(node)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-10-01 16:56:22 +02:00
|
|
|
size_t size() const;
|
|
|
|
|
|
|
|
bool operator==(JsonContainer const& other) const;
|
|
|
|
|
2014-10-01 16:13:36 +02:00
|
|
|
size_t printTo(char* buffer, size_t bufferSize) const;
|
|
|
|
virtual size_t printTo(Print& print) const;
|
|
|
|
|
2014-10-07 11:22:10 +02:00
|
|
|
size_t prettyPrintTo(char* buffer, size_t bufferSize) const;
|
|
|
|
size_t prettyPrintTo(ArduinoJson::Generator::IndentedPrint& print) const;
|
|
|
|
size_t prettyPrintTo(Print& print) const
|
|
|
|
{
|
|
|
|
return prettyPrintTo(ArduinoJson::Generator::IndentedPrint(print));
|
|
|
|
}
|
|
|
|
|
2014-10-01 16:13:36 +02:00
|
|
|
protected:
|
2014-10-01 16:56:22 +02:00
|
|
|
|
|
|
|
JsonNodeIterator beginChildren() const
|
|
|
|
{
|
|
|
|
return JsonNodeIterator(_node ? _node->content.asContainer.child : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
JsonNodeIterator endChildren() const
|
|
|
|
{
|
|
|
|
return JsonNodeIterator(0);
|
|
|
|
}
|
|
|
|
|
2014-10-05 14:48:19 +02:00
|
|
|
void addChild(JsonNode* newChild);
|
2014-10-01 16:56:22 +02:00
|
|
|
void removeChildAfter(JsonNode* child, JsonNode* previous);
|
|
|
|
JsonNode* createNode(JsonNodeType type);
|
|
|
|
|
|
|
|
bool checkNodeType(JsonNodeType expectedType);
|
|
|
|
|
2014-10-01 16:13:36 +02:00
|
|
|
JsonNode* _node;
|
|
|
|
};
|
|
|
|
|