| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  | * Arduino JSON library | 
					
						
							|  |  |  | * Benoit Blanchon 2014 - MIT License | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "JsonValue.h"
 | 
					
						
							|  |  |  | #include "JsonPair.h"
 | 
					
						
							|  |  |  | #include "JsonToken.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace ArduinoJson | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     namespace Parser | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2014-07-21 20:38:08 +02:00
										 |  |  |         // An iterator for JsonObject
 | 
					
						
							| 
									
										
										
										
											2014-07-19 14:41:29 +02:00
										 |  |  |         class JsonObjectIterator : JsonToken | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |         { | 
					
						
							|  |  |  |         public: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 20:38:08 +02:00
										 |  |  |             // Create an iterator pointing at the specified token
 | 
					
						
							| 
									
										
										
										
											2014-07-19 12:44:27 +02:00
										 |  |  |             JsonObjectIterator(JsonToken token) | 
					
						
							|  |  |  |                 : JsonToken(token) | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |             { | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 20:38:08 +02:00
										 |  |  |             // Move to the next JsonPair
 | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |             void operator++() | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2014-07-19 12:44:27 +02:00
										 |  |  |                 *this = JsonObjectIterator(nextSibling().nextSibling()); | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |             } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 20:38:08 +02:00
										 |  |  |             // Get the JsonPair pointed by the iterator
 | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |             JsonPair operator*() const | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2014-07-19 12:44:27 +02:00
										 |  |  |                 return JsonPair(*this); | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-07-19 14:41:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 20:38:08 +02:00
										 |  |  |             // Test iterator equality
 | 
					
						
							| 
									
										
										
										
											2014-07-19 14:41:29 +02:00
										 |  |  |             bool operator!= (const JsonObjectIterator& other) const | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 return JsonToken::operator!=(other); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-07-23 12:56:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // 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(); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2014-07-18 22:40:50 +02:00
										 |  |  |         }; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |