mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added tests for FlashStringAdapter
This commit is contained in:
		
							
								
								
									
										23
									
								
								extras/tests/Helpers/progmem_emulation.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								extras/tests/Helpers/progmem_emulation.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| // ArduinoJson - arduinojson.org | ||||
| // Copyright Benoit Blanchon 2014-2020 | ||||
| // MIT License | ||||
|  | ||||
| #include <stdint.h>  // uint8_t | ||||
| #include <string.h>  // strcmp, strlen... | ||||
|  | ||||
| class __FlashStringHelper; | ||||
|  | ||||
| inline const void* convertPtrToFlash(const void* s) { | ||||
|   return reinterpret_cast<const char*>(s) + 42; | ||||
| } | ||||
|  | ||||
| inline const void* convertFlashToPtr(const void* s) { | ||||
|   return reinterpret_cast<const char*>(s) - 42; | ||||
| } | ||||
|  | ||||
| #define F(X) reinterpret_cast<const __FlashStringHelper*>(convertPtrToFlash(X)) | ||||
| #define FC(X) reinterpret_cast<const char*>(convertPtrToFlash(X)) | ||||
|  | ||||
| inline uint8_t pgm_read_byte(const void* p) { | ||||
|   return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p)); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user