JsonContainer.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #pragma once
  2. #include "Arduino/Printable.hpp"
  3. #include "Internals/JsonNodeIterator.hpp"
  4. #include "Internals/JsonNode.hpp"
  5. #include "Internals/IndentedPrint.hpp"
  6. #include "Internals/JsonNodeWrapper.hpp"
  7. namespace ArduinoJson {
  8. class JsonArray;
  9. class JsonObject;
  10. class JsonValue;
  11. class JsonContainer : public Printable, public Internals::JsonNodeWrapper {
  12. friend class JsonArray;
  13. public:
  14. JsonContainer() {}
  15. explicit JsonContainer(Internals::JsonNode *node) : JsonNodeWrapper(node) {}
  16. size_t size() const;
  17. bool operator==(JsonContainer const &other) const;
  18. size_t printTo(char *buffer, size_t bufferSize) const;
  19. virtual size_t printTo(Print &print) const;
  20. size_t prettyPrintTo(char *buffer, size_t bufferSize) const;
  21. size_t prettyPrintTo(ArduinoJson::Internals::IndentedPrint &print) const;
  22. size_t prettyPrintTo(Print &print) const;
  23. protected:
  24. Internals::JsonNodeIterator beginChildren() const {
  25. return Internals::JsonNodeIterator(_node ? _node->getContainerChild() : 0);
  26. }
  27. Internals::JsonNodeIterator endChildren() const {
  28. return Internals::JsonNodeIterator(0);
  29. }
  30. void addChild(Internals::JsonNode *);
  31. void removeChild(Internals::JsonNode *);
  32. Internals::JsonNode *createNode();
  33. };
  34. }