forked from bblanchon/ArduinoJson
-
Notifications
You must be signed in to change notification settings - Fork 2
/
JsonObjectIterator.h
58 lines (49 loc) · 1.35 KB
/
JsonObjectIterator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Arduino JSON library
* Benoit Blanchon 2014 - MIT License
*/
#pragma once
#include "JsonValue.h"
#include "JsonPair.h"
#include "JsonToken.h"
namespace ArduinoJson
{
namespace Parser
{
// An iterator for JsonObject
class JsonObjectIterator : JsonToken
{
public:
// Create an iterator pointing at the specified token
JsonObjectIterator(JsonToken token)
: JsonToken(token)
{
}
// Move to the next JsonPair
void operator++()
{
*this = JsonObjectIterator(nextSibling().nextSibling());
}
// Get the JsonPair pointed by the iterator
JsonPair operator*() const
{
return JsonPair(*this);
}
// Test iterator equality
bool operator!= (const JsonObjectIterator& other) const
{
return JsonToken::operator!=(other);
}
// Get the key of the JsonPair pointed by the iterator
const char* key() const
{
return operator*().key();
}
// Get the key of the JsonPair pointed by the iterator
JsonValue value() const
{
return operator*().value();
}
};
}
}