mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-11-01 08:48:30 +01:00 
			
		
		
		
	Test an object with one member
This commit is contained in:
		| @@ -7,5 +7,27 @@ | ||||
|  | ||||
| size_t IndentedPrintDecorator::write(uint8_t c) | ||||
| { | ||||
|     return sink.write(c); | ||||
|     switch (c) | ||||
|     { | ||||
|     case '{': | ||||
|         indent++;         | ||||
|         return sink.write(c) + writeln(); | ||||
|  | ||||
|     case '}': | ||||
|         indent--; | ||||
|         return writeln() + sink.write(c); | ||||
|  | ||||
|     default: | ||||
|         return sink.write(c); | ||||
|     } | ||||
| } | ||||
|  | ||||
| size_t IndentedPrintDecorator::writeln() | ||||
| { | ||||
|     size_t n = sink.write('\n'); | ||||
|  | ||||
|     for (int i = 0; i < indent; i++) | ||||
|         n += sink.write(' '); | ||||
|  | ||||
|     return n; | ||||
| } | ||||
| @@ -13,14 +13,16 @@ class IndentedPrintDecorator : public Print | ||||
| public: | ||||
|  | ||||
|     IndentedPrintDecorator(Print& p) | ||||
|         : currentLevel(0), sink(p) | ||||
|         : indent(0), sink(p) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     virtual size_t write(uint8_t); | ||||
|  | ||||
| private: | ||||
|     int currentLevel; | ||||
|     int indent; | ||||
|     Print& sink; | ||||
|  | ||||
|     size_t writeln(); | ||||
| }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user