mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Renamed union members
This commit is contained in:
		| @@ -9,29 +9,29 @@ | |||||||
|  |  | ||||||
| size_t JsonValue::printBooleanTo(Print& p) const | size_t JsonValue::printBooleanTo(Print& p) const | ||||||
| { | { | ||||||
|     return p.write(content.boolean ? "true" : "false"); |     return p.write(content.asBool ? "true" : "false"); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t JsonValue::printNumberTo(Print& p) const | size_t JsonValue::printNumberTo(Print& p) const | ||||||
| { | { | ||||||
|     char tmp[16]; |     char tmp[16]; | ||||||
|  |  | ||||||
|     sprintf(tmp, "%lg", content.number); |     sprintf(tmp, "%lg", content.asDouble); | ||||||
|  |  | ||||||
|     return p.write(tmp); |     return p.write(tmp); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t JsonValue::printObjectTo(Print& p) const | size_t JsonValue::printObjectTo(Print& p) const | ||||||
| { | { | ||||||
|     if (content.object) |     if (content.asPrintable) | ||||||
|         return ((Printable*) content.object)->printTo(p); |         return ((Printable*) content.asPrintable)->printTo(p); | ||||||
|     else |     else | ||||||
|         return p.write("null"); |         return p.write("null"); | ||||||
| } | } | ||||||
|  |  | ||||||
| size_t JsonValue::printStringTo(Print& p) const | size_t JsonValue::printStringTo(Print& p) const | ||||||
| { | { | ||||||
|     const char* s = content.string; |     const char* s = content.asString; | ||||||
|  |  | ||||||
|     if (!s) |     if (!s) | ||||||
|     { |     { | ||||||
|   | |||||||
| @@ -19,25 +19,25 @@ public: | |||||||
|     JsonValue(const char* value) |     JsonValue(const char* value) | ||||||
|         : implementation(&JsonValue::printStringTo) |         : implementation(&JsonValue::printStringTo) | ||||||
|     { |     { | ||||||
|         content.string = value; |         content.asString = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     JsonValue(double value) |     JsonValue(double value) | ||||||
|         : implementation(&JsonValue::printNumberTo) |         : implementation(&JsonValue::printNumberTo) | ||||||
|     { |     { | ||||||
|         content.number = value; |         content.asDouble = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     JsonValue(bool value) |     JsonValue(bool value) | ||||||
|         : implementation(&JsonValue::printBooleanTo) |         : implementation(&JsonValue::printBooleanTo) | ||||||
|     { |     { | ||||||
|         content.boolean = value; |         content.asBool = value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     JsonValue(Printable& value) |     JsonValue(Printable& value) | ||||||
|         : implementation(&JsonValue::printObjectTo) |         : implementation(&JsonValue::printObjectTo) | ||||||
|     { |     { | ||||||
|         content.object = &value; |         content.asPrintable = &value; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     virtual size_t printTo(Print& p) const |     virtual size_t printTo(Print& p) const | ||||||
| @@ -50,10 +50,10 @@ private: | |||||||
|      |      | ||||||
|     union Content |     union Content | ||||||
|     { |     { | ||||||
|         bool        boolean; |         bool        asBool; | ||||||
|         double      number; |         double      asDouble; | ||||||
|         Printable*  object; |         Printable*  asPrintable; | ||||||
|         const char* string; |         const char* asString; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     Content content; |     Content content; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user