JsonArrayIterator.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Arduino JSON library
  3. * Benoit Blanchon 2014 - MIT License
  4. */
  5. #pragma once
  6. #include "JsonValue.h"
  7. #include "JsonToken.h"
  8. namespace ArduinoJson
  9. {
  10. namespace Parser
  11. {
  12. // An iterator for JsonArray
  13. class JsonArrayIterator : JsonToken
  14. {
  15. public:
  16. // Create an iterator pointing at the specified JsonToken
  17. JsonArrayIterator(JsonToken token)
  18. : JsonToken(token)
  19. {
  20. }
  21. // Move iterator forward
  22. void operator++()
  23. {
  24. *this = JsonArrayIterator(nextSibling());
  25. }
  26. // Get the value pointed by the iterator
  27. JsonValue operator*() const
  28. {
  29. return JsonValue(*this);
  30. }
  31. // Test iterator equality
  32. bool operator!= (const JsonArrayIterator& other) const
  33. {
  34. return JsonToken::operator!=(other);
  35. }
  36. };
  37. }
  38. }