JsonContainer.hpp 1.3 KB

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